Generate a temporary filename for this deploy.
969830
def get_temp_filename(self, hash_key=None):
        '''
        
        '''

        if not hash_key:
            hash_key = six.text_type(uuid4())

        temp_filename = '{0}/{1}'.format(
            self.config.TEMP_DIR, sha1_hash(hash_key),
        )

        return temp_filename
168316
public static String temporaryFileName(long nonce, String path) {
    return path + String.format(TEMPORARY_SUFFIX_FORMAT, nonce);
  }
50614
def gen_filename(endpoint):
    
    now = datetime.now().strftime('%Y%m%d_%H%M%S%f')[:-4]
    base = endpoint.split('://', 1)[1]
    if base.startswith('localhost:'):
        base = gethostname().split('.')[0] + base[9:]
    base = base.replace(':', '_').replace('/', '_')
    return '{}_{}.h5'.format(base, now)
1133159
def _gen_file_name(self):
        '''
        
        '''
        date = datetime.datetime.now()
        dt = "{}-{}-{}-{}-{}-{}-{}".format(str(date.year),str(date.month),str(date.day),str(date.hour),str(date.minute),str(date.second),str(random.randint(0,10000)))
        return self._output_filename_pattern.format(dt)
1162427
def make_tmp_dir(suffix="", prefix="tmp", dir=None):  # pylint: disable=redefined-builtin
  """"""
  if dir is None:
    return tempfile.mkdtemp(suffix, prefix, dir)
  else:
    while True:
      rand_term = random.randint(1, 9999)
      tmp_dir = os.path.join(dir, "%s%d%s" % (prefix, rand_term, suffix))
      if tf.gfile.Exists(tmp_dir):
        continue
      tf.gfile.MakeDirs(tmp_dir)
      break
    return tmp_dir
281607
def _CreateTempDir(prefix, run_dir=None):
  
  temp_dir = tempfile.mkdtemp(prefix=prefix + '-', dir=run_dir)
  try:
    yield temp_dir
  finally:
    shutil.rmtree(temp_dir)
717506
def generate_filename(self, mark, **kwargs):
        """"""

        kwargs = kwargs.copy()

        kwargs['opacity'] = int(kwargs['opacity'] * 100)
        kwargs['st_mtime'] = kwargs['fstat'].st_mtime
        kwargs['st_size'] = kwargs['fstat'].st_size

        params = [
            '%(original_basename)s',
            'wm',
            'w%(watermark)i',
            'o%(opacity)i',
            'gs%(greyscale)i',
            'r%(rotation)i',
            'fm%(st_mtime)i',
            'fz%(st_size)i',
            'p%(position)s',
        ]

        scale = kwargs.get('scale', None)
        if scale and scale != mark.size:
            params.append('_s%i' % (float(kwargs['scale'][0]) / mark.size[0] * 100))

        if kwargs.get('tile', None):
            params.append('_tiled')

        # make thumbnail filename
        filename = '%s%s' % ('_'.join(params), kwargs['ext'])

        return filename % kwargs
1082175
def get_new_filename(self, name):
        """"""
        name = MigrationFile.normalize_name(name)
        migrations = self.get_migration_files()
        migration_id = migrations[-1].id if migrations else 0
        migration_id += 1
        return '{:04}_{}.py'.format(migration_id, name)
520136
def deploy_file(self,
                    file_name,
                    calc_md5=True,
                    calc_sha1=True,
                    parameters={}):
        
        if calc_md5:
            md5 = md5sum(file_name)
        if calc_sha1:
            sha1 = sha1sum(file_name)

        target = self

        if self.is_dir():
            target = self / pathlib.Path(file_name).name

        with open(file_name, 'rb') as fobj:
            target.deploy(fobj, md5, sha1, parameters)
1018794
def _temporary_filenames(total):
    """"""
    temp_files = [_get_temporary_filename('optimage-') for i in range(total)]
    yield temp_files
    for temp_file in temp_files:
        try:
            os.remove(temp_file)
        except OSError:
            # Continue in case we could not remove the file. One reason is that
            # the fail was never created.
            pass
196364
def rename_to_temp(filename):
    """"""
    with _rename_to_temp_lock:
        root, ext = os.path.splitext(filename)
        if len(ext) > 0:
            ext = ext[1:]  # the dot (".") is originally included
        new_name = new_filename(root, ext)
        os.rename(filename, new_name)
        return new_name
228375
def backup_name(self, timestamp=None):
        
        suffix = datetime2string(coalesce(timestamp, datetime.now()), "%Y%m%d_%H%M%S")
        return File.add_suffix(self._filename, suffix)
192035
def generate_file_name(self):
        """"""
        if not self.project:
            raise UnderDefined("project name not given")

        out_data_dir = prms.Paths.outdatadir
        project_dir = os.path.join(out_data_dir, self.project)
        file_name = "cellpy_batch_%s.json" % self.name
        self.file_name = os.path.join(project_dir, file_name)
66622
def named_temporary_file(*args, **kwargs):
  
  assert 'delete' not in kwargs
  kwargs['delete'] = False
  fp = tempfile.NamedTemporaryFile(*args, **kwargs)
  try:
    with fp:
      yield fp
  finally:
    os.remove(fp.name)
1126140
def _maketemp(name, createmode=None):
    
    d, fn = os.path.split(name)
    fd, tempname = tempfile.mkstemp(prefix=".%s-" % fn, dir=d)
    os.close(fd)

    # Temporary files are created with mode 0600, which is usually not
    # what we want. If the original file already exists, just copy its mode.
    # Otherwise, manually obey umask.
    try:
        st_mode = os.lstat(name).st_mode & 0o777
    except OSError as err:
        if err.errno != errno.ENOENT:
            raise
        st_mode = createmode
        if st_mode is None:
            st_mode = ~umask
        st_mode &= 0o666
    os.chmod(tempname, st_mode)

    return tempname
806866
def _get_file(self):
        '''
        
        '''
        f = tempfile.NamedTemporaryFile(delete=False)
        self.tmp_files.add(f.name)
        return f
813967
public function tempnam(): string
    {
        $root = $this->getFsRoot();
        do {
            ++$this->fsCounter;
            $name = $root.'/'.$this->fsCounter;
        } while (file_exists($name));

        return $name;
    }