Here are the examples of the python api sys.argv taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
3
View Complete Implementation : recipe-343386.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def main():
opts,args = getopt.getopt(sys.argv[1:],'h:w:rR:')
height = 500
width = 500
dorandom = 0
rule = 22
for key,val in opts:
if key == '-h': height = int(val)
if key == '-w': width = int(val)
if key == '-r': dorandom = 1
if key == '-R': rule = int(val)
data = ca_data(height,width,dorandom,rule)
pil_render(data,height,width)
return
3
View Complete Implementation : recipe-578791.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def main():
debug("Entered main()")
global sysargv
sysargv = sys.argv
# Check for right number of arguments.
if len(sysargv) != 3:
sys.exit(1)
XMLtoPDFBook()
debug("Exiting main()")
3
View Complete Implementation : recipe-576583.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def main():
try:
file = open(sys.argv[1], 'rb')
md5 = hashlib.md5()
buffer = file.read(2 ** 20)
while buffer:
md5.update(buffer)
buffer = file.read(2 ** 20)
file.close()
print(md5.hexdigest())
except:
import os
print('Usage: {0} <filename>'.format(os.path.basename(sys.argv[0])))
3
View Complete Implementation : recipe-510388.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def main(function):
try:
arguments = sys.argv[1:]
astert arguments
for path in arguments:
astert os.path.isdir(path)
for path in arguments:
engine(path, function)
except:
sys.stdout.write(os.path.basename(sys.argv[0]) + ' <directory>')
3
View Complete Implementation : recipe-355731.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def main():
import sys, os
def printDocstring(base, node):
name, isDoc, childNodes = node
if isDoc == False:
print 'No docstring for %s%s!' % (base, name)
for symbol in childNodes:
printDocstring('%s.' % name, symbol)
if len(sys.argv) != 2:
print usage
raise SystemExit
module = DocStringCoverageVisitor(sys.argv[1]).getResult()
if not module[0]:
print "No module dostring!"
for symbol in module[1]:
printDocstring('', symbol)
3
View Complete Implementation : recipe-79735.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def setarg(pos, val):
if isarg(pos):
if isint(sys.argv[pos]):
return int(sys.argv[pos])
else:
return sys.argv[pos]
else:
sys.argv.append(str(val)) # str(val) is used, because by default all arguments are strings
if isint(sys.argv[len(sys.argv)-1]):
return int(sys.argv[len(sys.argv)-1])
else:
return sys.argv[len(sys.argv)-1]
3
View Complete Implementation : recipe-578396.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def main(argv):
if (len(sys.argv) != 5):
sys.exit('Usage: simple_past.py <upper_case> <lower_case> <digit> <special_characters>')
pastword = ''
for i in range(len(argv)):
for j in range(int(argv[i])):
if i == 0:
pastword += string.uppercase[random.randint(0,len(string.uppercase)-1)]
elif i == 1:
pastword += string.lowercase[random.randint(0,len(string.lowercase)-1)]
elif i == 2:
pastword += string.digits[random.randint(0,len(string.digits)-1)]
elif i == 3:
pastword += string.punctuation[random.randint(0,len(string.punctuation)-1)]
print 'You new pastword is: ' + ''.join(random.sample(pastword,len(pastword)))
3
View Complete Implementation : recipe-577599.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def main():
if len(sys.argv) < 2: usage()
try: opts, args = getopt.getopt(sys.argv[1:], 'h:t:')
except getopt.GetoptError as err: usage()
host = test = None
for o, value in opts:
if o == "-h": host = value
elif o == "-t": test = value
else: usage()
if host is None or test is None: usage()
func = get_func(test)
result = func(host)
nagios_return(result['code'], result['msg'])
3
View Complete Implementation : recipe-574459.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def parse_args(self, *args, **kwargs):
args = sys.argv[1:]
args0 = []
for p, v in zip(self.posargs, args):
args0.append("--%s" % p[0])
args0.append(v)
args = args0 + args
options, args = super(self.__clast__, self).parse_args(args, **kwargs)
if len(args) < len(self.posargs):
msg = 'Missing value(s) for "%s"\n' % ", ".join([arg[0] for arg in self.posargs][len(args):])
self.error(msg)
return options, args
3
View Complete Implementation : recipe-577008.py
Copyright MIT License
Author : ActiveState
Copyright MIT License
Author : ActiveState
def preloop(self):
'Setup the command prompt.'
self.prompt = '>>> '
self.intro = 'CS Profile Manager v2.1'
self.intro += '\n' + self.ruler * len(self.intro)
self.use_rawinput = False
self.cmdqueue.extend(sys.argv[1:])
try:
self.control = Profile_Manager('Profile.dat', 'save',
'Doukutsu.exe', 1478656, 260997856)
self.error = False
except Exception, reason:
self.reason = reason
self.error = True