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


Python osscripts.gopt函数代码示例

本文整理汇总了Python中pylib.osscripts.gopt函数的典型用法代码示例。如果您正苦于以下问题:Python gopt函数的具体用法?Python gopt怎么用?Python gopt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: main

def main(argv):
#-------------------------------------------------------------------------------
    """
    usage: tester <files to test>

    run an automated test against the specified python files.

    The files must have one or more functions with '__test__' embedded somewhere
    in the function name.
    """

    args, opts = oss.gopt(argv[1:], [('v', 'verbose')], [('p', 'package')], main.__doc__)

    pkg = '' if opts.package is None else opts.package + '.'

    tried = failed = 0

    for a in oss.paths(args):
        try:
            print("%-20s" % a, end='')
            t = test_it(pkg + a.name, opts.verbose)
            print("  %d tests" % t)
            tried += t
        except TesterException:
            print("failed")
            failed += 1

    print("\nRan %d tests. %d Failed\n" % (tried, failed), file=oss.stderr)

    if failed:
        oss.exit(1)
    oss.exit(0)
开发者ID:chyser,项目名称:bin,代码行数:32,代码来源:tester.py

示例2: main

def main(argv):
#-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [('h', 'hex'), ('d', 'decimal'), ('o', 'octal')], [], __doc__)

    disp = "%03x"

    if opts.decimal:
        disp = "%3d"
    elif opts.octal:
        disp = "%3o"


    for j in xrange(0,32):
        for i in xrange(0,8):
            l = 32*i + j

            if 0 < l and l < 27 :
                print (disp + ' : ^%c  ') % (l, chr(l + ord('a')-1)),
            elif l == 0 :
                print (disp + ' : \\0  ') % l,
            else:
                print (disp + ' : %c   ') %  (l, chr(l)),
        print '\n',

    oss.exit(0)
开发者ID:chyser,项目名称:bin,代码行数:25,代码来源:ascii.py

示例3: main

def main(argv):
#-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [('v','verbose')], [('h', 'hdr'), ('m', 'msg'), ('c','cmd')], usage)

    sa, tp = pnet.ArgsToAddrPort(args)

    if opts.msg:
        if isinstance(opts.msg, list):
            opts.msg = '\r\n'.join(opts.msg)
        else:
            opts.msg = util.CvtNewLines(opts.msg, '\r\n')

    if opts.hdr:
        opts.hdr = list(opts.hdr)

    if opts.cmd is None:
        opts.cmd = 'GET'
    else:
        opts.cmd = opts.cmd.upper()


    if opts.cmd in ['PUT', 'POST']:
        hdr, s = httpPutPost(sa[0], sa[1], tp[0], tp[1], opts.cmd, opts.msg, opts.hdr, opts.verbose)
    else:
        hdr, s = httpCmd(sa[0], sa[1], tp[0], tp[1], opts.cmd, opts.hdr, opts.verbose)

    print hdr
    print s

    oss.exit(0)
开发者ID:chyser,项目名称:bin,代码行数:30,代码来源:httpcmd.py

示例4: main

def main(argv):
#-------------------------------------------------------------------------------
    """ usage:
    """
    args, opts = oss.gopt(argv[1:], [], [('p', 'pat'), ('o', 'output')], __doc__ + main.__doc__)


    if len(args) == 0:
        args.append('.')

    if opts.output:
        otf = file(opts.output, 'w')
    else:
        otf = oss.stdout

    if opts.pat is None:
        opts.pat = '*'

    if ',' in opts.pat:
        opts.pat = opts.pat.split(',')

    a = Actions(otf)

    oss.find(args[0], opts.pat, a.action)

    if opts.output:
        otf.close()

    oss.exit(0)
开发者ID:chyser,项目名称:bin,代码行数:29,代码来源:find.py

示例5: main

def main(argv):
#-------------------------------------------------------------------------------

    args, opts = oss.gopt(argv[1:], [('v', 'verbose')], [('L', 'lib'), ('C', 'cc')], __doc__, longOpMarker='---', shortOpMarker='---')

    if opts.cc is None:
        oss.usage(1, __doc__, 'must specify compiler path')

    if opts.cc in compilerMap:
        path = compilerMap[opts.cc]
        if isinstance(path, tuple):
            opts.cc = path[1]
            path = path[0]
        else:
            opts.cc = 'cl.exe'
    else:
        path = oss.getpath(opts.cc)

    ## get environment
    env = oss.env.env

    env['PATH'] = path + ';' + env['PATH']

    if opts.lib is not None:
        env['LIB'] = opts.lib

    if opts.verbose:
        print path
        print opts.cc
        print opts.lib
        print args

    rc = subprocess.call(opts.cc + ' ' + ' '.join(args), env=env, shell=True)
    oss.exit(rc)
开发者ID:chyser,项目名称:bin,代码行数:34,代码来源:cc.py

示例6: main

def main(argv):
#-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [('r', 'recurse'), ('q', 'quick'), ('s', 'supress')],
                          [('d', 'dir')], [], [('x', 'exts')], __doc__)

    if not args:
        opts.usage(1, 'Must specify directories')

    if len(args) == 1:
        args.append('.')

    if opts.dir:
        args = ['{0}/{1}'.format(a, opts.dir) for a in args]

    for a in args:
        if not oss.exists(a):
            opts.usage(2, '"{0}" does not exist'.format(a))

    exts = set(['.{0}'.format(e) for e in opts.exts]) if opts.exts else None

    p = []
    for a0, a1 in util.permutations(len(args)):
        same = checkDir(args[a0], args[a1], exts, opts.quick, opts.recurse, opts.supress)
        p.append('    {0} {1} {2}'.format(args[a0], '==' if same else '!=', args[a1]))

    print('Status:')
    for i in p:
        print(i)
    oss.exit(0)
开发者ID:chyser,项目名称:bin,代码行数:29,代码来源:diffdir.py

示例7: main

def main(argv):
#-------------------------------------------------------------------------------
    """ usage: cvtimage -t <type> file [file ...]

        converts one or more image files to the specified image file type

        types include:
            jpg  : jpeg
            bmp  : bitmaps
            png  :
            gif  : (input only)
    """
    args, opts = oss.gopt(argv[1:], [], [('t', 'type')], main.__doc__)

    if opts.type is None:
        opts.usage(1, "must specify type")

    args = oss.paths(args)

    for a in args:
        otfn = a.drive_path_name + '.' + opts.type
        if otfn != a:
            try:
                print "Converting", a, "to", otfn
                Image.open(a).save(otfn)
            except IOError:
                print >> oss.stderr, "Cannot convert", a, "to", otfn



    oss.exit(0)
开发者ID:chyser,项目名称:bin,代码行数:31,代码来源:cvtimage.py

示例8: main

def main(argv):
#-------------------------------------------------------------------------------
    """ usage:  coverage.py [options] <module_name>

        options:
            -s | --swap   : swap the ran and miss marks
            -u | --useDB  : use prior run db if exists
            -m | --mods   : modules to report (accepts multiple)
    """
    args, opts = oss.gopt(argv[1:], [('s', 'swap'), ('u', 'useDB')], [], [], [('m', 'mods')], main.__doc__)

    if not args:
        opts.usage(1, 'Specify program or module')

    rm, mm = ('@', ' ') if opts.swap else (' ', '@')

    co = cvg.Coverage(args[0], rm, mm, opts.useDB, opts.mods)
    t, success = co.runTest()

    print("Tester: ran %d test(s) with %s\n" % (t, ['success', 'failure'][success]))
    print("Coverage generated files for:")

    for f in co.genReport():
        print('   ', f)

    oss.exit(0)
开发者ID:chyser,项目名称:bin,代码行数:26,代码来源:coverage.py

示例9: main

def main(argv):
#-------------------------------------------------------------------------------
    """ usage:
    """
    args, opts = oss.gopt(argv[1:], [], [], main.__doc__)

    oss.exit(0)
开发者ID:chyser,项目名称:bin,代码行数:7,代码来源:py_template.py

示例10: main

def main(argv):
#-------------------------------------------------------------------------------
    """ usage:
    """
    print(argv)
    args, opts = oss.gopt(argv[1:], [], [], main.__doc__ + __doc__)
    la = len(args)
    print(la)

    print(args)
    if not (0 < la < 3):
        oss.usage(1, "usage: cvt_flv_mp3.py <file_name.flv> [<output_file_name.mp3>]")
    elif la == 2:
        pth, fn, ext = oss.splitFilename(args[0])
        if not pth: pth = '.'
        infn = fn + '.flv'
        print(infn)
        pth, fn, ext = oss.splitFilename(args[1])
        if not pth: pth = '.'
        outfn = pth + '\\' + fn + '.mp3'
    else:
        pth, fn, ext = oss.splitFilename(args[0])
        if not pth: pth = '.'
        infn = fn + '.flv'
        outfn = pth + '\\' + fn + '.mp3'

    print("Pulling '%s' from '%s'" % (outfn, infn))
    oss.r(FFMPEG % (infn, outfn))
    oss.exit(0)
开发者ID:chyser,项目名称:bin,代码行数:29,代码来源:cvt_flv_mp3.py

示例11: main

def main(argv):
#-------------------------------------------------------------------------------
    """ options:
            -s | --seed   : specify a seed for the random number generator
            
    """
    args, opts = oss.gopt(argv[1:], [], [('s', 'seed'), ('r', 'restore')], __doc__)

    if opts.seed:
        sd = int(opts.seed)
    else:
        ## used for debugging
        sd = int(time.time())

    print(sd, "\n\n")
    random.seed(sd)
    
    disp = display.DisplayFactory('console')

    while 1:
        try:
            if opts.restore:
                Game().restore(opts.restore)
                opts.restore = None
            else:
                menu(disp)
                break

        except player.Notification as n:
            if n.typ == 'quit':
                pass
            elif n.typ == 'restore':
                opts.restore = n.val

    oss.exit(0)
开发者ID:chyser,项目名称:blocks,代码行数:35,代码来源:blocks.py

示例12: appmain

def appmain(usage, MFrame, CFGNm, title, context=None):
#-------------------------------------------------------------------------------
    """ builds the application and main window
    """

    args, opt = oss.gopt(oss.argv[1:], [], [('c', 'config')], usage)

    ## get configuration
    if opt.config is None:
        gConfig.Open(CFGNm)
    else:
        gConfig.Open(opt.config)

    children = gConfig.Load()

    app = wx.PySimpleApp()
    win = MFrame(None, -1, title, context, pos = gConfig.MainWindowPos, size = gConfig.MainWindowSize,
              style = wx.DEFAULT_FRAME_STYLE | wx.NO_FULL_REPAINT_ON_RESIZE | cfg.Flags2Style(gConfig.MainWindowFlags))


    app.SetTopWindow(win)

    ## open configured windows
    for c in children:
        win.Open(c[0], cfg.Flags2Style(c[1]))

    win.LoadConfig(gConfig)
    return app, win
开发者ID:chyser,项目名称:bin,代码行数:28,代码来源:mxmdi.py

示例13: main

def main(argv):
#-------------------------------------------------------------------------------
    """ usage: readlog.py <file> [<file> ...]

        continuously prints new lines added to files (like tail -f)
    """
    args, opts = oss.gopt(argv[1:], [], [], main.__doc__)

    fs = {};  last = None
    while 1:
        for f in args:
            if f not in fs and oss.exists(f):
                if last != f:
                    print('\n%s : -------------' % f)
                    last = f

                print("Opening:", f)
                last = f
                fs[f] = open(f, 'rU')
            else:
                if f in fs:
                    buf = fs[f].read(-1)
                    if buf:
                        if last != f:
                            print('\n%s : -------------' % f)
                            last = f
                        oss.stderr.write(buf)

            time.sleep(0.5)
开发者ID:chyser,项目名称:bin,代码行数:29,代码来源:readlog.py

示例14: main

def main(argv):
#-------------------------------------------------------------------------------
    """ usage:
    """
    args, opts = oss.gopt(argv[1:], [], [], main.__doc__ + __doc__)

    inf0 = open(args[0])
    inf1 = open(args[1])

    f0 = inf0.read()
    f1 = inf1.read()

    i = 0
    j = 0
    while 1:
        ch = getChar(f0, i)

        if ch != f1[j]:
            print(ch, f1[j], i)

            l = 0
            while ch != f1[j]:
                i += 1
                ch = getChar(f0, i)
                l += 1
            print('recover:', l)

        i += 1
        j += 1

    oss.exit(0)
开发者ID:chyser,项目名称:bin,代码行数:31,代码来源:chardiff.py

示例15: main

def main(argv):
#------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [], "")

    if not args:
        args = machs.keys()

    for m in args:
        if m not in machs:
	    print "unknown machine", m
	    continue

        print "Opening", m
	session = oss.r("qdbus org.kde.konsole /Konsole newSession", '$').strip()
        s = oss.r("qdbus org.kde.konsole /Sessions/%s setTitle 1 %s" % (session, m), '|')
        if s.strip():
            print s.rstrip()

        s = oss.r('qdbus org.kde.konsole /Sessions/%s sendText "ssh %s"' % (session, m), '|')
        if s.strip():
            print s.rstrip()

        s = oss.r('~/bin/qdsendnl %s' % session, '|')
        if s.strip():
            print s.rstrip()

        for cmd in machs[m]:
    	    if cmd:
	        s = oss.r('qdbus org.kde.konsole /Sessions/%s sendText "%s"' % (session, cmd), '|')
                if s.strip():
                    print s.rstrip()
	    s = oss.r('~/bin/qdsendnl %s' % session, '|')
            if s.strip():
                print s.rstrip()
开发者ID:chyser,项目名称:bin,代码行数:34,代码来源:cons.py


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