本文整理汇总了Python中sys.argv.append函数的典型用法代码示例。如果您正苦于以下问题:Python append函数的具体用法?Python append怎么用?Python append使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了append函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: make_dists
def make_dists():
prebuilt_platform_root = path.join("dtls", "prebuilt")
for platform in listdir(prebuilt_platform_root):
config = {"MANIFEST_DIR": path.join(prebuilt_platform_root, platform)}
execfile(path.join(prebuilt_platform_root, platform, "manifest.pycfg"),
config)
files = map(lambda x: "dtls/prebuilt/" + platform + "/" + x,
config["FILES"])
argv.append("--formats=" + config["FORMATS"])
invoke_setup([('dtls', files)])
del argv[-1]
for dist_format in config["FORMATS"].split(','):
source_name = path.join(DIST_DIR,
NAME + "-" + VERSION +
FORMAT_TO_SUFFIX[dist_format])
target_name = path.join(DIST_DIR,
NAME + "-" + VERSION +
".sdist_with_openssl." +
config["ARCHITECTURE"] +
FORMAT_TO_SUFFIX[dist_format])
try:
remove(target_name)
except OSError:
pass
rename(source_name, target_name)
# Finally the distribution without prebuilts
argv.append("--formats=zip,gztar")
invoke_setup()
示例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)
示例3: 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()
示例4: _parse_args
def _parse_args(self):
# display help per default:
if len(argv) == 1:
argv.append("-h")
args = self.arg_parser.parse_args()
self.args = args
if args.verbose:
logging.getLogger().setLevel(logging.INFO)
示例5: launch
def launch(module, includes ,files, out = None, multiple = None):
import sys
from sys import argv
from copy import copy, deepcopy
del argv[1:]
argv.extend(default_defines)
argv.extend(map(lambda include : '-I%s' % include, includes))
argv.append('--module=%s' % module)
if out == None:
out = module
argv.append('--out=%s' % out)
if multiple:
argv.append('--multiple')
argv_saved = copy(argv)
argv.extend(files)
print argv
from os import system
def makecmd():
import string
return ('python -c "from Pyste import pyste; pyste.main()" '
+ string.join(argv[1:], ' '))
system(makecmd())
argv = argv_saved
if multiple:
argv.append('--generate-main')
argv.extend(files)
print 'generating main'
system(makecmd())
示例6: 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)
示例7: print
from pyd.support import Extension
from pyd.support import setup
from pyd import patch_distutils
from sys import argv
if argv[-1] == "opt":
print("building with optimalization")
argv.pop()
argv.append("build")
argv.append("-c")
argv.append("ldc2")
argv.append("-O")
else: argv.append("build")
projName = 'dbindings'
sources = ['dbindings.d',
'ea/ea_config.d',
'ea/population.d',
'ea/individual.d',
'ea/beer_tracker_individual.d',
'ea/beer_tracker_population.d',
'flatland/flatland_agent.d',
'flatland/flatland_simulator.d',
'flatland/flatland_evolve.d',
'ann/ann.d',
'ann/matrix.d',
'ann/ann_config.d',
'ann/ctrnn.d',
示例8: myhash
inner_hash = myhash(s[1:])
wat = s[0]
return ((ord(wat)<<31)+(ord(wat)<<3)-(ord(wat)+1)+(inner_hash<<5)+(inner_hash>>5))&(0xffffffff)
def get_battery_level():
level = -1
try:
with open("/sys/class/power_supply/BAT0/uevent","r") as f:
uevent_contents = f.read()
property_list = [tuple(x.split("=")) for x in uevent_contents.split("\n") if len(x.split("="))==2]
properties = dict(property_list)
level = int(properties['POWER_SUPPLY_CHARGE_NOW'])*100/int(properties['POWER_SUPPLY_CHARGE_FULL'])
except Exception as e:
level = -1
return min(level,100)
if len(argv)<2:
argv.append("test")
color = (myhash(argv[1]))%16
color_upper = int(color/8)
color_lower = int(color%8)
stdout.write("\033[%d;3%dm%s"%(color_upper,color_lower,argv[1]))
if argv[1]=="clamps": # Battery monitoring on laptop
battery_level = get_battery_level()
stdout.write("(%3d"%battery_level+"%%)") # percent signs are filtered by zsh
示例9: raise
return 0
except KeyboardInterrupt:
### handle keyboard interrupt ###
return 0
except Exception as e:
if DEBUG:
raise(e)
pass
indent = len(program_name) * " "
from sys import stderr
stderr.write(program_name + ": " + repr(e) + "\n")
stderr.write(indent + " for help use --help")
return 2
pass
if __name__ == "__main__":
if DEBUG:
from sys import argv
argv.append("-n 700")
argv.append("--minimizer=Powell")
argv.append("--clf-params={'learning_rate': 0.05, 'min_child_weight': 240, 'subsample': 0.9, 'colsample_bytree': 0.67, 'max_depth': 6, 'initial_params': [0.1, -1, -2, -1, -0.8, 0.02, 0.8, 1]}")
argv.append("-f 10")
pass
from sys import exit as Exit
Exit(main())
pass
示例10: looper
self.close()
os.system("gui_interaction.py restart")
def looper(self):
while True:
time.sleep(1)
self.updateSig.emit()
def vaultlooper(self):
while True:
time.sleep(3)
self.vaultSig.emit()
if __name__ == '__main__':
argv.append("building")
app = QApplication(argv)
if "restart" not in argv and "building" not in argv:
os.system("commands\\minimize.bat")
ss = QSplashScreen(QPixmap("images/splash.png"))
ss.show()
ss.showMessage("Loading Components", alignment=Qt.AlignBottom|Qt.AlignHCenter, color=Qt.white)
mp = gui_interaction()
time.sleep(2)
ss.showMessage("Initialising Components", alignment=Qt.AlignBottom|Qt.AlignHCenter, color=Qt.white)
time.sleep(3)
ss.showMessage("Finished Loading. Welcome to MagPy.", alignment=Qt.AlignBottom|Qt.AlignHCenter, color=Qt.white)
time.sleep(1)
mp.show()
ss.hide()
else:
示例11:
print "LISTE: impacchettamento, spacchettamento; accessibilita', inizializzazione tramite indicizzazione"
lista0 = [1, 4, 5]
print "Se si puo' impacchettare & accedere a una lista tramite indicizzazione, qui di seguito deve comparire il numero 4: ", lista0[1]
(pippo, pluto, paperino) = lista0
print "Se si puo' spacchettare una lista, qui di seguito deve comparire la serie 1 4 5: ", pippo, pluto, paperino
lista1 =[pippo, pluto, paperino]
lista1[0] =5
print "Se si puo' inizializzare una lista tramite indicizzazione, qui di seguito deve comparire una lista: ", lista1
print "\n-----------------------------------------------------------"
print "ARGV: qui testo se vari elementi visti finora sono o meno delle tuple"
argv.append(5)
print "Se sys.argv e' una lista, allora qui di seguito deve essere mostrata una lista contenente il nome dello script seguito dagli argomenti passati allo script e infine dal numero 5", argv
print "\n-----------------------------------------------------------"
print "DICTIONARY"
dic1 = {'a':1, 2:2, 'c':'a'}
key = 'c'
elem = dic1[key]
print "\nIl valore associato alla chiave \'%s\' e': " % key, elem
print "La seguente stampa del dizionario mostra come key e value possano essere insiemi eterogenei: ", dic1
dic2={'Panda':(1, 4), 5:'Foca'}
dic1['a']=dic2
print "La seguente stampa del dizionario mostra come i dizionari possano essere annidabili: ", dic1
示例12:
# help="snpEff output file", default=None)
# grab options and arguments in an usable form
#parser.add_option("-l", dest="log_file",
# help="Optional log file", default=None)
#parser.add_option("-o", dest="out_prefix",
# help="Prefix for output files", default=None)
parser.add_argument("-l", dest="log_file",
help="Optional log file", default=None)
parser.add_argument("-o", dest="out_prefix",
help="Prefix for output files", default=None)
if not argv[1:] :
argv.append('-h')
prog_name = os.path.basename(argv[0])
args = parser.parse_args()
#print options
if not args.vcf_file :
parser.error("\nvcf file missing.")
else :
if not os.access(args.vcf_file, os.R_OK):
parser.error("Unable to read vcf file %s " %args.vcf_file)
if not args.out_prefix :
out_snp = args.vcf_file[:-4]+".snp"
out_indel = args.vcf_file[:-4]+".indel"
示例13: mode
#!/usr/bin/env python
import re
from sys import argv, stdout, stderr, exit, modules
from optparse import OptionParser
# import ROOT with a fix to get batch mode (http://root.cern.ch/phpBB3/viewtopic.php?t=3198)
argv.append("-b-")
import ROOT
ROOT.gROOT.SetBatch(True)
argv.remove("-b-")
from HiggsAnalysis.CombinedLimit.DatacardParser import *
from HiggsAnalysis.CombinedLimit.ModelTools import *
from HiggsAnalysis.CombinedLimit.ShapeTools import *
from HiggsAnalysis.CombinedLimit.PhysicsModel import *
parser = OptionParser(usage="usage: %prog [options] datacard.txt -o output \nrun with --help to get list of options")
addDatacardParserOptions(parser)
parser.add_option(
"-P",
"--physics-model",
dest="physModel",
default="HiggsAnalysis.CombinedLimit.PhysicsModel:defaultModel",
type="string",
help="Physics model to use. It should be in the form (module name):(object name)",
)
parser.add_option(
"--PO",
"--physics-option",
dest="physOpt",
示例14: SupervisedDataSet
samples = SupervisedDataSet(3,1)
for i in data_transformed_training:
samples.addSample(i['past'], i['next'] - i['average'])
trainer = BackpropTrainer(net, samples)
print 'Training'
trainer.trainUntilConvergence(maxEpochs= 10)
#Comparing step-------------------------------------------------------------------
print 'Naive1'
aux = map(lambda y: y['past'], data_transformed)
aux2 = map(lambda y: y['next']-y['average'], data_transformed)
compare_forecast_samples(Forecaster(predict_function = lambda x: aux2[aux.index(x)-1]), data_transformed)
print 'Network'
compare_forecast_samples(Forecaster(predict_function = net.activate), data_transformed)
print "Number of samples %d for training." %len(data_transformed_training)
if __name__ == '__main__':
from sys import argv
if len(argv) < 2:
'''Usage python %s [name_of_samples_file]''' %argv[0]
argv.append('readings_27_04_12_15h22m53s.txt')
print 'Working over', argv[1]
#from pybrain.tools.shortcuts import buildNetWork
main(argv[1])
示例15: getCompressionInfo
def getCompressionInfo(inputText,codeMap):
''' Return a Tuple containing the original number of bits, the final number of bits, and the compression ratio.'''
codedSum=0
for char in inputText:
codedSum=codedSum+len(codeMap[char])
startSize=len(inputText)*8
endSize=codedSum
ratio=float(startSize)/endSize
return (startSize,endSize,ratio)
def printCodeInfo(inputText,codeMap):
print 'Code Map:'
printCode(codeMap)
rawSize,compressedSize,ratio=getCompressionInfo(inputText,codeMap)
print 'Original Size(bits):',rawSize,', Compressed Size(bits):',compressedSize,', Compression Ratio:',ratio
if(len(argv)>2):
print 'expecting one argument'
exit()
elif(len(argv)==1):
argv.append('InputOutput.txt')
inputFile=open(argv[1],'r')
inputText=inputFile.read()
codeMap,codeTree=huffman.getCodeFromText(inputText)
huffmanCoder=huffman.HuffmanCoder(codeMap,codeTree)
pickleFile=open('huffmanCode','w')
pickle.dump(huffmanCoder,pickleFile)
pickleFile.close()