def create_cmd(args, basename_binary=False):
 if basename_binary:
  args[0] = os.path.basename(args[0])
 if (os.name == 'nt'):
  return subprocess.list2cmdline(args)
 else:
  escaped_args = []
  for arg in args:
   if (re.search('^[a-zA-Z0-9/_^\\-\\.:=]+$', arg) is None):
    arg = ((u"'" + arg.replace(u"'", u"'\\''")) + u"'")
   escaped_args.append(arg)
  return u' '.join(escaped_args)

def create_cmd ( args , basename_binary = False ) : if basename_binary : args [ 0 ] = os . path . basename ( args [ 0 ] ) if ( os . name == 'nt' ) : return subprocess . list2cmdline ( args ) else : escaped_args = [ ] for arg in args : if ( re . search ( '^[a-zA-Z0-9/_^\\-\\.:=]+$' , arg ) is None ) : arg = ( ( u"'" + arg . replace ( u"'" , u"'\\''" ) ) + u"'" ) escaped_args . append ( arg ) return u' ' . join ( escaped_args )
takes an array of strings to be passed to subprocess .