Dowload file to /tmp
514869
def download(self, output_dir, url, overwrite):
        
        tmp = self.url2tmp(output_dir, url)
        if os.path.isfile(tmp) and not overwrite:
            logging.info("File {0} already exists. Skipping download.".format(tmp))
            return tmp
        f = open(tmp, 'wb')
        logging.info("Downloading {0}".format(url))
        res = requests.get(url, stream=True)
        if res.status_code != 200:
            # failed to download, cleanup and raise exception
            f.close()
            os.remove(tmp)
            error = "{0}\n\nFailed to download < {0} >".format(res.content, url)
            raise IOError(error)
        for block in res.iter_content(1024):
            f.write(block)
        f.close()
        return tmp
317057
def _convertTmp(self, tmpCacheEntry):
        
        from analyser.common.signal import loadSignalFromWav
        tmpCacheEntry['status'] = 'converting'
        logger.info("Loading " + tmpCacheEntry['path'])
        signal = loadSignalFromWav(tmpCacheEntry['path'])
        logger.info("Loaded " + tmpCacheEntry['path'])
        if Path(tmpCacheEntry['path']).exists():
            logger.info('Deleting ' + tmpCacheEntry['path'])
            os.remove(tmpCacheEntry['path'])
        else:
            logger.warning('Tmp cache file does not exist: ' + tmpCacheEntry['path'])
        self._tmpCache.remove(tmpCacheEntry)
        self._conversionCache.append(tmpCacheEntry)
        srcFs = signal.fs
        completeSamples = signal.samples
        outputFileName = os.path.join(self._uploadDir, tmpCacheEntry['name'])
        if srcFs > 1024:
            self.writeOutput(outputFileName, completeSamples, srcFs, 1000)
        else:
            self.writeOutput(outputFileName, completeSamples, srcFs, srcFs)
        tmpCacheEntry['status'] = 'loaded'
        self._conversionCache.remove(tmpCacheEntry)
        self._uploadCache.append(self._extractMeta(outputFileName, 'loaded'))
315917
function (files, output, name) {
    this.files = files;
    this.outputfile = path.resolve(output || os.tmpdir()) + path.sep + (name || '.check');
    this.data = {};
}
451230
def downlad_file(url, fname):
    """"""
    print("Downloading {} as {}".format(url, fname))
    response = urlopen(url)
    download = response.read()
    with open(fname, 'wb') as fh:
        fh.write(download)
1178136
public static function getFile($tmp = true, $name = null)
    {
        return ($tmp ? realpath(sys_get_temp_dir()) : '').'/'.(null === $name ? uniqid() : $name);
    }
1111707
def upload_to(instance, filename, prefix=None):
    
    ext = path.splitext(filename)[1]
    name = str(instance.pk or time()) + filename

    # We think that we use utf8 based OS file system
    filename = md5(name.encode('utf8')).hexdigest() + ext
    basedir = path.join(instance._meta.app_label, instance._meta.module_name)
    if prefix:
        basedir = path.join(basedir, prefix)
    return path.join(basedir, filename[:2], filename[2:4], filename)
504922
function ftpPut(inFilename, cb) {
    var fileUrl = '';
    if (/\//.test(inFilename)) {
      fileUrl = inFilename;
      inFilename = inFilename.split('/').slice(-1)[0];
    } else {
      fileUrl = localRoot + path.sep + currPath + path.sep + inFilename;
    }
    var fileData = fs.readFileSync(fileUrl);
    ftp.put(inFilename, fileData, function(err) {
      if (err) {
        log.error('Cannot upload file: ' + inFilename + ' --> ' + err);
        cb(err);
      } else {
        log.ok('Uploaded file: ' + inFilename.green + ' to: ' + ('/' + remoteRoot + '/' + currPath).yellow);
        cb(null);
      }
    });
  }
7275
def remove_tmp_prefix_from_file_path(file_path):
    
    path, filename = os.path.split(file_path)
    return os.path.join(path, remove_tmp_prefix_from_filename(filename)).replace('\\', '/')
863181
def save_to_temp(content, file_name=None):
    """"""

    #output = "results.html"
    temp_dir = tempfile.gettempdir()
    #tempfile.TemporaryDirectory()
    #tempfile.NamedTemporaryFile(mode='w+t') as f:
    out_file = os.path.join(temp_dir, file_name)
    #if os.path.exists(output) and os.path.isfile(output):
    file = open(out_file, 'w')
    file.write(content)
    file.close()
    #print("results saved in results.html file.")
    #return output
    #output = str(pathlib.Path(f.name))
    return out_file
529924
def tmpfile(*args, **kwargs):
    
    (fd, fname) = tempfile.mkstemp(*args, **kwargs)
    try:
        yield fname
    finally:
        os.close(fd)
        if os.path.exists(fname):
            os.remove(fname)
77874
public static File createTmpFile(InputStream inputStream, String name, String ext, File tmpDirFile) throws IOException {
    FileOutputStream fos = null;
    try {
      File tmpFile;
      if (tmpDirFile == null) {
    	  tmpFile = File.createTempFile(name, '.' + ext);
      } else {
        tmpFile = File.createTempFile(name, '.' + ext, tmpDirFile);
      }
      tmpFile.deleteOnExit();
      fos = new FileOutputStream(tmpFile);
      int read = 0;
      byte[] bytes = new byte[1024 * 100];
      while ((read = inputStream.read(bytes)) != -1) {
        fos.write(bytes, 0, read);
      }
      fos.flush();
      return tmpFile;
    } finally {
      if (inputStream != null) {
        try {
          inputStream.close();
        } catch (IOException e) {
        }
      }
      if (fos != null) {
        try {
          fos.close();
        } catch (IOException e) {
        }
      }
    }
  }
926773
def freeze_archive(tmp_dir, dest_prefix):
    """"""
    zip_filename = "%s/aomi-blah.zip" % tmp_dir
    archive = zipfile.ZipFile(zip_filename, 'w')
    for root, _dirnames, filenames in os.walk(dest_prefix):
        for filename in filenames:
            relative_path = subdir_path(root, dest_prefix).split(os.sep)[1:]
            relative_path = os.sep.join(relative_path)
            archive.write("%s/%s" % (root, filename),
                          "%s/%s" % (relative_path, filename))

    archive.close()
    return zip_filename
930428
def tmp_file(*args, **kwargs):
    
    fileno, path = tempfile.mkstemp(*args, **kwargs)

    # create the file
    with open(path, "w") as f:
        f.write("")

    # yield it
    try:
        yield fileno, path
    finally:
        if os.path.exists(path):
            os.remove(path)
341264
def make_tmpname(basename, n)
      extension = File.extname(basename)
      sprintf("%s,%d,%d%s", File.basename(basename, extension), $$, n.to_i, extension)
    end
714099
def _move_tmp_file(self, tmpfilepath, filepath):
        

        try:
            shutil.move(tmpfilepath, filepath)

        except OSError, err:
            # No tmp file present
            post_command_event(self.main_window, self.StatusBarMsg, text=err)
1034456
def tmpdir(self):
        
        if self._tmpdir is None:
            self._tmpdir = mkdtemp(prefix="colin-", dir="/var/tmp")
        return self._tmpdir
156488
def do_cat(self, path):
        """"""
        path = path[0]
        tmp_file_path = self.TMP_PATH + 'tmp'

        if not os.path.exists(self.TMP_PATH):
            os.makedirs(self.TMP_PATH)

        f = self.n.downloadFile(self.current_path + path, tmp_file_path)
        f = open(tmp_file_path, 'r')

        self.stdout.write(f.read())
        self.stdout.write("\n")