def transfer(argv=sys.argv):
try:
opts, args = getopt.getopt(argv[1:], "n")
except getopt.GetoptError:
usage()
return 1
dry_run = False
for o, a in opts:
if o == "-n":
dry_run = True
if len(args) == 3:
default_ttl = int(args[2])
else:
default_ttl = 86400
axfr(args[0], args[1], default_ttl, dry_run=dry_run)
python类GetoptError()的实例源码
graph_builder_month.py 文件源码
项目:bitcointalk-sentiment
作者: DolphinBlockchainIntelligence
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def main(argv):
input_file = ''
save_to = ''
try:
opts, args = getopt.getopt(argv, "hi:o:")
except getopt.GetoptError:
print('graph_builder.py -i <JSON inputfile> -o <output image>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('graph_builder.py -i <JSON inputfile> -o <output image>')
sys.exit()
elif opt == '-i':
input_file = arg
elif opt == '-o':
save_to = arg
build_graph(input_file,save_to)
bitcointalk_sentiment_classifier.py 文件源码
项目:bitcointalk-sentiment
作者: DolphinBlockchainIntelligence
项目源码
文件源码
阅读 21
收藏 0
点赞 0
评论 0
def main(argv):
warnings.filterwarnings('ignore', category=DeprecationWarning)
input_file = ''
model_file = ''
output_folder = ''
output_posts = ''
try:
opts, args = getopt.getopt(argv, "hi:m:f:n:")
except getopt.GetoptError:
print('bitcointalk_sentiment_classifier.py -i <inputfile> -m <model> -f <output folder> -n <number of output posts [number|fraction|all]>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('bitcointalk_sentiment_classifier.py -i <inputfile> -m <model> -f <output folder> -n <number of output posts [number|fraction|all]>')
sys.exit()
elif opt == '-i':
input_file = arg
elif opt == '-m':
model_file = arg
elif opt == '-f':
output_folder = arg
elif opt == '-n':
output_posts = arg
classify(input_file, model_file, output_folder, output_posts)
graph_builder.py 文件源码
项目:bitcointalk-sentiment
作者: DolphinBlockchainIntelligence
项目源码
文件源码
阅读 20
收藏 0
点赞 0
评论 0
def main(argv):
input_file = ''
save_to = ''
try:
opts, args = getopt.getopt(argv, "hi:o:")
except getopt.GetoptError:
print('graph_builder.py -i <JSON inputfile> -o <output image>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('graph_builder.py -i <JSON inputfile> -o <output image>')
sys.exit()
elif opt == '-i':
input_file = arg
elif opt == '-o':
save_to = arg
build_graph(input_file,save_to)
def main(argv):
global CONFIG_FILE_NAME
try:
opts, args = getopt.getopt(argv,"hc:",["help","config="])
except getopt.GetoptError:
print 'client.py -c <configfile> '
sys.exit(2)
for opt, arg in opts:
if opt in ("-h", "--help"):
print 'client.py -c <configfile> '
sys.exit()
elif opt in ("-c", "--config"):
CONFIG_FILE_NAME = arg
print 'Config file is "', CONFIG_FILE_NAME
unicorndisplay.init(CONFIG_FILE_NAME)
def main(argv):
inputfile = ''
try:
opts, args = getopt.getopt(argv,"i:",["ifile="])
except getopt.GetoptError:
print 'cidrToIps.py -i <inputfile>'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'cidrToIps.py -i <inputfile>'
sys.exit()
elif opt in ("-i", "--ifile"):
inputfile = arg
print 'Reading IP ranges in CIDR notation from file:', inputfile
fo = open(inputfile, "r+")
for line in fo:
for ip in IPNetwork(line):
print '%s' % ip
def main(argv):
import getopt, imp
def usage():
print ('usage: %s [-h host] [-p port] [-n name] module.class' % argv[0])
return 100
try:
(opts, args) = getopt.getopt(argv[1:], 'h:p:n:')
except getopt.GetoptError:
return usage()
host = ''
port = 8080
name = 'WebApp'
for (k, v) in opts:
if k == '-h': host = v
elif k == '-p': port = int(v)
elif k == '-n': name = v
if not args: return usage()
path = args.pop(0)
module = imp.load_source('app', path)
WebAppHandler.APP_CLASS = getattr(module, name)
print ('Listening %s:%d...' % (host,port))
httpd = HTTPServer((host,port), WebAppHandler)
httpd.serve_forever()
return
def main(argv):
import getopt, fileinput
def usage():
print ('usage: %s [-c codec] file ...' % argv[0])
return 100
try:
(opts, args) = getopt.getopt(argv[1:], 'c')
except getopt.GetoptError:
return usage()
if not args: return usage()
codec = 'utf-8'
for (k, v) in opts:
if k == '-c': codec = v
for line in fileinput.input(args):
line = latin2ascii(unicode(line, codec, 'ignore'))
sys.stdout.write(line.encode('ascii', 'replace'))
return
def main(argv):
"""Parse the arguments and start the main process."""
try:
opts, args = getopt.getopt(argv, "h", ["help"])
except getopt.GetoptError:
exit_with_parsing_error()
for opt, arg in opts:
arg = arg # To avoid a warning from Pydev
if opt in ("-h", "--help"):
usage()
sys.exit()
if len(args) == 2:
params = list(get_dicts(*args))
params.extend(get_dict_names(*args))
compare_dicts(*params)
else:
exit_with_parsing_error()
def parse_args(argv):
helpstring = 'dep-check.py [-c <config_file>] [-v -t -s]'
fname = PATCHWORK_PATH + '/patchwork/config.json' # if not specified, look in current directory
global VERBOSE
global TEST
global PERSIST
try:
opts, args = getopt.getopt(argv,"hvtsc:",["verbose","test","save","config="])
except getopt.GetoptError:
print(helpstring)
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print(helpstring)
sys.exit()
elif opt in ("-c", "--config"):
fname = arg
elif opt in ("-v", "--verbose"):
VERBOSE = True
elif opt in ("-t", "--test"):
TEST = True
elif opt in ("-s", "--save"):
PERSIST = True
return fname
def main(argv):
# Configure Parameters and Options
options = 'e:u:p:P:'
longOptions = ['endpoint=', 'user=', 'password=', 'pwdfile=']
# Get Options & Arguments
try:
opts, args = getopt.getopt(argv, options, longOptions)
# Read Module Arguments
moduleArgs = readModuleArgs(opts, args)
except getopt.GetoptError:
usage()
except Exception as e:
print('Unknown Exception please check log file')
logging.exception(e)
sys.exit(1)
return
# Main function to kick off processing
def main(argv):
# Configure Parameters and Options
options = 'e:u:p:P:'
longOptions = ['endpoint=', 'user=', 'password=', 'pwdfile=']
# Get Options & Arguments
try:
opts, args = getopt.getopt(argv, options, longOptions)
# Read Module Arguments
moduleArgs = readModuleArgs(opts, args)
except getopt.GetoptError:
usage()
except Exception as e:
print('Unknown Exception please check log file')
logging.exception(e)
sys.exit(1)
return
# Main function to kick off processing
def main(argv):
# Configure Parameters and Options
options = 'e:u:p:P:'
longOptions = ['endpoint=', 'user=', 'password=', 'pwdfile=']
# Get Options & Arguments
try:
opts, args = getopt.getopt(argv, options, longOptions)
# Read Module Arguments
moduleArgs = readModuleArgs(opts, args)
except getopt.GetoptError:
usage()
except Exception as e:
print('Unknown Exception please check log file')
logging.exception(e)
sys.exit(1)
return
# Main function to kick off processing
def main(argv):
# Configure Parameters and Options
options = 'e:u:p:P:'
longOptions = ['endpoint=', 'user=', 'password=', 'pwdfile=']
# Get Options & Arguments
try:
opts, args = getopt.getopt(argv, options, longOptions)
# Read Module Arguments
moduleArgs = readModuleArgs(opts, args)
except getopt.GetoptError:
usage()
except Exception as e:
print('Unknown Exception please check log file')
logging.exception(e)
sys.exit(1)
return
# Main function to kick off processing
def main(argv):
# Configure Parameters and Options
options = 'e:u:p:P:'
longOptions = ['endpoint=', 'user=', 'password=', 'pwdfile=']
# Get Options & Arguments
try:
opts, args = getopt.getopt(argv, options, longOptions)
# Read Module Arguments
moduleArgs = readModuleArgs(opts, args)
except getopt.GetoptError:
usage()
except Exception as e:
print('Unknown Exception please check log file')
logging.exception(e)
sys.exit(1)
return
# Main function to kick off processing
def main(argv):
# Configure Parameters and Options
options = 'e:u:p:P:'
longOptions = ['endpoint=', 'user=', 'password=', 'pwdfile=']
# Get Options & Arguments
try:
opts, args = getopt.getopt(argv, options, longOptions)
# Read Module Arguments
moduleArgs = readModuleArgs(opts, args)
except getopt.GetoptError:
usage()
except Exception as e:
print('Unknown Exception please check log file')
logging.exception(e)
sys.exit(1)
return
# Main function to kick off processing
def main(argv):
# Configure Parameters and Options
options = 'e:u:p:P:'
longOptions = ['endpoint=', 'user=', 'password=', 'pwdfile=']
# Get Options & Arguments
try:
opts, args = getopt.getopt(argv, options, longOptions)
# Read Module Arguments
moduleArgs = readModuleArgs(opts, args)
except getopt.GetoptError:
usage()
except Exception as e:
print('Unknown Exception please check log file')
logging.exception(e)
sys.exit(1)
return
# Main function to kick off processing
def main(argv):
# Configure Parameters and Options
options = 'e:u:p:P:'
longOptions = ['endpoint=', 'user=', 'password=', 'pwdfile=']
# Get Options & Arguments
try:
opts, args = getopt.getopt(argv, options, longOptions)
# Read Module Arguments
moduleArgs = readModuleArgs(opts, args)
except getopt.GetoptError:
usage()
except Exception as e:
print('Unknown Exception please check log file')
logging.exception(e)
sys.exit(1)
return
# Main function to kick off processing
def grabargs():
# "Grab command-line arguments"
fname = ''
options={
'strip':False,
'full':False,
'limit':False,
'stat':False,
'reduce':False,
}
if not sys.argv[1:]:
usage()
sys.exit(0)
try:
opts, args = getopt.getopt(sys.argv[1:], "hVtlv:f:l:",
["help", "version","stat", "limit=", "file="],)
except getopt.GetoptError:
usage()
sys.exit(0)
for o, val in opts:
if o in ("-h", "--help"):
usage()
sys.exit(0)
if o in ("-V", "--version"):
print scriptversion
sys.exit(0)
if o in ("-t", "--stat"):
options['stat'] = True;
if o in ("-l", "--limit"):
try: options['limit'] = int(val);
except: options['limit']=0;
if o in ("-f", "--file"):
fname = val
utfargs=[]
for a in args:
utfargs.append( a.decode('utf8'));
text= u' '.join(utfargs);
#if text: print text.encode('utf8');
return (fname, options)
def _getOptions(classtype):
try:
# IMPORTANT YOU CANNOT USE gnu_getopt OR OptionParser
# because they will treat execparams with negative number
# values as arguments.
#
# Since property ids *MUST* be valid XML names
# they cannot start with -, therefore this is safe
opts, args = getopt.getopt(sys.argv[1:], "i", ["interactive"])
if len(opts)==0 and len(args)==0:
print "usage: %s [options] [execparams]" % sys.argv[0]
print
print "The set of execparams is defined in the .prf for the component"
print "They are provided as arguments pairs ID VALUE, for example:"
print " %s INT_PARAM 5 STR_PARAM ABCDED" % sys.argv[0]
print
print classtype.__doc__
sys.exit(2)
except getopt.GetoptError:
print "usage: %s [options] [execparams]" % sys.argv[0]
print
print "The set of execparams is defined in the .prf for the component"
print "They are provided as arguments pairs ID VALUE, for example:"
print " %s INT_PARAM 5 STR_PARAM ABCDED" % sys.argv[0]
print
print classtype.__doc__
sys.exit(2)
return opts, args