• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python osscripts.gopt函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: main

def main(argv):
#-------------------------------------------------------------------------------
    """ usage: compilexrc [options] <xrc_file>
        options:
            -d | --dialog  : generate dialog code (default)
            -a | --app     : generate application code
            -f | --frame   : generate frame code
            -w | --wizard  : generate wizard code
            -p | --panel   : generate panel code

            -m | --mixin   : import mixin file, name = <xrc_file>_mixin.py
    """
    args, opts = oss.gopt(argv[1:], [('a', 'app'), ('w', 'wizard'), ('d', 'dialog'), ('m', 'mixin'), ('p', 'panel'), ('f', 'frame')], [], __doc__ + main.__doc__)
    if not args:
        oss._usage(1, "must supply xrc file(s)")

    if opts.app:
        tflag = 'APP'
    elif opts.wizard:
        tflag = 'WIZ'
    elif opts.dialog:
        tflag = 'DLG'
    elif opts.panel:
        tflag = 'PNL'
    elif opts.frame:
        tflag = 'APP'
    else:
        tflag = None

    for infn in oss.paths(args):
        fn = infn.name
        xrc = XRCParser(infn, fn)
        xrc.compileXrc(tflag, opts.mixin)

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


示例17: main

def main(argv):
#-------------------------------------------------------------------------------
    args, opts = oss.gopt(argv[1:], [], [('s', 'start'), ('e', 'end')], usage)

    start = 0
    end = 100000000000000000

    if opts.start is not None:
        start = int(opts.start)

    if opts.end is not None:
        end = int(opts.end)

    inf = file(args[0])
    try:
        otf = file(args[1], 'w')
    except IndexError:
        otf = oss.stdout

    idx = 0
    for line in inf:
        if start <= idx < end:
            otf.write(line)
        else:
            if idx >= end:
                break
        idx += 1

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


示例18: main

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

    mp = set()

    oss.cd(MUSIC_PATH)
    for f in oss.find('.', '*.mp3'):
        dest = CAR_PATH + f[2:]
        d = dest.split('\\')[0] + '/'

        mp.add(f)

        if not oss.exists(d):
            oss.mkdir(d)

        if not oss.exists(dest) or oss.newerthan(f, dest):
            print(f, dest)
            cp(f, dest)

    if opts.extra:
        oss.cd(CAR_PATH)
        dp = set()

        for f in oss.find('.', '*.mp3'):
            dp.add(f)

        a = dp - mp
        for f in a:
            print(f)

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


示例19: main

def main(argv):
#-------------------------------------------------------------------------------
    """ usage: drives.py

    shows the available drives on the system and (free space/total space)
    """
    args, opts = oss.gopt(argv[1:], [], [], main.__doc__)

    drives = w32.GetLogicalDrives()

    for i in range(26):
        if drives & (1 << i):
            dl = chr(i + ord('A'))
            rootpath = dl + ':\\'
            tp = w32.GetDriveType(rootpath)
            print("  %s:" % dl, S[tp], end='')

            try:
                f, t, d = w32.GetDiskFreeSpaceEx(rootpath)

                if tp == 4:
                    print(" (%s/%s)" % (util.CvtGigMegKBytes(f), util.CvtGigMegKBytes(t)), end='')
                    print(" [%s]" % wnet.WNetGetUniversalName(rootpath, 1))
                else:
                    print(" (%s/%s)" % (util.CvtGigMegKBytes(f), util.CvtGigMegKBytes(t)))

            except:
                print("  -- not ready")

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


示例20: main

def main(argv):
#-------------------------------------------------------------------------------
    """ usage: newerthan.py [options[ <date>

        options:
            -i | --ignore   : extentions to ignore (may be specified multiple times)

        finds file newer than the specified data
        date formats ['%b %d %y', '%b %d %Y', '%B %d %y', '%B %d %Y']
    """
    args, opts = oss.gopt(argv[1:], [], [], [], [('i', 'ignore')], main.__doc__)

    td = cvtDateExpr(' '.join(args))
    if td is None:
        opts.usage(1, "Can't parse date")

    for f in oss.find('.'):
        bn, _, ext = f.rpartition('.')

        if ext in set(['bak']) or ext.startswith('bk'):
            continue

        s = os.stat(f)
        fd = datetime.datetime.fromtimestamp(s.st_mtime)
        if fd > td:
            print(f)


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pexpect.spawn函数代码示例发布时间:2022-05-25
下一篇:
Python osscripts.exit函数代码示例发布时间:2022-05-25
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap