def generate_tmp_file_name(file_name, ext=None, directory='/tmp/'):
 while True:
  file_name = (((file_name + '-') + time.strftime('%Y%m%d-%H%M%S-')) + generate_random_string(4))
  if ext:
   file_name += ('.' + ext)
  file_name = os.path.join(directory, file_name)
  if (not os.path.exists(file_name)):
   break
 return file_name

def generate_tmp_file_name ( file_name , ext = None , directory = '/tmp/' ) : while True : file_name = ( ( ( file_name + '-' ) + time . strftime ( '%Y%m%d-%H%M%S-' ) ) + generate_random_string ( 4 ) ) if ext : file_name += ( '.' + ext ) file_name = os . path . join ( directory , file_name ) if ( not os . path . exists ( file_name ) ) : break return file_name
returns a temporary file name .