本文整理汇总了Python中pylib.osscripts.exit函数的典型用法代码示例。如果您正苦于以下问题:Python exit函数的具体用法?Python exit怎么用?Python exit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了exit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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
示例2: 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
示例3: 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
示例4: main
def main(argv):
#-------------------------------------------------------------------------------
""" usage:
"""
args, opts = oss.gopt(argv[1:], [], [], main.__doc__)
oss.exit(0)
开发者ID:chyser,项目名称:bin,代码行数:7,代码来源:py_template.py
示例5: 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
示例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: 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
示例8: 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
示例9: 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
示例10: 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
示例11: 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
示例12: usage
def usage(err):
#---------------------------------------------------------------------------
print >> oss.stderr, """
usage: %s
-c, --config : specify a configuration filename
""" % (gTitle)
oss.exit(err)
开发者ID:chyser,项目名称:bin,代码行数:7,代码来源:mxmdi.py
示例13: 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
示例14: 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
示例15: 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
示例16: usage
def usage(rc, errmsg=""):
print__doc__, file=oss.stderr
if errmsg:
print("""
Error:
""" + str(errmsg), file=oss.stderr)
oss.exit(rc)
开发者ID:chyser,项目名称:bin,代码行数:7,代码来源:fileobj.py
示例17: 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
示例18: 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
示例19: main1
def main1(argv):
#-------------------------------------------------------------------------------
args, opts = oss.gopt(argv[1:], [], [], usage)
#mb = imo.IMAPServer('kirby.fc.hp.com', 'chrish', 'kibsop)')
mb = imo.IMAPServer('mail.hp.com', '[email protected]', 'kibsop)')
print mb.version
print mb.capability()
print 'Num Messages', mb.numMsgs
chk = relib.reHas('[email protected]|[hH]yser')
for msgSeqNum in range(1, mb.numMsgs):
hdr = mb.getMsgHdr(msgSeqNum)
#if msgSeqNum >= 52:
# print hdr['to']
tl = hdr.toList()
if len(tl) != 1:
continue
#print msgSeqNum, tl[0]
if chk.isIn(tl[0]):
mb.store(msgSeqNum, '+FLAGS', '(\\Flagged)')
#print "-----------------------------------------------------------"
#print 'date:', hdr["date"]
#print "subject:", hdr['subject']
#print 'to:', hdr['to']
#print hdr.flags
print msgSeqNum
mb.close()
oss.exit(0)
开发者ID:chyser,项目名称:bin,代码行数:35,代码来源:imap_check.py
示例20: 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
注:本文中的pylib.osscripts.exit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论