本文整理汇总了Python中sys.argv.pop函数的典型用法代码示例。如果您正苦于以下问题:Python pop函数的具体用法?Python pop怎么用?Python pop使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了pop函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: hfst_specific_option
def hfst_specific_option(option):
if option in argv:
index = argv.index(option)
argv.pop(index)
return True
else:
return False
开发者ID:hfst,项目名称:hfst,代码行数:7,代码来源:setup.py
示例2: test_main_with_gui_argument
def test_main_with_gui_argument(self):
argv.append("-g")
pacsudoku = main()
with open(self.default_config_file) as rawfile:
actual_xml_content = rawfile.readlines()
self.assertEqual([], actual_xml_content)
argv.pop()
pacsudoku.config_file.file.close()
remove(self.default_config_file)
开发者ID:pstuder,项目名称:pacsudoku,代码行数:9,代码来源:test_pacsudoku.py
示例3: _targets_from_argv
def _targets_from_argv(self):
argv.pop(0) # remove script name
if not len(argv):
log.fatal("Nothing to do! Check the documentation and make sure to have a settings file.")
exit(1)
return []
target = {"target_path": argv.pop(0)}
if len(argv):
target["backup_dir"] = argv.pop(0)
yield target
开发者ID:ekevoo,项目名称:hfbr,代码行数:10,代码来源:hfbrw.py
示例4: test_main_with_valid_config_file
def test_main_with_valid_config_file(self):
argv.append("-c")
argv.append(self.my_config_file)
pacsudoku = main()
with open(self.my_config_file) as rawfile:
actual_xml_content = rawfile.readlines()
self.assertEqual(self.expected_xml_content, actual_xml_content)
argv.pop()
argv.pop()
pacsudoku.config_file_handler.file.close()
开发者ID:pstuder,项目名称:pacsudoku,代码行数:10,代码来源:test_pacsudoku.py
示例5: handle_args
def handle_args(argv):
# Default settings:
settings = {'root':False, 'port':'22', 'password':'', 'idfile':''}
argv = argv[1:] # Discard the name of the program.
for index, arg in enumerate(argv):
#print(index, arg)
if arg == '-r':
settings['root'] = True
elif arg == '-h':
try:
settings['hostname'] = argv.pop(index + 1)
except IndexError:
raise InputError('-h takes a positional argument.')
elif arg == '-i':
try:
settings['idfile'] = argv.pop(index + 1)
except IndexError:
raise InputError('-i takes a positional argument.')
elif arg == '-p':
settings['password'] = True
elif arg == '--install':
install() # Not a setting that gets passed along.
exit() # Also, it's the only thing we'll be doing, in that case.
elif arg.startswith('-'):
raise InputError('Unkown option ' + arg)
# First positional is host.
elif not 'host' in settings:
# Check for the presence of a user.
target = arg.split('@')
if len(target) == 1:
target = target[0]
elif len(target) == 2:
settings['user'] = target[0]
target = target[1]
else:
raise InputError('Multiple @ symbols in connection string.')
target = target.split(':')
settings['host'] = target[0]
if len(target) == 2:
settings['port'] = target[1]
elif len(target) > 2:
raise InputError('Multiple : symbols in connection string.')
# Second positional is bastion. or an intermediate host.
elif not 'bastion' in settings:
settings['bastion'] = arg
else:
raise InputError('Too many arguments')
if settings['password']:
settings['password'] = getpass(prompt='Please enter password: ')
if not 'hostname' in settings:
settings['hostname'] = settings['host']
return settings
开发者ID:mudbungie,项目名称:sshinit,代码行数:54,代码来源:sshinit.py
示例6: startup
def startup(self):
argv.pop()
p = Process(target=self.startWorker)
p.start()
p = Process(target=self.startRESTAPI)
p.start()
p = Process(target=self.startElasticsearch)
p.start()
开发者ID:frnsys,项目名称:UnveillanceAnnex,代码行数:11,代码来源:unveillance_annex.py
示例7: process_batch_command
def process_batch_command(argv):
if len(argv) > 0:
command = str(argv[0]);
else:
command = "help"
if len(argv) > 0:
argv.pop(0)
args = argv
else:
args = []
return process_command(command, args)
开发者ID:ChrisCummins,项目名称:pip-db,代码行数:13,代码来源:pipbot.py
示例8: main
def main(*args, **kwargs):
"""
Upload a file to a Twitter account
"""
argv.pop(0)
status = str()
if argv:
status = argv.pop()
unuploaded = True
while unuploaded:
try:
api = create_api(read_keys())
api.update_with_media("output.png", status)
unuploaded = False
print("Successfully uploaded!")
except Exception as e:
print("Error: {}".format(e))
开发者ID:sleibrock,项目名称:Randombrot,代码行数:17,代码来源:upload.py
示例9: main
def main(argv):
argv.pop(0)
entry = Entrypoint(args=argv)
try:
entry.exit_if_disabled()
if not entry.is_handled and not entry.should_config:
entry.log.warning("Running command without config")
entry.launch()
entry.config.set_to_env()
entry.log.debug("Starting config")
entry.run_pre_conf_cmds()
entry.apply_conf()
entry.run_post_conf_cmds()
entry.launch()
except Exception as e:
entry.log.error(str(e))
exit(1)
开发者ID:cmehay,项目名称:pyentrypoint,代码行数:17,代码来源:entrypoint.py
示例10: _construct
def _construct(self):
"""
Construct the argument parser.
lense-devtools build {package} (optional) # Defaults to build all
"""
self.parser = ArgumentParser(description=self._desc(), formatter_class=RawTextHelpFormatter)
# Main argument
self.parser.add_argument('command', help=self._command_help())
# Argument flags
self.parser.add_argument('-p', '--projects', help='A single project or comma seperated list of projects', action='append')
self.parser.add_argument('-a', '--auto', help='Run in automated mode (avoid prompts)', action='store_true')
# Parse arguments
argv.pop(0)
self.storage = vars(self.parser.parse_args(argv))
开发者ID:pombredanne,项目名称:lense-devtools,代码行数:18,代码来源:args.py
示例11: main
def main():
prog = "mr_repo"
if (len(argv) > 0):
prog = argv.pop(0)
# If prog does not look something like Mr. Repo then change it
if None == re.search('mr(\.|)([-_ ]{0,2})repo', prog,
flags=re.IGNORECASE):
prog = "mr_repo"
#Create an instance of MrRepo
Repossesser(prog=prog, args=argv, execute=True, one_use=True)
开发者ID:RyanMcG,项目名称:Mr-Repo,代码行数:10,代码来源:main.py
示例12: main_func
def main_func():
# Check the number of inputs
numofinputs = len(sys.argv)
# Conditional expressions
if numofinputs > 5 :
print ("Invalid arguments \nGood BYE")
else :
# Get the input arguments
filename = argv.pop(1) # EXE name, File Name, Module Name
operation = argv.pop(1) # DEBUG, INFO, WARN, ERROR, CRITICAL, EXCEPTION
message = argv.pop(1) # Message to be printed
logFile = argv.pop(1) # Log file
# setup `logging` module
logger = logging.getLogger(filename)
fileHandler = logging.FileHandler('Logger.log')
logger.setLevel(logging.INFO)
formatter = logging.Formatter("[%(asctime)s] [%(name)s] : %(message)s")
# setup `RainbowLoggingHandler`
handler = RainbowLoggingHandler(sys.stderr, color_name=('grey', None , True),color_asctime=('green', None , True))
handler.setFormatter(formatter)
fileHandler.setFormatter(formatter)
logger.addHandler(fileHandler)
logger.addHandler(handler)
if operation == 'DEBUG' :
logger.debug(message)
if operation == 'INFO' :
logger.info(message)
if operation == 'WARN' :
logger.warn(message)
if operation == 'ERROR' :
logger.error(message)
if operation == 'CRITICAL' :
logger.critical(message)
if operation == 'EXCEPTION' :
raise RuntimeError("InstallException!")
logger.exception(message)
logger.exception(e)
开发者ID:mathewba,项目名称:GitRepository,代码行数:42,代码来源:InstallLogger.py
示例13: run
def run(self):
"""
Parse the command-line arguments and call the method corresponding to
the situation.
"""
# We're using a custom parser here to handle subcommands.
argv = self.argv
argc = len(argv)
if argc == 0:
return self.print_help()
action = argv.pop(0)
argc -= 1
if action in HELP_FLAGS:
self.print_version()
return self.print_help()
if action in ('-v', '-version', '--version'):
return self.print_version()
# Subcommands are defined as below:
# def action_some_keyword(self, ...)
# defines an action 'some:keyword'. We might need to use classes for
# subcommands like Thor (Ruby gem), but it'd be too much overhead for
# now.
name = 'action_%s' % action.replace(':', '_')
if not hasattr(self, name):
print("Unrecognized action '%s'" % action)
return self.print_help()
fun = getattr(self, name)
# dynamically check if enough arguments were given on the command line
spec = inspect.getargspec(fun)
# skip 'self'
spec_args = (spec.args or ())[1:]
spec_defaults = spec.defaults or ()
defaults_len = len(spec_defaults)
required_len = len(spec_args) - defaults_len
if argc < required_len or (argc > 0 and argv[0] in HELP_FLAGS):
defaults = list(reversed(spec_args))[:defaults_len]
args = []
for arg in spec_args:
fmt = '<%s>'
if arg in defaults:
fmt = '[%s]' % fmt
args.append(fmt % arg)
if spec.varargs:
args.append('[<%s...>]' % spec.varargs)
print("Usage:\n\t%s %s %s" % (self.exe, action, ' '.join(args)))
return False
return fun(*argv)
开发者ID:bfontaine,项目名称:didelcli,代码行数:54,代码来源:cli.py
示例14: main
def main():
success = True
argv.pop(0)
if not argv:
help()
success = False
while (argv):
init_dir()
command = argv.pop(0)
if not command in commands:
help();
success = False
break
returncode = commands[command][0]()
success = success and not bool(returncode)
sys.exit(not success)
开发者ID:OpenFlex,项目名称:bleeding_edge,代码行数:20,代码来源:dom.py
示例15: main
def main():
success = True
argv.pop(0)
if not argv:
help()
success = False
while (argv):
# Make sure that we're always rooted in the dart root folder.
os.chdir(dart_dir)
command = argv.pop(0)
if not command in commands:
help();
success = False
break
returncode = commands[command][0]()
success = success and not bool(returncode)
sys.exit(not success)
开发者ID:francom,项目名称:bleeding_edge,代码行数:21,代码来源:dom.py
示例16: main
def main(argv):
status, result = None, None
arg = argv.pop(0).lower()
if arg == "keygen":
status, result = createPrimaryKey(argv)
elif arg == "encrypt":
status, result = encrytData(argv)
elif arg == "decrypt":
status, result = decryptData(argv)
elif arg == "crack":
status, result = crackEncryptedData(argv)
else:
status, result = False, "Invalid argument: {0}".format(arg)
print("{0}".format(result))
return status
开发者ID:aishee,项目名称:cryptoFile,代码行数:15,代码来源:crypto.py
示例17: test_dart2js
def test_dart2js(browser, argv):
cmd = [
os.path.join('tools', 'test.py'),
'-c', 'dart2js',
'-r', browser,
'--mode=release',
'--checked',
'--arch=ia32',
'-v',
]
if argv:
cmd.append(argv.pop(0))
else:
print(
'Test commands should be followed by tests to run. Defaulting to html')
cmd.append('html')
return call(cmd)
开发者ID:francom,项目名称:bleeding_edge,代码行数:17,代码来源:dom.py
示例18: test_sudoku_argument_parser_class_with_arguments
def test_sudoku_argument_parser_class_with_arguments(self):
expected_config_metavar = "other.xml"
argv.append("-g")
argv.append("-c")
argv.append(expected_config_metavar)
parser = SudokuArgumentParser()
actual_arguments = parser.parse_args()
argv.pop()
argv.pop()
argv.pop()
self.assertEqual(expected_config_metavar, actual_arguments.config)
self.assertTrue(actual_arguments.gui)
开发者ID:pstuder,项目名称:pacsudoku,代码行数:12,代码来源:test_pacsudoku.py
示例19: test_dart2js
def test_dart2js(browser, argv):
cmd = [
os.path.join("tools", "test.py"),
"-c",
"dart2js",
"-r",
browser,
"--mode=release",
"--checked",
"--arch=ia32",
"-v",
]
if argv:
cmd.append(argv.pop(0))
else:
print ("Test commands should be followed by tests to run. Defaulting to html")
cmd.append("html")
return call(cmd)
开发者ID:hangstrap,项目名称:bleeding_edge,代码行数:18,代码来源:dom.py
示例20:
'PyStemmer',
'python-dateutil',
'SOAPpy',
'SQLAlchemy>=0.5,<0.6a', # Works with >=0.4.6 except on OS X
'Twisted',
'wokkel>=0.6.3',
]
if version_info[0] == 2 and version_info[1] < 6:
install_requires.append('simplejson')
if version_info[0] == 2 and version_info[1] < 5:
install_requires.append('cElementTree')
install_requires.append('pysqlite')
if argv[1:] == ['install', '--no-dependencies']:
argv.pop()
install_requires = None
setup(
name='Ibid',
version='0.2.0dev',
description='Multi-protocol general purpose chat bot',
url='http://ibid.omnia.za.net/',
keywords='chat bot irc jabber twisted messaging',
author='Ibid Developers',
author_email='[email protected]',
license='MIT',
py_modules=['ibid'],
install_requires=install_requires,
extras_require = {
'imdb': ['imdbpy'],
开发者ID:adrianmoisey,项目名称:ibid,代码行数:31,代码来源:setup.py
注:本文中的sys.argv.pop函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论