コード例 #1
0
def main():
    parser = extargsparse.ExtArgsParse()
    parser = load_s_1(parser)
    parser = load_s_2(parser)
    parser.end_options()
    debug_total(parser)
    return
コード例 #2
0
ファイル: parser.py プロジェクト: jeppeter/py-coff
def main():
    commandline = '''
	{
		"verbose|v" : "+",
		"header<header_handler>" : {
			"$" : "+"
		},
		"optheader<optheader_handler>" : {
			"$" : "+"
		},
		"sections<sections_handler>" : {
			"$" : "+"
		},
		"symbols<symbols_handler>" : {
			"$" : "+"
		},
		"relocs<relocs_handler>" : {
			"$" : "+"
		},
		"all<all_handler>" : {
			"$" : "+"
		}
	}
	'''
    parser = extargsparse.ExtArgsParse()
    parser.load_command_line_string(commandline)
    parser.parse_command_line(None, parser)
    raise Exception('can not parse')
    return
コード例 #3
0
ファイル: releasetest.py プロジェクト: jeppeter/disttools
def main():
    outputfile_orig = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   'release.py')
    outputfile = slash_string(outputfile_orig)
    commandline_fmt = '''
		{
	        "verbose|v" : "+",
	        "failfast|f" : false,
	        "timewait|t" : 0.0,
	        "waitpid|w" : false,
	        "macros|m" : [],
	        "excludes|e" : [],
	        "repls|r" : [],
	        "cmdchanges|C" : [],        
			"release<release_handler>##release file##" : {
				"output|O" : "%s",
				"importnames|I" : ["debug_disttools_case"],
				"macros|M" : ["##handleoutstart","##handleoutend"]
			},
			"test<test_handler>##test mode##" : {
				"$" : "*"
			},
			"releasefile<releasefile_handler>" : {
				"$" : "+"
			}
		}
	'''
    commandline = commandline_fmt % (outputfile)
    options = extargsparse.ExtArgsOptions()
    parser = extargsparse.ExtArgsParse(options)
    parser.load_command_line_string(commandline)
    args = parser.parse_command_line()
    raise Exception('not supported subcommand[%s]' % (args.subcommand))
    return
コード例 #4
0
def main():
    global P
    commandline_fmt = '''
    {
        "verbose|v" : "+",
        "parsenum|P" : %s,
        "random|R" : -1,
        "times|t" : 256,
        "genkey<genkey_handler>" : {
            "$" : 2
        },
        "filter<filter_handler>" : {
            "$" : 3
        },
        "decrypt<decrypt_handler>" : {
            "$" : 2
        }
    }
    '''
    commandline = commandline_fmt % (P)
    parser = extargsparse.ExtArgsParse()
    parser.load_command_line_string(commandline)
    parser.parse_command_line(None, parser)
    raise Exception('unknown subcommand [%s]' % (args.subcommand))
    return
コード例 #5
0
def main():
	commandline='''
	{
		"verbose|v" : "+",
		"pair|p!optparse=pair_parse;opthelp=pair_help!" : [],
		"even|e!jsonfunc=single_2_jsonfunc!" : [],
		"clr_CA_name" : null,
		"$" : "*"
	}
	'''
	options = extargsparse.ExtArgsOptions()
	options.longprefix = '++'
	options.shortprefix = '+'
	options.jsonlong = 'jsonfile'
	options.helplong = 'usage'
	options.helpshort = '?'
	options.flagnochange = True
	parser = extargsparse.ExtArgsParse(options)
	parser.load_command_line_string(commandline)
	args = parser.parse_command_line()
	print('verbose [%d]'%(args.verbose))
	print('pair (%s)'%(args.pair))
	print('args (%s)'%(args.args))
	print('clr_CA_name (%s)'%(args.clr_CA_name))
	print('event (%s)'%(args.even))
	return
コード例 #6
0
ファイル: __main_debug__.py プロジェクト: jeppeter/insertcode
def main():
    commandline='''
    {
        "verbose|v" : "+",
        "input|i##default (stdin)##" : null,
        "output|o##default (stdout)##": null,
        "pattern|p" : "%REPLACE_PATTERN%",
        "bashinsert<bashinsert_handler>" : {
            "$" : "*"
        },
        "bashstring<bashstring_handler>" : {
            "$" : "*"
        },
        "makepython<makepython_handler>" : {
            "$" : "*"
        },
        "makeperl<makeperl_handler>" : {
            "$" : "*"
        },
        "shperl<shperl_handler>" : {
            "$" : "*"
        },
        "shpython<shpython_handler>" : {
            "$" : "*"
        },
        "pythonperl<pythonperl_handler>" : {
            "$" : "*"
        },
        "pythonc<pythonc_handler>" : {
            "$" : "*"
        },
        "version<version_handler>" : {
            "$" : 0
        },
        "bz2base64<bz2base64_handler>" : {
            "$" : 1
        },
        "bz2base64mak<bz2base64mak_handler>" : {
            "$" : 1
        },
        "pshcmdline<pshcmdline_handler>" : {
            "$" : "*"
        },
        "pshcmdlinetoc<pshcmdlinetoc_handler>" : {
            "$" : "*"
        }

    }
    '''
    options = extargsparse.ExtArgsOptions('{ "version" : "VERSION_RELACE_STRING"}')
    parser = extargsparse.ExtArgsParse()
    parser.load_command_line_string(commandline)
    args = parser.parse_command_line(None,parser)
    sys.stderr.write('no handler specified')
    sys.exit(4)
    return
コード例 #7
0
ファイル: first.py プロジェクト: jeppeter/extargsparse
def main():
    parser = extargsparse.ExtArgsParse(usage=' sample commandline parser ')
    parser.load_command_line_string(commandline)
    args = parser.parse_command_line()
    print('verbose = %d' % (args.verbose))
    print('flag = %s' % (args.flag))
    print('number = %d' % (args.number))
    print('list = %s' % (args.list))
    print('string = %s' % (args.string))
    print('args = %s' % (args.args))
コード例 #8
0
ファイル: char_exp.py プロジェクト: jeppeter/ctf2017
def main():
    commandline = '''
    {
        "verbose|v" : "+",
        "genkey<genkey_handler>" : {
            "$" : 2
        }
    }
    '''
    parser = extargsparse.ExtArgsParse()
    parser.load_command_line_string(commandline)
    parser.parse_command_line(None, parser)
    raise Exception('unknown subcommand [%s]' % (args.subcommand))
    return
コード例 #9
0
ファイル: tstfunc.py プロジェクト: jeppeter/extargsparse4sh
def main():
    commandline = '''
    {
        "verbose|v" : "+",
        "testfindline<testfindline_handler>##restr num instr##"  : {
            "$" : 3
        }
    }
    '''
    parser = extargsparse.ExtArgsParse()
    parser.load_command_line_string(commandline)
    args = parser.parse_command_line(None, parser)
    raise Exception("[%s] not supported" % (args.subcommand))
    return
コード例 #10
0
def main():
	commandline='''
	{
		"verbose|v" : "+",
		"input|i" : null,
		"clean<clean_handler>" : {
			"$" : 0
		}
	}
	'''
	parser = extargsparse.ExtArgsParse()
	parser.load_command_line_string(commandline)
	parser.parse_command_line(None,parser)
	raise Exception('can not return')
	return
コード例 #11
0
ファイル: pyinsert.py プロジェクト: jeppeter/disttools
def main():
	commandline='''
	{
		"verbose|v" : "+",
		"pattern|p" : "%REPLACE_PATTERN%",
		"input|i" : null,
		"output|o" : null,
		"pythonpython<pythonpython_handler>" : {
			"$" : "*"
		}
	}
	'''
	parser = extargsparse.ExtArgsParse()
	parser.load_command_line_string(commandline)
	args = parser.parse_command_line(None,parser)
	raise Exception('[%s] not supported'%(args.subcommand))
	return
コード例 #12
0
ファイル: diffdir.py プロジェクト: jeppeter/insertcode
def main():
	commandline='''
	{
		"verbose|v" : "+"
	}
	'''
	parser = extargsparse.ExtArgsParse()
	parser.load_command_line_string(commandline)
	args = parser.parse_command_line()
	set_log_level(args)
	i = 0
	argc = len(args.args)
	d = DiffDir()
	while i < (argc -1):
		cfs = d.dircompare(args.args[i], args.args[i+1])
		logging.info('cfs %s'%(repr(cfs)))
		i += 2
	return
コード例 #13
0
def main():
    commandline = '''
	{
		"verbose|v" : "+",
		"time|t" : 0.0,
		"pid|p" : false,
		"$" : "*"
	}
	'''
    parser = extargsparse.ExtArgsParse()
    parser.load_command_line_string(commandline)
    args = parser.parse_command_line()
    if args.pid and len(args.args) > 2:
        args.args.insert(2, '%d' % (os.getpid()))
        args.args.insert(2, '--pid')
    run_cmd(args.args)
    if (args.time - 0.0) > 0.0001:
        time.sleep(args.time)
    sys.exit(0)
    return
コード例 #14
0
ファイル: testsh.py プロジェクト: jeppeter/extargsparse4sh
def main():
    global shell_env_string
    global shell_verbose_mode
    commandline='''
    {
        "verbose|v" : "+",
        "longopt|l" : null,
        "shortopt|s" : null,
        "varname|V" : null,
        "optdest|o" : null,
        "envfile|e" : null,
        "validx|i" : 0,
        "shellfunc|S" : null,
        "type|t" : null,
        "$" : "*"
    }
    '''
    parser = extargsparse.ExtArgsParse()
    parser.load_command_line_string(commandline)
    args = parser.parse_command_line()
    set_log_level(args)
    logging.info('args (%s)'%(args))
    argsopt = extargsparse.ExtArgsOptions()
    keycls = extargsparse.ExtArgsOptions()
    keycls.type = args.type
    keycls.longopt = args.longopt
    keycls.optdest = args.optdest
    keycls.shortopt = args.shortopt
    keycls.varname = args.varname
    keycls.attr = extargsparse.ExtArgsOptions()
    keycls.attr.optparse = 'shell_optparse'
    keycls.attr.shellfunc = args.shellfunc
    shell_env_string = get_env_string(read_file(args.envfile))
    shell_verbose_mode = args.verbose
    random.seed(os.getpid())
    logging.info('keycls [%s]'%(keycls))
    idx = args.validx
    while (idx ) < len(args.args):
        nret = shell_optparse(argsopt,idx,keycls,args.args)
        idx += nret
    return
コード例 #15
0
def main():
    commandline = '''
	{
		"verbose|v" : "+",
		"excludes|E" : [],
		"input|i" : null,
		"pattern|P" : null,
		"output|o" : null,
		"checkmethod|c" : [],
		"macro|m" : [],
		"cmdchg|C" : [],
		"replace|r" : [],
		"$" : "*"
	}
	'''
    parser = extargsparse.ExtArgsParse()
    parser.load_command_line_string(commandline)
    args = parser.parse_command_line()
    set_log_level(args)
    output_handler(args)
    return
コード例 #16
0
def main():
    outputfile_orig = os.path.join(os.path.dirname(os.path.abspath(__file__)),
                                   'release.py')
    outputfile = slash_string(outputfile_orig)
    commandline_fmt = '''
		{
			"verbose|v" : "+",
			"failfast|f" : false,
			"release<release_handler>##release file##" : {
				"output|O" : "%s",
				"importnames|I" : ["debug_args_function","debug_tcebase","debug_set_2_args", "Debug_set_2_args","debug_upper_jsonfunc","debug_2_jsonfunc","debug_opthelp_set","debug_extargs_test_case","_LoggerObject"],
				"adds|A" : ["ExtArgsParse","ExtArgsOptions","set_attr_args","SUB_COMMAND_JSON_SET","COMMAND_JSON_SET","ENVIRONMENT_SET","ENV_SUB_COMMAND_JSON_SET","ENV_COMMAND_JSON_SET"]
			},
			"test<test_handler>##test mode##" : {
				"$" : "*"
			}
		}
	'''
    commandline = commandline_fmt % (outputfile)
    options = extargsparse.ExtArgsOptions()
    parser = extargsparse.ExtArgsParse(options)
    parser.load_command_line_string(commandline)
    args = parser.parse_command_line()
    return
コード例 #17
0
ファイル: echo.py プロジェクト: jeppeter/insertcode
def main():
    commandline_fmt = '''
    {
        "verbose|v" : "+",
        "version|V" : false,
        "win32|W" : false,
        "output|o" : null,
        "times|T" : 0,
        "dump|D" : null,
        "includes|I" : [],
        "includefiles" : [],
        "unpatchfunc|U" : "unpatch_handler",
        "cob<cob_handler>##srcdir dstdir to obfuscated code in c mode##" : {
            "handles" : ["\\\\.c$","\\\\.h$","\\\\.cpp$","\\\\.cxx$"],
            "filters" : ["\\\\.git$"],
            "config" : null,
            "dump" : null,
            %s,
            "$" : "+"
        },
        "makob<makob_handler>##srcfile to give the other code file ,this need environment variable MAKOB_FILE to get the default (makob.json)##" : {
            "namemin" : 5,
            "namemax" : 20,
            "$" : "+"
        },
        "unmakob<unmakob_handler>##dstfile to give the origin ,this need environment variable MAKOB_FILE to get the default (makob.json)##" : {
            "short" : false,
            "$" : "+"
        },
        "basename<basename_handler>##to make basename##" : {
            "$" : "+"
        },
        "obtrans<obtrans_handler>##translate the srcdir to dstdir in makob file##" : {
            "srcdir" : "",
            "dstdir" : "",
            "$" : "+"
        },
        "oblist<oblist_handler>##to list files ob files##" : {
            "$" : "*"
        },
        "obuntrans<obuntrans_handler>##inputfile [outputfile] to trans file from MAKOB_FILE##" : {
            "$" : "+"
        },
        "obunpatchelf<obunpatchelf_handler>##objfilename:func1,func2 ... to format unpatch elf file with func1 func2##" : {
            "$" : "+",
            "loglvl" : 3
        },
        "obpatchelf<obpatchelf_handler>##inputfile to patch elf functions##" : {
            "$" : "+"
        },
        "obunpatchcoff<obunpatchcoff_handler>##objfile:func1,func2 ... to format unpatch coff file with func1 func2##" : {
            "$" : "+",
            "loglvl" : 3
        },
        "obpatchpe<obpatchpe_handler>##inputfile to patch pe functions##" : {
            "$" : "+"
        },
        "obunfunc<obunfunc_handler>##funcs... to set obfuncs##" : {
            "$" : "+"
        },
        "obunpatchelfforge<obunpatchelfforge_handler>##objfilename:func1,func2 ... to format unpatch elf file with func1 func2##" : {
            "$" : "+",
            "loglvl" : 3
        },
        "obpatchelfforge<obpatchelfforge_handler>##inputfile to no handle##" : {
            "$" : "+"
        },
        "obreunpatchelf<obreunpatchelf_handler>##objfiles ... to replay unpatchelf##" : {
            "$" : "+"
        },
        "obrepatchelf<obrepatchelf_handler>##objfiles ... to replay patchelf##" : {
            "$" : "+"
        },
        "obreunpatchcoff<obreunpatchcoff_handler>##objfiles ... to replay unpatchelf##" : {
            "$" : "+"
        },
        "obrepatchpe<obrepatchpe_handler>##objfiles ... to replay patchelf##" : {
            "$" : "+"
        }
    }
    '''
    commandline = commandline_fmt % (format_cob_config(4))
    d = dict()
    d['version'] = "VERSION_RELACE_STRING"
    options = extargsparse.ExtArgsOptions(d)
    parser = extargsparse.ExtArgsParse(options)
    parser.load_command_line_string(commandline)
    args = parser.parse_command_line(None, parser)
    if args.version:
        sys.stdout.write('%s\n' % (options.version))
        sys.exit(0)
    raise Exception('can not support command [%s]' % (args.subcommand))
    return
コード例 #18
0
ファイル: total.py プロジェクト: jeppeter/extargsparse
def main():
	commandline= '''
	{
		"verbose|v" : "+",
		"+http" : {
			"url|u" : "http://www.google.com",
			"visual_mode|V": false
		},
		"$port|p" : {
			"value" : 3000,
			"type" : "int",
			"nargs" : 1 , 
			"helpinfo" : "port to connect"
		},
		"dep" : {
			"list|l" : [],
			"string|s" : "s_var",
			"$" : "+"
		}
	}
	'''
	jsonfile = None
	depjsonfile = None
	try:
		depstrval = 'newval'
		depliststr = '["depenv1","depenv2"]'
		deplistval = eval(depliststr)
		httpvmstr = "True"
		httpvmval = eval(httpvmstr)
		fd,jsonfile = tempfile.mkstemp(suffix='.json',prefix='parse',dir=None,text=True)
		os.close(fd)
		fd = -1
		fd ,depjsonfile = tempfile.mkstemp(suffix='.json',prefix='parse',dir=None,text=True)
		os.close(fd)
		fd = -1
		with open(jsonfile,'w+') as f:
			f.write('{ "http" : { "url" : "http://www.yahoo.com"} ,"dep":{"list" : ["jsonval1","jsonval2"],"string" : "jsonstring"},"port":6000,"verbose":3}\n')
		with open(depjsonfile,'w+') as f:
			f.write('{"list":["depjson1","depjson2"]}\n')
		delone = True
		while delone:
			delone = False
			for k in os.environ.keys():
				if k.startswith('EXTARGS_') or k.startswith('DEP_') or k == 'EXTARGSPARSE_JSON' or k.startswith('HTTP_'):
					del os.environ[k]
					delone = True
					break

		os.environ['EXTARGSPARSE_JSON'] = jsonfile
		os.environ['DEP_JSON'] = depjsonfile
		options = extargsparse.ExtArgsOptions()
		parser = extargsparse.ExtArgsParse()
		parser.load_command_line_string(commandline)
		os.environ['DEP_STRING'] = depstrval
		os.environ['DEP_LIST'] = depliststr
		os.environ['HTTP_VISUAL_MODE']=httpvmstr
		
		args = parser.parse_command_line(['-p','9000','dep','--dep-string','ee','ww'])
		assert( args.verbose == 3 )
		assert( args.port == 9000 )
		assert( args.dep_list == ['depenv1', 'depenv2'] )
		assert( args.dep_string == 'ee')
		assert( args.http_visual_mode )
		assert( args.http_url == 'http://www.yahoo.com')
		assert( args.subcommand == 'dep' )
		assert( args.subnargs == ['ww'] )
		print('args.verbose %d'%(args.verbose))
		print('args.port %d'%(args.port))
		print('args.dep_list %s'%(args.dep_list))
		print('args.dep_string %s'%(args.dep_string))
		print('args.http_visual_mode %s'%(args.http_visual_mode))
		print('args.http_url %s'%(args.http_url))
		print('args.subcommand %s'%(args.subcommand))
		print('args.subnargs %s'%(args.subnargs))
	finally:
		if depjsonfile is not None:
			os.remove(depjsonfile)
		depjsonfile = None
		if jsonfile is not None:
			os.remove(jsonfile)
		jsonfile = None
		if 'EXTARGSPARSE_JSON' in os.environ.keys():
			del os.environ['EXTARGSPARSE_JSON']
		if 'DEP_JSON' in os.environ.keys():
			del os.environ['DEP_JSON']
	return