Esempio n. 1
0
def get_parameter():
    result = []
    _, args = getopt(sys.argv[0:2], "")
    opts, _ = getopt(sys.argv[2:], "t:s:")
    result.append(args[1])
    for i in opts:
        result.append(i[1])
    return result
def main():
    start_time = time()
    options, args = getopt(sys.argv[1:], "i:s:m:b:t:r:", [])
    for syntax, value in options:
        if syntax in "-i":
            network_path = value
        if syntax in "-s":
            seed_path = value
        if syntax in "-m":
            diff_model = value
        if syntax in "-b":
            ter_type = int(value)
        if syntax in "-t":
            ter_time = int(value)
        if syntax in "-r":
            ran_seed = int(value)
    seed(ran_seed)
    vertex_num, edge_num, graph_numpy = network_reader(network_path)
    seeds = seed_reader(seed_path)
    graph_class = Graph(graph_numpy, vertex_num)
    if ter_type == 0:
        ter_time = 10000
    sum, iter = 0, 0
    for i in range(0, 10000):
        if diff_model == "IC":
            count = ic_model(graph_class, seeds)
        else:
            count = lt_model(graph_class, seeds)
        sum = count + sum
        iter += 1
        if ter_time - 3 < time() - start_time:
            break
    print sum / iter
    print time() - start_time
Esempio n. 3
0
def main():
    ops, args = getopt(sys.argv[1:], "hi:o:f:t:")
    # for op,value in ops:
    if ops.has_key("-h"):
        print("""Usage
            -h details for options
            -i input file
            -o output file.if none,then will use input file
            -f input file fold,if this,all files in this fold will be as input file
            -t change time(millisecond),positive or negative
            """)
    else:
        if ops.has_key("-t"):
            millisecond = int(ops.get("-t", default=0))
            if ops.has_key("-f"):
                file_dir = ops.get("-f")
                for fn in os.listdir(file_dir):
                    modify_time_axis(fn, millisecond=millisecond)
            else:
                src = ops.get("-i")
                if ops.has_key("-o"):
                    dest = ops.get("-o")
                    modify_time_axis(src, dest, millisecond)
                else:
                    modify_time_axis(src, millisecond=millisecond)
        else:
            print("""unknow command
            to see more details please using <-h>
            """)
Esempio n. 4
0
def main():
    global start_time, ter_time
    start_time = time()
    options, args = getopt(sys.argv[1:], "i:k:m:b:t:r:", [])
    for syntax, value in options:
        if syntax in "-i":
            network_path = value
        if syntax in "-k":
            seed_size = int(value)
        if syntax in "-m":
            diff_model = value
        if syntax in "-b":
            ter_type = int(value)
        if syntax in "-t":
            ter_time = int(value)
        if syntax in "-r":
            ran_seed = int(value)
    if ter_type == 0:
        ter_time = 10000
    seed(ran_seed)
    # network_path = "network.txt"
    # seed_size = 4
    # diff_model = "IC"
    vertex_num, edge_num, graph_numpy = network_reader(network_path)
    graph_class = Graph(graph_numpy, vertex_num)
    tar = degree_dis(graph_class, min(8 * seed_size, vertex_num))
    seeds = celf_improved(tar, graph_class, seed_size, diff_model)
    for i in seeds:
        print i
def parse_args():
    global workbookname, compiler_version, input_file, input_opt, os_name, linkage, compiler_name, arch_name

    short_opts = "f:v:i:o:O:l:c:a:"
    long_opts = [
        "output-file=", "compiler-version=", "input-file=", "optlevel=", "os=",
        "linkage=", "compiler=", "arch="
    ]

    try:
        opts, args = getopt(sys.argv[1:], short_opts, long_opts)
    except GetoptError:
        print("ERROR parsing options")
        sys.exit(-1)

    for opt, arg in opts:
        if opt == "-f" or opt == "--output-file":
            workbookname = arg
        elif opt == "-v" or opt == "--compiler-version":
            compiler_version = arg
        elif opt == "-i" or opt == "--input-file":
            input_file = arg
        elif opt == "-o" or opt == "--optlevel":
            input_opt = arg
        elif opt == "-O" or opt == "--os":
            os_name = arg
        elif opt == "-l" or opt == "--linkage":
            linkage = arg
        elif opt == "-c" or opt == "--compiler":
            compiler_name = arg
        elif opt == '-a' or opt == "--arch":
            arch_name = arg
        else:
            print("unknown option", opt)
            sys.exit(-1)

    if os_name not in os_names:
        print("invalid os name given, please use 'linux' or 'android'")
        sys.exit(-1)

    if arch_name not in arch_names:
        print(
            "invalid architecture given, please use 'arm', 'thumb' or 'i486'")
        sys.exit(-1)

    if linkage not in linkage_names:
        print("invalid linkage given, please use 'static', 'dynamic' or 'pie'")
        sys.exit(-1)

    if compiler_name not in compiler_names:
        print("invalid compiler given, please use 'gcc' or 'llvm'")
        sys.exit(-1)

    if compiler_name == 'llvm' and (compiler_version not in llvm_versions):
        print(
            "invalid version given for LLVM, please use '3.2', '3.3' or '3.4'")
        sys.exit(-1)
    elif compiler_name == 'gcc' and (compiler_version not in gcc_versions):
        print("invalid version given for GCC, please use '4.6.4' or '4.8.1'")
        sys.exit(-1)
Esempio n. 6
0
 def __parseArgs(self):
     short, long = self.getAvailableOptions()
     long.append("help")
     try:
         opts, args = getopt(sys.argv[1:], "h" + short, long)
     except GetoptError, e:
         return
def main(argv):
    try: 
        opts, args = getopt(argv, 'f')
    except GetoptError as err:
        print str(err)
        sys.exit(2)

    print opts
    Pyvader(opts).main_loop()
Esempio n. 8
0
def main():
	global progname 

	progname = sys.argv[0]

	try:
		opts, args = getopt(sys.argv[1:], "ho:", \
							["help", "output="])
	except GetoptError, err:
		error(str(err))
Esempio n. 9
0
def main():
    global progname

    progname = sys.argv[0]

    try:
        opts, args = getopt(sys.argv[1:], "ho:", \
             ["help", "output="])
    except GetoptError, err:
        error(str(err))
Esempio n. 10
0
def read_cmd():
    try:
        opts, agrs = getopt(sys.argv[0:], 'i:s:m:t')
    except:
        print("wrong in read cmd")
        sys.exit(2)
    graph_path = agrs[2]
    seed_path = agrs[4]
    model = agrs[6]
    time = int(agrs[8])
    return graph_path, seed_path, model, time
Esempio n. 11
0
def read_cmd():
    try:
        opts, agrs = getopt(sys.argv[0:], ' : :t')
    except:
        print("wrong in read cmd")
        sys.exit(2)
    # print(agrs)
    train = agrs[1]
    test = agrs[2]
    time_limit = float(agrs[4])
    return train, test, time_limit
Esempio n. 12
0
	def parse_opts (self, cmdline, short="", long=[]):
		try:
			opts, args = getopt(
				cmdline, "I:bc:de:fhklm:n:o:pqr:SsvW:z" + short,
				["bzip2", "cache", "clean", "command=", "epilogue=", "force", "gzip",
				 "help", "inplace", "into=", "jobname=", "keep", "landcape", "maxerr=",
				 "module=", "only=", "post=", "pdf", "ps", "quiet", "read=",
				 "src-sepcials", "short", "texpath=", "verbose", "version", "warn="] + long)
		except GetoptError, e:
			print e
			sys.exit(1)
Esempio n. 13
0
def main(argv=None):
	if argv is None:
		argv = sys.argv
	try:
		try:
			opts, args = getopt(argv[1:], "h", ["help"])
		except getopt.error, msg:
			raise Usage(msg)
	except Usage, err:
		print(err.msg, file=sys.stderr)
		print("for help use --help", file=sys.stderr)
		return 2
Esempio n. 14
0
def main():
	global listen
	global port
	global execute
	global command
	global upload_destination
	global target

	if not len(sys.argv[1:]):
		usage()

	# read the command line options
	try:
		opts, args = getopt(sys.argv[1:], "hle:t:p:cu:", ["help", "listen", "execute", "target", "port", "command", "upload"])
	except getopt.GetoptError as err:
		print str(err)
		usage()

	for o,a in opts:
		if o in ("-h", "--help"):
			usage()
		elif o in ("-l", "--listen"):
			listen = True
		elif o in ("-e", "--execute"):
			execute = a
		elif o in ("-c", "--command"):
			command = True
		elif o in ("-u", "--upload"):
			upload_destination = a
		elif o in ("-t", "--target"):
			target = a
		elif o in ("-p", "--port"):
			port = int(a)
		else:
			assert False,"Unhandled Exception"


	# are we going to listen or just send data from stdin?
	if not listen and len(target) and port > 0:

		# read in the buffer from the commandline
		# this will block, so send CTRL-D if not sending input
		# to stdin
		buffer = sys.stdin.read()

		# send data off
		client_sender(buffer)

	# we are going to listen and potentially 
	# upload things, execute commands, and drop a shell back
	# depending on our command line options above
	if listen:
		server_loop()
Esempio n. 15
0
 def parseOptions(self):
     try:
         opts, self.args = getopt(argv[1:], self.options, self.longOptions )
     except:
         self.usage(2)
     
     if not self.args:
         self.args = ['.']
     
     for o, v in opts:
         if o in ('-v', '--verbose'):
             self.verbose = True
         elif o in ('-h', '--help'):
             self.usage(0)
         elif o in ('-E', '--avm'):
             self.avm = v
         elif o in ('-a', '--asc'):
             self.asc = v
         elif o in ('-g', '--globalabc'):
             self.builtinabc = v
         elif o in ('-b', '--builtinabc'):
             self.builtinabc = v
         elif o in ('-s', '--shellabc'):
             self.shellabc = v
         elif o in ('-x', '--exclude'):
             self.exclude += v.split(',')
         elif o in ('-t', '--notime'):
             self.timestamps = False
         elif o in ('-f', '--forcerebuild'):
             self.forcerebuild = True
         elif o in ('-c', '--config'):
             self.config = v
         elif o in ('-e', '--eval'):
             self.eval = True
         elif o in ('--ascargs',):
             self.ascargs = v
         elif o in ('--vmargs',):
             self.vmargs = v
         elif o in ('--ext',):
             self.sourceExt = v
         elif o in ('--timeout',):
             self.self.testTimeOut=int(v)
         elif o in ('-d',):
             self.debug = True
         elif o in ('--rebuildtests',):
             self.rebuildtests = True
         elif o in ('-q', '--quiet'):
             self.quiet = True
         elif o in ('--nohtml',):
             self.htmlOutput = False
     return opts
Esempio n. 16
0
def getArgs(argv):
 
  try:
    opts, args = getopt(argv[1:],'i:l:')
  except GetoptError:
    print 'undo_bondswap.py -i <filename> -l <chainLength>'
    exit(2)
  for opt, arg in opts:
    if opt == '-i':
      inFile = arg
    elif opt == '-l':
      chainLength = arg
 
  return inFile, int(chainLength)
Esempio n. 17
0
File: IMP.py Progetto: Voldet/AI-Lab
def sys_reader():
    options, args = getopt(sys.argv[1:], "i:k:m:t:", [])
    network_path, diff_model = "", ""
    seed_size, termination = 0, 0
    for syntax, value in options:
        if syntax in "-i":
            network_path = value
        if syntax in "-k":
            seed_size = int(value)
        if syntax in "-m":
            diff_model = value
        if syntax in "-t":
            termination = int(value)
    return network_path, seed_size, diff_model, termination
Esempio n. 18
0
 def parse_opts(self, cmdline, short="", long=[]):
     try:
         opts, args = getopt(
             cmdline, "I:bc:de:fhklm:n:o:pqr:SsvW:z" + short, [
                 "bzip2", "cache", "clean", "command=", "epilogue=",
                 "force", "gzip", "help", "inplace", "into=", "jobname=",
                 "keep", "landcape", "maxerr=", "module=", "only=", "post=",
                 "pdf", "ps", "quiet", "read=", "src-sepcials",
                 "shell-escape", "short", "texpath=", "verbose", "version",
                 "warn="
             ] + long)
     except GetoptError, e:
         print e
         sys.exit(1)
Esempio n. 19
0
def getoptTest(dict):
	try:
		opts,argsTmp=getopt(dict[1:],'s:m:')
		for o,a in opts:
			if o in ("-s"):
				sub = a
				print sub 
			if o in ("-m"):
				msg = a
				print msg

	except getopt.GetoptError:
		print("getopt error")
		sys.exit(1)
Esempio n. 20
0
def getArgs(argv):

  try:
    opts, args = getopt(argv[1:],'i:o:')
  except GetoptError:
    print 'randomWalk.py -i <filename> -o <filename>'
    exit(2)
  for opt, arg in opts:
    if opt == '-i':
      inFile = arg
    elif opt == '-o':
      outFile = arg
 
  return inFile, outFile
Esempio n. 21
0
def getArgs(argv):
  
  try:
    opts, args = getopt(argv[1:],'f:n:')
  except GetoptError:
    print 'randomWalk.py -f <filename> -n <nFrames>'
    exit(2)
  for opt, arg in opts:
    if opt == '-f':
      trajFile = arg
    if opt == '-n':
      nFrames = arg

  return trajFile, int(nFrames)
Esempio n. 22
0
def getArgs(argv):
  
  try:
    opts, args = getopt(argv[1:],'t:o:n:')
  except GetoptError:
    print 'calcInterface.py -t <filename> -o <filename> -n <nSteps>'
    exit(2)
  for opt, arg in opts:
    if opt == '-t':
      trajFile = arg
    elif opt == '-o':
      confFile = arg
    elif opt == '-n':
      nSteps = arg

  return trajFile, confFile, int(nSteps)
Esempio n. 23
0
def getArgs(argv):
  
  try:
    opts, args = getopt(argv[1:],'t:o:n:')
  except GetoptError:
    print 'randomWalk.py -t <filename>'
    exit(2)
  for opt, arg in opts:
    if opt == '-t':
      trajFile = arg
    if opt == '-o':
      outFile = arg
    if opt == '-n':
      nFrames = arg

  return trajFile, outFile, int(nFrames)
Esempio n. 24
0
def getArgs(argv):

  try:
    opts, args = getopt(argv[1:],'p:s:o:')
  except GetoptError:
    print 'randomWalk.py -p <prefix file> -s <suffix file> -o <filename>'
    exit(2)
  for opt, arg in opts:
    if opt == '-p':
      prefixFile = arg
    if opt == '-s':
      suffixFile = arg
    elif opt == '-o':
      outFile = arg
 
  return prefixFile, suffixFile, outFile
Esempio n. 25
0
def getArgs(argv):

  try:
    opts, args = getopt(argv[1:],'i:o:n:')
  except GetoptError:
    print 'randomWalk.py -i <xyz file> -o <filename> -n <nFrames>'
    exit(2)
  for opt, arg in opts:
    if opt == '-i':
      inFile = arg
    elif opt == '-o':
      outFile = arg
    elif opt == '-n':
      nSteps = arg
 
  return inFile, outFile, int(nSteps)
Esempio n. 26
0
def getArgs(argv):

    try:
        opts, args = getopt(argv[1:], "t:o:n:")
    except GetoptError:
        print """randomWalk.py -t <filename> -o <filename> -n <steps> """
        exit(2)
    for opt, arg in opts:
        if opt == "-t":
            trajFile = arg
        elif opt == "-o":
            outFile = arg
        elif opt == "-n":
            steps = arg

    return trajFile, outFile, int(steps)
Esempio n. 27
0
def getArgs(argv):

    try:
        opts, args = getopt(argv[1:], "t:o:n:")
    except GetoptError:
        print "calcInterface.py -t <filename> -o <filename> -n <nSteps>"
        exit(2)
    for opt, arg in opts:
        if opt == "-t":
            trajFile = arg
        elif opt == "-o":
            confFile = arg
        elif opt == "-n":
            nSteps = arg

    return trajFile, confFile, int(nSteps)
Esempio n. 28
0
def sys_reader():
    options, args = getopt(sys.argv[1:], "i:s:m:t:", [])
    network_path, seed_path, diffusion_model = "", "", ""
    termination = 0
    for syntax, value in options:
        # absolute path of the social network file
        if syntax in "-i":
            network_path = value
        # absolute path of the seed set file
        if syntax in "-s":
            seed_path = value
        # IC / LT
        if syntax in "-m":
            diffusion_model = value
        # time limitation
        if syntax in "-t":
            termination = int(value)
    return network_path, seed_path, diffusion_model, termination
Esempio n. 29
0
def main():
    global listen
    global port
    global execute
    global command
    global upload_destination
    global target
    
    if not len(sys.argv[1:]):
        usage()
    
    #Read command line arguments
    
    try:
        opts,args = getopt(sys.argv[1:],"hle:t:p:cu",["help","listen","execute","target","port","port","command","upload"])
    except getopt.GetoptError as err:
        print str(err)
        usage()
Esempio n. 30
0
def getParameter(argv, params):
    if (len(argv)<2):
        return False
    params['year'] = int(argv[0])
    params['month'] = int(argv[1])
    if params['month'] <1 or params['month']>12:
        print('Error:month should between 1 and 12')
        return False
    try:
        opts, args = getopt(argv[2:], "p:")
    except GetoptError:
        return False
    
    for opt, arg in opts:
        if (opt == '-p'):
            params['dataDir'] = arg
        
    return True
Esempio n. 31
0
def main(argv=None):
    try:
        opts, args = getopt(argv, "f:d:")
    except getopt.GetoptError:
        usage()
        sys.exit(2)

    default_fnlabel = None
    default_duration = None

    for o, a in opts:
        if o == '-f':
            default_fnlabel = a
        elif o == '-d':
            default_duration = a

    if default_fnlabel is None:
        sys.exit(2)
    elif default_duration is None:
        sys.exit(2)

    default_timestamp = timestamp()
    default_ofname = "{}_{}".format(default_timestamp, default_fnlabel)

    ecarec = EcaRec()
    ecarec.createChanset()
    ecarec.setDuration(default_duration)
    ecarec.setOutFile(default_ofname)

    ecarec.ichanAdd([1, 2, 3, 4])
    ecarec.ochanAdd([1, 2, 3, 4])

    ecarec.startRec()

    while 1:
        if ecarec.engineStatus() == "running":
            break

    while ecarec.isRunning():
        time.sleep(2)

    ecarec.stopRec()

    ecarec.disconnect()
Esempio n. 32
0
def main():
    global username
    global host
    global port
    global password
    global proto

    try:
        opts, args = getopt(sys.argv[1:], "u:p:Svh",
                            ["userpass="******"port=", "SSL", "version", "help"])
    except GetoptError as e:
        showUsage()
        sys.exit(2)

    for o, a in opts:
        if o in ("-v", "--version"):
            # show version and exit
            showVersion()
        elif o in ("-h", "--help"):
            # show usage and exit
            showUsage()

        if o in ("-u", "--userpass"):
            (username, password) = split(':', a, 2)
            if not username or not password:
                sys.exit(2)

        if o in ("-S", "--SSL"):
            proto = "ftps"

        if o in ("-p", "--port"):
            if a > 0 and a < 65536:
                port = a
            else:
                print "Invalid port specified."
                sys.exit(2)

    if proto == "ftp":
        print connectFTP(host, username, password, port)
    elif proto == "ftps":
        print connectFTPS(host, username, password, port)
    else:
        print "oops! invalid protocol specified"
        sys.exit(2)
Esempio n. 33
0
def main():
    """
    This is the routine that gets called if MakefileVariable.py is invoked from
    the shell.  Process any command-line options that may be given, take the
    first argument as a filename, process it to obtain a dictionary of variable
    name/value pairs, and output the results.
    """
    # Initialization
    (progDir,progName) = os.path.split(sys.argv[0])
    options      = "hmpv"
    long_options = ["help", "make", "python", "version"]
    outStyle     = "python"

    # Get the options and arguemnts from the command line
    (opts,args) = getopt(sys.argv[1:], options, long_options)

    # Loop over options and implement
    for flag in opts:
        if flag[0] in ("-h","--help"):
            print __doc__
            sys.exit()
        elif flag[0] in ("-m", "--make"):
            outStyle = "make"
        elif flag[0] in ("-p", "--python"):
            outStyle = "python"
        elif flag[0] in ("-v", "--version"):
            print progName, __version__, __date__
            sys.exit()
        else:
            print "Unrecognized flag:", flag[0]
            print __doc__
            sys.exit()

    # Process the filename
    dict = processMakefile(args[0])

    # Output the variable names and values
    if outStyle == "make":
        keys = dict.keys()
        keys.sort()
        for key in keys:
            print key, "=", dict[key]
    elif outStyle == "python":
        print dict
def getArgs(argv, flags, types):

  flagArr = flags.split(':')
  flagArr = ''.join(flagArr)
  try:
    opts, _ = getopt(argv[1:], flags)
  except GetoptError:
    print 'randomWalk.py %s <xyz file> %s <filename> %s <nFrames>' % tuple(flagArr)
    exit(2)
  for opt, arg in opts:
    if opt == '-' + flagArr[0]:
      inFile = arg
    elif opt == '-' + flagArr[1]:
      outFile = arg
    elif opt == '-' + flagArr[2]:
      nSteps = arg
 
  # return an array or tuple of the arguments instead and perform the unpacking
  return inFile, outFile, int(nSteps)
Esempio n. 35
0
def getArgs(argv):

  try:
    opts, args = getopt(argv[1:],'i:o:l:r:z:')
  except GetoptError:
    print 'randomWalk.py -i <file> -o <file> -l <chainLength> -r <radius> -z <z-origin>'
    exit(2)
  for opt, arg in opts:
    if opt == '-i':
      inFile = arg
    elif opt == '-o':
      outFile = arg
    elif opt == '-l':
      chainLength = arg
    elif opt == '-r':
      radius = arg
    if opt == '-z':
      origin = arg
 
  return inFile, outFile, int(chainLength), float(radius), float(origin)
Esempio n. 36
0
def getArgs(argv):
  
  try:
    opts, args = getopt(argv[1:],'t:o:n:i:s:')
  except GetoptError:
    print 'randomWalk.py -t <filename> -o <filename> -n <steps> -i <nInsert> -s <nSlices>'
    exit(2)
  for opt, arg in opts:
    if opt == '-t':
      trajFile = arg
    elif opt == '-o':
      outFile = arg
    elif opt == '-n':
      steps = arg
    elif opt == '-i':
      insertions = arg
    elif opt == '-s':
      slices = arg

  return trajFile, outFile, int(steps), int(insertions), int(slices)
Esempio n. 37
0
def get_arguments():

    try:
        #option map
        options = getopt(sys.argv[1:],
                         shortopts="p:t:h",
                         longopts=["path=", "time=", "help"])
    except GetoptError as e:
        print("ERROR, wrong option used: ", e)
        sys.exit(usage_collecter_usage())

    path = DEFAULT_CSV_PATH
    time = DEFAULT_TIME

    for (opts, args) in options[0]:

        # Help options
        if opts == "-h":
            sys.exit(usage_collecter_usage())
        elif opts == "--help":
            sys.exit(usage_collecter_usage())

        # Path Options
        if opts == '-p':
            path = args
        elif opts == '--path':
            path = args

        # Time Options
        try:

            if opts == "-t":
                time = int(args)
            elif opts == "--time":
                time = int(args)

        except ValueError as e:
            print("ERROR, wrong value used MUST BE AN INT: ", e)
            sys.exit(usage_collecter_usage())

    return path, time
Esempio n. 38
0
def main():
    global listen
    global port
    global execute
    global command
    global upload_destination
    global target

    if not len(sys.argv[1:]):
        usage()
    
    #read the command line options
    try:
        opts, args = getopt(sys.argv[1:],"hle:t:p:cu:",["help","listen","execute","target","port","command","uplaod"])
    
    except getopt.GetoptError as err:
        print str(err)
        usage()
    
    for o,a in opts:
        if o in ("-h", "--help"):
            usage()
        elif o in ("-l", "--listen"):
            listen = True
        elif o in ("-e", "--execute"):
            execute = a
        elif o in ("-c", "--command"):
            command = True
        elif o in ("-u", "--upload"):
            upload_destination = a
        elif o in ("-t", "--target")
            target = a
        elif o in ("-o", "--port")
            port = int(a)
        else:
            assert False, "Unhandeled Option"
    if not listen and len(target) and port  > 0:
        buffer = sys.stdin.read()
        client_sender(buffer)
    if listen:
        server_loop()
Esempio n. 39
0
def getArgs(argv):
  
  # defaults
  trajFile = 'Ellipsoids/613766.ocoee.nics.utk.edu/N_5_undersat_traj.xyz'
  outFile = ''
  steps = 0

  try:
    opts, args = getopt(argv[1:],'t:o:n:')
  except GetoptError:
    print 'randomWalk.py -t <filename> -o <filename> -n <steps>'
    exit(2)
  for opt, arg in opts:
    if opt == '-t':
      trajFile = arg
    elif opt == '-o':
      outFile = arg
    elif opt == '-n':
      steps = arg

  return trajFile, outFile, int(steps)
Esempio n. 40
0
def main(argv):
    try:
        opts, args = getopt(argv, "h", ["help"])
    except GetoptError:
        usage()
        sys.exit(1)

    for opt, arg in opts:
        if opt in ("-h", "--help"):
            usage()
            sys.exit()

    for arg in args:
        try:
            with open(arg, 'r') as f:
                readin = f.read()
                tree = parser(readin)
                semantics(tree)

        except IOError:
            print "File %s not found!" % arg
            sys.exit(1)
Esempio n. 41
0
    def parse_opts(self, cmdline):
        try:
            long = [
                "module=", "readopts=", "short", "verbose", "boxes", "check",
                "deps", "errors", "help", "refs", "rules", "version",
                "warnings"
            ]
            args = rubber.cmdline.Main.parse_opts(self, cmdline, long=long)
            opts, args = getopt(args, "", long)
            self.max_errors = -1
        except GetoptError as e:
            msg.error(e)
            sys.exit(1)

        for (opt, arg) in opts:
            if opt in ("-h", "--help"):
                self.help()
                sys.exit(0)
            elif opt in ("-m", "--module"):
                self.modules.append(arg)
            elif opt in ("-o", "--readopts"):
                file = open(arg)
                opts2 = file.read().split()
                file.close()
                args = self.parse_opts(opts2) + args
            elif opt in ("-s", "--short"):
                msg.short = 1
            elif opt in ("-v", "--verbose"):
                msg.level = msg.level + 1
            elif opt == "--version":
                msg(0, version)
                sys.exit(0)
            else:
                if self.act:
                    sys.stderr.write(_("You must specify only one action.\n"))
                    sys.exit(1)
                self.act = opt[2:]
        return args
Esempio n. 42
0
def optget():
    global mode_B
    global mode_C
    global mode_L
    global mode_M
    global mode_CH
    global mode_W
    global filename    
    global byte
    
    if len(argv) < 2:
        usage()
        
    try:
        opts, args = getopt(argv[1:], "cmlwh:LC", ["bytes", "chars", "lines", "words", "help", "max-line-length", "chinese-chars"])
        filename = args[0]
        byte = size(filename)         
    except GetoptError as err:
        print str(err)
        usage()
    
    for o, a in opts:
        if o in ("-h", "--help"):
            usage()
        elif o in ("-c", "--bytes"):
            mode_B = True
        elif o in ("-m", "--chars"):
            mode_C = True 
        elif o in ("-l", "--lines"):
            mode_L = True
        elif o in ("-w", "--words"):
            mode_W = True
        elif o in ("-C", "--chinese-chars"):
            mode_CH = True
        elif o in ("-L", "--max-line-length"):
            mode_M = True
        else:
            assert False, "Unhandled Option"
Esempio n. 43
0
def main():
    global flag
    global mode_G
    global mode_I

    try:
        opts, args = getopt(sys.argv[1:], "gih",
                            ["graph", "interactive", "help"])
    except GetoptError as err:
        print str(err)
        usage()

    if len(sys.argv) < 2:
        usage()

    for o, a in opts:
        if o in ("-h", "--help"):
            usage()
        if o in ("-g", "--graph"):
            mode_G = 1
        if o in ("-i", "interactive"):
            mode_I = 1
    try:
        s = bin(int(args[-1]))[2:]
    except ValueError:
        print fc.ERROR + "[!] " + fc.ENDC + "ValueError: ",
        print "Please input a decimal integer."
        usage()
    except IndexError:
        pass
    if mode_G and not mode_I:
        graph(s)
    elif mode_I:
        interactive()
    else:
        print s
        print
Esempio n. 44
0
def main(argv):
  try:
    opts, args = getopt(argv, "h", ["help"])
  except GetoptError:
    usage()
    sys.exit(1)

  for opt, arg in opts:
    if opt in ("-h", "--help"):
      usage()
      sys.exit()

  
  for arg in args:
    try:
      with open(arg, 'r') as f:
        readin = f.read()
        tree = parser(readin)
        semantics(tree)


    except IOError:
      print "File %s not found!" % arg
      sys.exit(1)
def main():
    global start
    start = time()
    file_name = sys.argv[1]
    options, args = getopt(sys.argv[2:], "t:s:", [])
    global ter_time
    for name, value in options:
        if name in "-t":
            ter_time = int(value)
        if name in "-s":
            ran_seed = int(value)
    manager = multiprocessing.Manager()
    return_dict = manager.dict()
    result = []
    for i in range(8):
        temp_proc = multiprocessing.Process(target=solver, args=(file_name, return_dict))
        result.append(temp_proc)
        temp_proc.start()
    for temp_proc in result:
        temp_proc.join()
    k = sorted(return_dict.items())[0][0]
    res_s = ','.join(str(x) for x in return_dict[k])
    print 's', res_s.replace(' ', '')
    print 'q', int(k)
Esempio n. 46
0
	def parse_opts (self, cmdline):
		try:
			long =  [ "module=", "readopts=", "short", "verbose", "boxes",
				"check", "deps", "errors", "help", "refs", "rules", "version",
				"warnings" ]
			args = rubber.cmdline.Main.parse_opts(self, cmdline, long=long)
			opts, args = getopt(args, "", long)
			self.max_errors = -1
		except GetoptError as e:
			msg.error(e)
			sys.exit(1)

		for (opt,arg) in opts:
			if opt in ("-h", "--help"):
				self.help()
				sys.exit(0)
			elif opt in ("-m", "--module"):
				self.modules.append(arg)
			elif opt in ("-o" ,"--readopts"):
				file = open(arg)
				opts2 = file.read().split()
				file.close()
				args = self.parse_opts(opts2) + args
			elif opt in ("-s", "--short"):
				msg.short = 1
			elif opt in ("-v", "--verbose"):
				msg.level = msg.level + 1
			elif opt == "--version":
				msg(0, version)
				sys.exit(0)
			else:
				if self.act:
					sys.stderr.write(_("You must specify only one action.\n"))
					sys.exit(1)
				self.act = opt[2:]
		return args
Esempio n. 47
0
File: ftqviz.py Progetto: 1587/ltp
    legend(['interpolated', 'smoothed'])
    title("FFT")
    xlabel("Frequency")
    ylabel("Amplitude")

    show()


def usage():
        print "usage: "+argv[0]+" -t times-file -c counts-file [-s SAMPLING_HZ] [-w WINDOW_LEN] [-h]"


if __name__=='__main__':

    try:
        opts, args = getopt(argv[1:], "c:hs:t:w:")
    except GetoptError:
        usage()
        exit(2)

    sample_hz = 10000
    wlen = 25
    times_file = None
    counts_file = None
    for o, a in opts:
        if o == "-c":
            counts_file = a
        if o == "-h":
            usage()
            exit()
        if o == "-s":
Esempio n. 48
0
  --handicap <amount>
  --size <board size>               (default 19)
  --games <number of games to play> (default 1)
  --sgffile <filename>              (create sgf files with sgfbase as basename)
"""

    def usage():
        print helpstring
        sys.exit(1)

    (opts, params) = getopt(sys.argv[1:], "", [
        "black=",
        "white=",
        "verbose=",
        "komi=",
        "boardsize=",
        "size=",
        "handicap=",
        "games=",
        "sgffile=",
    ])

    for opt, value in opts:
        if opt == "--black":
            black = value
        elif opt == "--white":
            white = value
        elif opt == "--verbose":
            verbose = int(value)
        elif opt == "--komi":
            komi = value
Esempio n. 49
0
#
# $Id: list.py,v 1.2 2004-05-31 18:30:15 jsommers Exp $
#

import sys, xmlrpclib
from getopt import *


def usage(proggie):
    print "usage: ", proggie, "[-u <url>]*"
    exit


try:
    opts, args = getopt(sys.argv[1:], "u:", [])
except GetoptError, e:
    print "exception while processing options: ", e
    usage(sys.argv[0])

url_list = []
for o, a in opts:
    if o == "-u":
        url_list.append(a)

for server_url in url_list:
    server = xmlrpclib.ServerProxy(server_url)
    print "listing methods offered by ", server
    try:
        result = server.system.listMethods()
        print "result: ", result
Esempio n. 50
0
"""


def usage():
    print helpstring
    sys.exit(1)


try:
    (opts, params) = getopt(sys.argv[1:], "", [
        "black=",
        "white=",
        "verbose=",
        "komi=",
        "boardsize=",
        "size=",
        "handicap=",
        "free-handicap=",
        "adjust-handicap=",
        "games=",
        "sgfbase=",
        "endgame=",
    ])
except:
    usage()

for opt, value in opts:
    if opt == "--black":
        black = value
    elif opt == "--white":
        white = value
    elif opt == "--verbose":
Esempio n. 51
0
  --endgame <moves before end>      (endgame contest - add filenames of
                                     games to be replayed after last option)
"""

def usage():
    print helpstring
    sys.exit(1)

try:
    (opts, params) = getopt(sys.argv[1:], "",
                            ["black=",
                             "white=",
                             "verbose=",
                             "komi=",
                             "boardsize=",
                             "size=",
                             "handicap=",
                             "free-handicap=",
                             "adjust-handicap=",
                             "games=",
                             "sgfbase=",
                             "endgame=",
                            ])
except:
    usage();

for opt, value in opts:
    if opt == "--black":
        black = value
    elif opt == "--white":
        white = value
    elif opt == "--verbose":
Esempio n. 52
0
#!/usr/bin/env python
# Copyright 2016 LinkedIn Corp. Licensed under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with the
# License.
#
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
"""
Usage: ptyhooks [-c CONFIG_MODULE] [-h] [--help] [COMMAND [ARGUMENTS...]]

Execute Python functions in response to output generated by a subprocess. When
no subprocess COMMAND is specified, PTYHooks will attempt to launch the
application defined by the SHELL environment variable and defaults to executing
"/bin/sh" when that is unset.

Argument parsing is handled using traditional getopt(3) instead of GNU
getopt(3). If PTYHooks used GNU getopt(3), "ptyhooks bash -l" would not work
because PTYHooks would try to parse "-l" as though it were intended for itself
instead of Bash.

Options:
 -c CONFIG_MODULE   Load specified file as the configuration module. When
                    unspecified, PTYHooks will try to use "$HOME/.ptyhooks.py"
                    as the configuration module.
 -h, --help         Show this text and exit.
"""
from __future__ import print_function
Esempio n. 53
0
		of feedback for debugging.
		
		
"""

import string
import sys

import re

stack = []
_port = 9000
_dns = "::gnumed"

from getopt import *
optlist, remaining_args = getopt(sys.argv[1:], "hp:c:")
for (opt, value) in optlist:
    sys.stderr.write("option %s=%s\n" % (opt, value))
    if opt == '-h':
        print """
	USAGE:
		python analyse_sql3.py  -p port -c connect_string  filename  > server.py    

		where 
			port : the port number for the xmlrpc server (default is 9000)
			
			connect_string: the string used for database connection (default '::gnumed')
			
			filename :  the sql file or path to file: e.g ../sql/gmclinical.sql

		output is to stdout so in the above example
Esempio n. 54
0
def usage(c):
    print "usage: %s [options] [file to parse]" % basename(argv[0])
    print " -v --verbose       enable additional output"
    print " -c --config        testconfig.txt file to load"
    print " -h --help          display help and exit"
    print " -o --output		   html output file"
    print " -x --nohtml		   don't output html"
    print " --tc [filename]    output a testconfig.txt file containing all failures"
    exit(c)


if __name__ == "__main__":
    try:
        opts, args = getopt(
            argv[1:], "vhc:o:x",
            ["verbose", "help", "config=", "output", "nohtml", "tc="])
    except:
        usage(2)

    if not args:
        args = ["../spidermonkey-test.log"]
    for o, v in opts:
        if o in ("-v", "--verbose"):
            verbose = True
        elif o in ("-h", "--help"):
            usage(0)
        elif o in ("-x", "--nohtml"):
            js_output = False
        elif o in ("-c", "--config"):
            if not isfile(v):
		newComb=[]
		roComb.append(newComb)
		for lthisfield,thisField in zip(lfields,fields):
			ia= i % lthisfield
			newComb.append(thisField[ia])
		
	return roComb


if __name__=='__main__':




	programName=argv[0]
	opt,args=getopt(argv[1:],'i:s:d:u',['startRow=','headerRow=','roll-over'])
	try:
		filename,=args
	except:
		printUsageAndExit(programName)

	internalSeparator="|"
	
	colSelectors=[]
	internalSeparators=[]
	
	rollover=False
	fs="\t"
	headerRow=-1
	startRow=-1
	uniq=False
Esempio n. 56
0
  <date>{date}</date>
 </doc>
"""

# Process command-line args

from getopt import *

gInputDir = "."
gOutput = sys.stdout
gOutputFile = None
gCompress = False
gQuiet = False
errflag = 0

opts, args = getopt(sys.argv[1:], 'd:o:qvz?',
                    ('dir', 'output', 'quiet', 'verbose', 'compress'))

for k, v in opts:
    if k == "-o":  # Output file
        gOutputFile = v
    elif k == "-d":
        gInputDir = v
    elif k == "-v":
        gLogger.setLevel(gLogger.getEffectiveLevel() - 10)
    elif k == "-z":
        gCompress = True
    else:
        errflag += 1

if errflag:
    sys.stderr.write("""Usage: %s [-d dir] [-o file] [-z] [-v] [-q]
Esempio n. 57
0
#!/usr/bin/env python

#
# $Id: inventory.py,v 1.2 2004-05-31 18:30:15 jsommers Exp $
#

import sys,xmlrpclib,pprint
from getopt import *

def usage(proggie):
	print "usage: ",proggie,"[-u <url>]*"
	exit
try:
	opts,args = getopt(sys.argv[1:],"u:",[])
except GetoptError,e:
	print "exception while processing options: ",e
	usage(sys.argv[0])

url_list = []
for o,a in opts:
	if o == "-u":
		url_list.append(a)

for server_url in url_list:
	print "Plugin Inventory for ",server_url,":"
	server = xmlrpclib.ServerProxy(server_url)
	try:
		result = server.queryPlugins()
		for struct in result:
			if struct.has_key('uptime'):
				print '\tplugin<%(plugin_name)s> state<%(state)s> personality<%(personality)s> uptime<%(uptime)d>' % struct
Esempio n. 58
0
from dirscan  import *
from datetime import *
from os.path  import *
from stat     import *

random.seed()

args   = None
debug  = False
status = False
window = 14
opts   = { 'dryrun': False, 'ages': False }

if len(sys.argv) > 1:
    options, args = getopt(sys.argv[1:], 'nvuA', {})

    for o, a in options:
        if o in ('-v'):
            debug = True
            l.basicConfig(level = l.DEBUG,
                          format = '[%(levelname)s] %(message)s')
        elif o in ('-u'):
            status = True
            l.basicConfig(level = l.INFO, format = '%(message)s')
        elif o in ('-n'):
            opts['dryrun'] = True
        elif o in ('-A'):
            opts['ages'] = True

def verifyContents(entry):
Esempio n. 59
0
    legend(['interpolated', 'smoothed'])
    title("FFT")
    xlabel("Frequency")
    ylabel("Amplitude")

    show()


def usage():
        print("usage: "+argv[0]+" -t times-file -c counts-file [-s SAMPLING_HZ] [-w WINDOW_LEN] [-h]")


if __name__=='__main__':

    try:
        opts, args = getopt(argv[1:], "c:hs:t:w:")
    except GetoptError:
        usage()
        exit(2)

    sample_hz = 10000
    wlen = 25
    times_file = None
    counts_file = None
    for o, a in opts:
        if o == "-c":
            counts_file = a
        if o == "-h":
            usage()
            exit()
        if o == "-s":