本文整理匯總了Python中sys.argv方法的典型用法代碼示例。如果您正苦於以下問題:Python sys.argv方法的具體用法?Python sys.argv怎麽用?Python sys.argv使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sys
的用法示例。
在下文中一共展示了sys.argv方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: weather_icons
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def weather_icons():
try:
if argv[1] == 'loop':
loop()
elif argv[1] in os.listdir(folder_path):
print('Drawing Image: {}'.format(argv[1]))
img = Image.open(folder_path + argv[1])
draw_animation(img)
unicorn.off()
else:
help()
except IndexError:
help()
示例2: __init__
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def __init__(self, model_nm, logfile=None, props=None,
loglevel=logging.INFO):
self.model_nm = model_nm
self.graph = nx.Graph()
if props is None:
self.props = {}
else:
self.props = props
logfile = self.get("log_fname")
self.logger = Logger(self, model_name=model_nm,logfile=logfile)
self.graph.add_edge(self, self.logger)
self["OS"] = platform.system()
self["model"] = model_nm
# process command line args and set them as properties:
prop_nm = None
for arg in sys.argv:
# the first arg (-prop) names the property
if arg.startswith(SWITCH):
prop_nm = arg.lstrip(SWITCH)
# the second arg is the property value
elif prop_nm is not None:
self[prop_nm] = arg
prop_nm = None
示例3: __init__
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def __init__(self, defaults, args):
script_name = os.path.splitext(os.path.basename(sys.argv[0]))[0]
self.defaults = defaults
self.dir = self.__find_config_dir(script_name)
self.parser = self.__init_configparser(script_name)
global DEBUG
DEBUG = self.parser.getboolean('debug', DEBUG) or args.debug
global VERBOSE
VERBOSE = self.parser.getboolean('verbose', VERBOSE) or args.verbose
global VERIFY_SSL
VERIFY_SSL = self.parser.getboolean('verify_ssl', VERIFY_SSL)
global UNICODE
UNICODE = self.parser.getboolean('unicode', UNICODE)
if DEBUG:
# Turn on some extras
global SAVE_PLAYLIST_FILE
SAVE_PLAYLIST_FILE = True
示例4: main
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def main():
env = os.environ.copy()
# in case the PYTHONHASHSEED was not set, set to 0 to denote
# that hash randomization should be disabled and
# restart python for the changes to take effect
if 'PYTHONHASHSEED' not in env:
env['PYTHONHASHSEED'] = "0"
proc = subprocess.Popen([sys.executable] + sys.argv,
env=env)
proc.communicate()
exit(proc.returncode)
# check if hash has been properly de-randomized in python 3
# by comparing hash of magic tuple
h = hash(eden.__magic__)
assert h == eden.__magic_py2hash__ or h == eden.__magic_py3hash__, 'Unexpected hash value: "{}". Please check if python 3 hash normalization is disabled by setting shell variable PYTHONHASHSEED=0.'.format(h)
# run program and exit
print("This is the magic python hash restart script.")
exit(0)
示例5: ensure_lambda_helper
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def ensure_lambda_helper():
awslambda = getattr(clients, "lambda")
try:
helper_desc = awslambda.get_function(FunctionName="aegea-dev-process_batch_event")
logger.info("Using Batch helper Lambda %s", helper_desc["Configuration"]["FunctionArn"])
except awslambda.exceptions.ResourceNotFoundException:
logger.info("Batch helper Lambda not found, installing")
import chalice.cli
orig_argv = sys.argv
orig_wd = os.getcwd()
try:
os.chdir(os.path.join(os.path.dirname(__file__), "batch_events_lambda"))
sys.argv = ["chalice", "deploy", "--no-autogen-policy"]
chalice.cli.main()
except SystemExit:
pass
finally:
os.chdir(orig_wd)
sys.argv = orig_argv
示例6: main
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def main(wf):
query = sys.argv[1]
baseUrl = os.getenv('baseUrl')
url = baseUrl + 'user?keyword=' + query
try:
result = web.get(url=url)
result.raise_for_status()
resp = result.text
userList = json.loads(resp)
if len(userList) > 0:
for item in userList:
title = item['title']
subtitle = item['subTitle']
icon = item['icon']
userId = item['userId']
copyText = item['copyText']
qlurl = item['url']
wf.add_item(title=title, subtitle=subtitle, icon=icon, largetext=title, copytext=copyText, quicklookurl=qlurl, arg=userId, valid=True)
else:
wf.add_item(title='找不到聯係人…',subtitle='請重新輸入')
except IOError:
wf.add_item(title='請先啟動微信 & 登錄…',subtitle='並確保安裝微信小助手')
wf.send_feedback()
示例7: parse_args
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def parse_args():
"""
Parse input arguments
"""
parser = argparse.ArgumentParser(description='Re-evaluate results')
parser.add_argument('output_dir', nargs=1, help='results directory',
type=str)
parser.add_argument('--imdb', dest='imdb_name',
help='dataset to re-evaluate',
default='voc_2007_test', type=str)
parser.add_argument('--matlab', dest='matlab_eval',
help='use matlab for evaluation',
action='store_true')
parser.add_argument('--comp', dest='comp_mode', help='competition mode',
action='store_true')
parser.add_argument('--nms', dest='apply_nms', help='apply nms',
action='store_true')
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
return args
開發者ID:Sunarker,項目名稱:Collaborative-Learning-for-Weakly-Supervised-Object-Detection,代碼行數:26,代碼來源:reval.py
示例8: parse_args
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def parse_args():
"""
Parse input arguments
"""
parser = argparse.ArgumentParser(description='Re-evaluate results')
parser.add_argument('output_dir', nargs=1, help='results directory',
type=str)
parser.add_argument('--imdb', dest='imdb_name',
help='dataset to re-evaluate',
default='voc_2007_test', type=str)
parser.add_argument('--comp', dest='comp_mode', help='competition mode',
action='store_true')
if len(sys.argv) == 1:
parser.print_help()
sys.exit(1)
args = parser.parse_args()
return args
開發者ID:Sunarker,項目名稱:Collaborative-Learning-for-Weakly-Supervised-Object-Detection,代碼行數:21,代碼來源:reval_discovery.py
示例9: main
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def main (argv):
global host, hosts, tests
if len(argv) == 3: # tnode.py torch.cfg hostname
cfile = argv[1]
host = argv[2]
else:
print 'usage: tnode torch.cfg hostname'
exit()
try:
config = tlib.parser(cfile)
hosts = config.hosts
bgprouters = config.bgprouters
except Exception, e:
print 'Bad configuration: ' + repr(e)
exit()
示例10: shutdown
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def shutdown():
if lp_events.timer != None:
lp_events.timer.cancel()
scripts.to_run = []
for x in range(9):
for y in range(9):
if scripts.threads[x][y] != None:
scripts.threads[x][y].kill.set()
if window.lp_connected:
scripts.unbind_all()
lp_events.timer.cancel()
launchpad_connector.disconnect(lp)
window.lp_connected = False
logger.stop()
if window.restart:
if IS_EXE:
os.startfile(sys.argv[0])
else:
os.execv(sys.executable, ["\"" + sys.executable + "\""] + sys.argv)
sys.exit("[LPHK] Shutting down...")
示例11: parse_options
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def parse_options():
"""
parse command line options
"""
parser = argparse.ArgumentParser()
helptext="Root path of input run for which metadata should be created, should contain metadata.tsv and genome_to_id.tsv"
parser.add_argument("-i", "--input-run", type=str, help=helptext)
helptext="output file to write metadata to"
parser.add_argument("-o", "--output", type=str, help=helptext)
helptext="Name of the data set"
parser.add_argument("-n", "--name", type=str, help=helptext)
if not len(sys.argv) > 1:
parser.print_help()
return None
args = parser.parse_args()
return args
示例12: main
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def main(argv):
""" Spleeter runner. Parse provided command line arguments
and run entrypoint for required command (either train,
evaluate or separate).
:param argv: Provided command line arguments.
"""
try:
parser = create_argument_parser()
arguments = parser.parse_args(argv[1:])
enable_logging()
if arguments.verbose:
enable_tensorflow_logging()
if arguments.command == 'separate':
from .commands.separate import entrypoint
elif arguments.command == 'train':
from .commands.train import entrypoint
elif arguments.command == 'evaluate':
from .commands.evaluate import entrypoint
params = load_configuration(arguments.configuration)
entrypoint(arguments, params)
except SpleeterError as e:
get_logger().error(e)
示例13: main
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def main():
global output_file
num_args = len(sys.argv)
if num_args < 3:
print("usage: %s <json-file-1> [json-file-2 ...] <output-csv-file>" % sys.argv[0], file=sys.stderr)
exit(1)
json_files = sys.argv[1:num_args - 1]
output_file = sys.argv[num_args - 1]
merged_json_data = {}
for json_file in json_files:
print("> reading JSON file '%s'..." % json_file)
with open(json_file) as f:
json_data = json.load(f)
for label, data in json_data.items():
if label not in merged_json_data:
merged_json_data[label] = data
else:
merged_json_data[label]['data'].extend(data['data'])
# pprint(merged_json_data)
analyse(merged_json_data)
示例14: read_props
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def read_props(model_nm):
"""
A prop file to read must be our first arg, if it exists.
"""
if len(sys.argv) > 1:
poss_props = sys.argv[1]
if not poss_props.startswith('-'): # not a property but a prop file
return prop_args.read_props(model_nm, poss_props)
return None
示例15: main
# 需要導入模塊: import sys [as 別名]
# 或者: from sys import argv [as 別名]
def main(args=None):
"""The main routine."""
if args is None:
args = sys.argv[1:]
print("The modules containing models are: ")
for num, module in modules.items():
print(str(num) + ". " + module[MODULE_NAME])
choice = int(
input("Enter module number to view avialable models: "))
modules[choice][MODULE_MAIN]()