当前位置: 首页>>代码示例>>Python>>正文


Python getopt.getopt方法代码示例

本文整理汇总了Python中getopt.getopt方法的典型用法代码示例。如果您正苦于以下问题:Python getopt.getopt方法的具体用法?Python getopt.getopt怎么用?Python getopt.getopt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在getopt的用法示例。


在下文中一共展示了getopt.getopt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def main():
    exploits = []
    outfile = None
    if len (sys.argv) != 7:
        print ("Usage: ./runExploits.py -t <target-ip> -o <output-dir> -e <exploits>")
        print ("Note: <exploits> can be 'all' or a list of exploits seperated by ','")
        exit (1)
    opts, argv = getopt.getopt(sys.argv[1:], 'e:t:o:')
    for k, v in opts:
        if k == '-e':
            if v == 'all':
                exploits = list (METASPLOIT_EXPLOITS.keys()) + list (SHELL_EXPLOITS.keys())
            else:
                exploits = [int(x) for x in v.split(',')]
        if k == '-t':
            target = v
        if k == '-o':
            if not os.path.isdir(v):
                if os.path.exists(v):
                    os.remove(v)
                os.makedirs(v, 0o755);
            outfile = v + "/%(exploit)s.log"

    process(target, exploits, outfile) 
开发者ID:kyechou,项目名称:firmanal,代码行数:26,代码来源:runExploits.py

示例2: main

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def main(self, argv: List[str]) -> None:
        try:
            opts, args = getopt.getopt(argv, "hlvV ", ['help', 'log', 'version', 'version', 'dependency-versions'])
        except getopt.GetoptError:
            self.help_command()
        for opt, _ in opts:
            if opt in ['-h', '--help']:
                self.help_command()
            if opt in ['-v', '-V', '--version']:
                self.version_command()
            if opt in ['--dependency-versions']:
                self.dependency_versions_command()
        if len(args):
            if args[0] in ('run', 'start', 'go'):
                self.run_command(args[1:])
        self.help_command() 
开发者ID:kalaspuff,项目名称:tomodachi,代码行数:18,代码来源:__init__.py

示例3: main

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def main():
    infile = iid = None
    opts, argv = getopt.getopt(sys.argv[1:], "f:i:")
    for k, v in opts:
        if k == '-i':
            iid = int(v)
        if k == '-f':
            infile = v

    if infile and not iid:
        m = re.match(r"(\d+)\.tar\.gz", infile)
        if m:
            iid = int(m.groups(1))

    getarch (infile)
    process(iid, infile) 
开发者ID:kyechou,项目名称:firmanal,代码行数:18,代码来源:importdb.py

示例4: main

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def main():
    """Small main program"""
    import sys, getopt
    try:
        opts, args = getopt.getopt(sys.argv[1:], 'deut')
    except getopt.error as msg:
        sys.stdout = sys.stderr
        print(msg)
        print("""usage: %s [-d|-e|-u|-t] [file|-]
        -d, -u: decode
        -e: encode (default)
        -t: encode and decode string 'Aladdin:open sesame'"""%sys.argv[0])
        sys.exit(2)
    func = encode
    for o, a in opts:
        if o == '-e': func = encode
        if o == '-d': func = decode
        if o == '-u': func = decode
        if o == '-t': test(); return
    if args and args[0] != '-':
        with open(args[0], 'rb') as f:
            func(f, sys.stdout.buffer)
    else:
        func(sys.stdin.buffer, sys.stdout.buffer) 
开发者ID:war-and-code,项目名称:jawfish,代码行数:26,代码来源:base64.py

示例5: app

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def app():
    # Parse and interpret options.
    (opts, _) = getopt.getopt(argv[1:], "l:p:sh",
                              ["logfile=", "port=", "server-mode", "help"])
    port = 8000
    server_mode = False
    help_mode = False
    logfilename = None
    for (opt, value) in opts:
        if (opt == "-l") or (opt == "--logfile"):
            logfilename = str(value)
        elif (opt == "-p") or (opt == "--port"):
            port = int(value)
        elif (opt == "-s") or (opt == "--server-mode"):
            server_mode = True
        elif (opt == "-h") or (opt == "--help"):
            help_mode = True

    if help_mode:
        usage()
    else:
        wnb(port, not server_mode, logfilename) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:24,代码来源:wordnet_app.py

示例6: ParseArgs

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def ParseArgs(argv):
  options, args = getopt.getopt(
      argv[1:],
      'h:e:p:f:',
      ['host=', 'email=', 'params=', 'mysql_default_file='])
  host = None
  gae_user = None
  params = None
  mysql_default_file = None
  for option_key, option_value in options:
    if option_key in ('-h', '--host'):
      host = option_value
    elif option_key in ('-e', '--email'):
      gae_user = option_value
    elif option_key in ('-p', '--params'):
      params = option_value
    elif option_key in ('-f', '--mysql_default_file'):
      mysql_default_file = option_value
  return host, gae_user, params, mysql_default_file, args 
开发者ID:elsigh,项目名称:browserscope,代码行数:21,代码来源:local_scores.py

示例7: ParseArgs

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def ParseArgs(argv):
  options, args = getopt.getopt(
      argv[1:],
      'h:e:f:rc',
      ['host=', 'email=', 'mysql_default_file=',
       'release', 'category_browsers_only'])
  host = None
  gae_user = None
  mysql_default_file = None
  is_release = False
  is_category_browsers_only = False
  for option_key, option_value in options:
    if option_key in ('-h', '--host'):
      host = option_value
    elif option_key in ('-e', '--email'):
      gae_user = option_value
    elif option_key in ('-f', '--mysql_default_file'):
      mysql_default_file = option_value
    elif option_key in ('-r', '--release'):
      is_release = True
    elif option_key in ('-c', '--category_browsers_only'):
      is_category_browsers_only = True
  return host, gae_user, mysql_default_file, is_release, is_category_browsers_only, args 
开发者ID:elsigh,项目名称:browserscope,代码行数:25,代码来源:data_dump.py

示例8: ParseArgs

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def ParseArgs(argv):
  options, args = getopt.getopt(
      argv[1:],
      'h:u:p:',
      ['host=', 'gae_user=', 'params='])
  host = None
  gae_user = None
  params = None
  for option_key, option_value in options:
    if option_key in ('-h', '--host'):
      host = option_value
    elif option_key in ('-u', '--gae_user'):
      gae_user = option_value
    elif option_key in ('-p', '--params'):
      params = option_value
  return host, gae_user, params, args 
开发者ID:elsigh,项目名称:browserscope,代码行数:18,代码来源:admin.py

示例9: _parsebase

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def _parsebase(argv):
    """Parse until the second part of the command.
    """
    shortopts = 'vf:m:' # version, file, model
    longopts = ['version', 'file=', 'model=', 'samples-dir=', 'test-split=', 'val-split=',
                'cache-dir=', 'random-seed=', 'trainings-dir=', 'project-dir=',
                'cache=', 'device=', 'device-memory=']

    args, rest = getopt.getopt(argv, shortopts, longopts)

    args = dict(args)
    # don't match prefix
    for opt in map(lambda s: s.rstrip("="), longopts):
        # pylint: disable=W0640
        if ''f'--{opt}' in args and not any(map(lambda a: a.startswith('--' + opt), argv)):
            # find the key that does not match
            keys = map(lambda a: a.split("=")[0].lstrip("-"), argv)
            keys = list(filter(lambda k: k in opt, keys))
            if keys:
                raise getopt.GetoptError('Invalid key', opt='--' + keys[0])
            else:
                raise getopt.GetoptError('Invalid key')

    # convert from short to long names
    for sht, lng in (('-v', '--version'), ('-m', '--model'), ('-f', '--file')):
        if sht in args:
            args[lng] = args[sht]
            del args[sht]

    args = {k.strip('-'):v for k, v in args.items()}

    return args, rest 
开发者ID:mme,项目名称:vergeml,代码行数:34,代码来源:__main__.py

示例10: main

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def main(argv):
    try:
        opts, args = getopt.getopt(argv, "hi:d", ["ip="])
    except getopt.GetoptError:
        usage()
        sys.exit(2)

    if not opts:
        usage()
        sys.exit(2)

    for opt, arg in opts:
        if opt == "-h":
            print '### HELP? ma LOL ###'
            sys.exit()
        elif opt == "-i":
            ipToCheck = arg
         

    print '## Checking IP:',arg

    print '## Verify EGBL...'
    verifyConfig()
     
    print '## Check vulnerability...'
    verifyVuln(ipToCheck) 
开发者ID:fnatalucci,项目名称:NSAEQGRPFortinetVerify,代码行数:28,代码来源:check_fortinet_vuln.py

示例11: main

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def main():
    infile = None
    makeQemuCmd = False
    iid = None
    outfile = None
    arch = None
    endianness = None
    (opts, argv) = getopt.getopt(sys.argv[1:], 'f:i:S:a:oqd')
    for (k, v) in opts:
        if k == '-f':
            infile = v
        if k == '-d':
            global debug
            debug += 1
        if k == '-q':
            makeQemuCmd = True
        if k == '-i':
            iid = int(v)
        if k == '-S':
            VMDIR = v
        if k == '-o':
            outfile = True
        if k == '-a':
            (arch, endianness) = archEnd(v)

    if not arch or not endianness:
        raise Exception("Either arch or endianness not found try mipsel/mipseb/armel/armeb")

    if not infile and iid:
        infile = "%s/%i/qemu.initial.serial.log" % (VMDIR, iid)
    if outfile and iid:
        outfile = """%s/%i/run.sh""" % (VMDIR, iid)
    if debug:
        print("processing %i" % iid)
    if infile:
        process(infile, iid, arch, endianness, makeQemuCmd, outfile) 
开发者ID:kyechou,项目名称:firmanal,代码行数:38,代码来源:makeNetwork.py

示例12: main

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def main():
    ##
    # Handle command line input
    ##

    num_clips = 5000000

    try:
        opts, _ = getopt.getopt(sys.argv[1:], 'n:t:c:oH',
                                ['num_clips=', 'train_dir=', 'clips_dir=', 'overwrite', 'help'])
    except getopt.GetoptError:
        usage()
        sys.exit(2)

    for opt, arg in opts:
        if opt in ('-n', '--num_clips'):
            num_clips = int(arg)
        if opt in ('-t', '--train_dir'):
            c.TRAIN_DIR = c.get_dir(arg)
        if opt in ('-c', '--clips_dir'):
            c.TRAIN_DIR_CLIPS = c.get_dir(arg)
        if opt in ('-o', '--overwrite'):
            c.clear_dir(c.TRAIN_DIR_CLIPS)
        if opt in ('-H', '--help'):
            usage()
            sys.exit(2)

    # set train frame dimensions
    assert os.path.exists(c.TRAIN_DIR)
    c.FULL_HEIGHT, c.FULL_WIDTH = c.get_train_frame_dims()

    ##
    # Process data for training
    ##

    process_training_data(num_clips) 
开发者ID:dyelax,项目名称:Adversarial_Video_Generation,代码行数:38,代码来源:process_data.py

示例13: init

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def init(argv):
    """Read the args and return all variable
    Will return:
        - the number of error encounter
        - the absolute path of the output directory
        - an array of collection id given as args (in fact everything that is
            not a recognised arg
        - the absolute path of the save file
    Return int(error), string(output_dir), array(collections_id),
        string(save_file)
    """
    error = 0
    output_dir = os.getcwd()
    collections_id_list = []
    save_file = os.path.join(output_dir, "addons.lst")
    if len(argv) == 1 and not os.path.isfile(save_file):
        print("No save file found")
        usage(argv[0], 0)
    try:
        opts, args = getopt.getopt(argv[1:],"ho:")
    except getopt.GetoptError:
        usge(argv[0], 2)
    else:
        for opt, arg in opts:
            if opt == 'h':
                usge(argv[0], 0)
            elif opt == '-o':
                output_dir = os.path.abspath(arg)
                save_file = os.path.join(output_dir, "addons.lst")
        if not os.path.exists(output_dir):
            print(output_dir + ": path doesn't exist\nEnd of program")
            error += 1
        collections_id_list = argv[len(opts) * 2 + 1:]
    return error, output_dir, collections_id_list, save_file 
开发者ID:Geam,项目名称:steam_workshop_downloader,代码行数:36,代码来源:workshop.py

示例14: run

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def run(self, args):
    rid = RegressiveImageryDictionary()
    load_default_dict = True
    load_default_exc = True
    html_output = False
    title = "RID Analysis"

    try:
      optlist, args = getopt.getopt(sys.argv[1:], 'd:e:ht:',
                                    ['add-dict=', 'add-exc='])
      for (o, v) in optlist:
        if o == '-d':
          rid.load_dictionary_from_file(v)
          load_default_dict = False
        elif o == '-e':
          rid.load_exclusion_list_from_file(v)
          load_default_exc = False
        elif o == '--add-dict':
          rid.load_dictionary_from_file(v)
        elif o == '--add-exc':
          rid.load_exclusion_list_from_file(v)
        elif o == '-h':
          html_output = True
        elif o == '-t':
          title = v
        else:
          sys.stderr.write("%s: illegal option '%s'\n" % (args[0], o))
          self.usage(args)
    except getopt.GetoptError, e:
      sys.stderr.write("%s: %s\n" % (args[0], e.msg))
      self.usage(args)
      sys.exit(1) 
开发者ID:rafasashi,项目名称:razzy-spinner,代码行数:34,代码来源:rid.py

示例15: main

# 需要导入模块: import getopt [as 别名]
# 或者: from getopt import getopt [as 别名]
def main(argv):
    trainIds = False
    try:
        opts, args = getopt.getopt(argv,"ht")
    except getopt.GetoptError:
        printError( 'Invalid arguments' )
    for opt, arg in opts:
        if opt == '-h':
            printHelp()
            sys.exit(0)
        elif opt == '-t':
            trainIds = True
        else:
            printError( "Handling of argument '{}' not implementend".format(opt) )

    if len(args) == 0:
        printError( "Missing input json file" )
    elif len(args) == 1:
        printError( "Missing output image filename" )
    elif len(args) > 2:
        printError( "Too many arguments" )

    inJson = args[0]
    outImg = args[1]

    if trainIds:
        json2instanceImg( inJson , outImg , 'trainIds' )
    else:
        json2instanceImg( inJson , outImg )

# call the main method 
开发者ID:pierluigiferrari,项目名称:fcn8s_tensorflow,代码行数:33,代码来源:json2instanceImg.py


注:本文中的getopt.getopt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。