示例#1
0
def test_get_args(add_argument, ArgumentParser):
    ArgumentParser.return_value.add_argument = add_argument
    ArgumentParser.return_value.parse_args.return_value = []
    captured_return_value = get_args()
    ArgumentParser.assert_called_once_with(
        description="Historical Currency Converter")
    add_argument.assert_has_calls([
        mock.call(
            "-y",
            "--year",
            help=("The year in which you are interested in the currency "
                  "rate"),
            type=int,
            default=None,
        ),
        mock.call(
            "-m",
            "--month",
            help=("The month in which you are interested in the currency "
                  "rate (1-12)"),
            type=int,
            default=None,
        ),
        mock.call(
            "-c",
            "--currency",
            help="The three letter currency code (eg. AUD, BRL, JPY)",
            type=str,
            default=None,
        ),
    ])
    assert (captured_return_value ==
            ArgumentParser.return_value.parse_args.return_value)
示例#2
0
文件: andropy.py 项目: ccjj/andropy
def main(argv):
	#inserts in the config-constructor args.samplepath, args.interval, args.sdcard, args.outputpath, args.customconfig
	samplepath, interval, sdcard, outputpath, customconfig = argparser.get_args()#todo
	adbcommands.kill_blocking_processes()
	
	if adbcommands.other_emulator_online() == False: #no other device running
		config = create_and_config(samplepath, interval, sdcard, outputpath, False, False)
		machine = OnlineNotifierClass.OnlineNotifier(config.name, config.filedir, config.newavddir)
		machine.start_machine()
	else: #some other device is running
		config = create_and_config(samplepath, interval, sdcard, outputpath, False, True)
	start_online_timer()
	android = MachineClass.Device(config)
	android.start_dumping_process()
示例#3
0
def main(argv):
    #inserts in the config-constructor args.samplepath, args.interval, args.sdcard, args.outputpath, args.customconfig
    samplepath, interval, sdcard, outputpath, customconfig = argparser.get_args(
    )  #todo
    adbcommands.kill_blocking_processes()

    if adbcommands.other_emulator_online() == False:  #no other device running
        config = create_and_config(samplepath, interval, sdcard, outputpath,
                                   False, False)
        machine = OnlineNotifierClass.OnlineNotifier(config.name,
                                                     config.filedir,
                                                     config.newavddir)
        machine.start_machine()
    else:  #some other device is running
        config = create_and_config(samplepath, interval, sdcard, outputpath,
                                   False, True)
    start_online_timer()
    android = MachineClass.Device(config)
    android.start_dumping_process()
                mutates=mutations)
        if not success:
            print "Failed fuzzing of sudoku solver"
            return
        else:
            print "Sudoku solver passed all tests!"

if __name__ == '__main__':
    try:
        from argparser import get_args
    except ImportError:
        try:
            from optparser import get_args
        except ImportError:
            print """couldn't import an option parser. Run in interactive mode."""
    args_dict = get_args()
    import imp, os
    filepath = os.path.abspath(args_dict["solver_file"])
    mod_name, file_ext = os.path.splitext(os.path.split(filepath)[-1])
    if file_ext.lower() == '.py':
        user_mod = imp.load_source(mod_name, filepath)
    elif file_ext.lower() == ".pyc":
        user_mod = imp.load_compiled(mod_name, filepath)
    del args_dict["solver_file"]
    try:
        args_dict["check_sudoku"] = user_mod.check_sudoku
    except AttributeError:
        raise AttributeError("Module `{mod}` has no function"
                "`check_sudoku`".format(mod=mod_name))
    if args_dict["test"] in ("all", "solver"):
        try:
示例#5
0
from argparser import get_args
from inputs import get_year_input, get_month_input, get_currency_input
from rates import Rates

args = get_args()
rates = Rates()


def main():
    print("Welcome to the Historical Rate Calculator")
    year = args.year if args.year else get_year_input(rates)
    month = args.month if args.month else get_month_input(rates)
    currency = args.currency if args.currency else get_currency_input(rates)
    conversion_rate = rates.get_rate(year, month, currency)
    print(f"Conversion rate of {currency} to CAD: {conversion_rate}")


if __name__ == "__main__":
    main()
示例#6
0
    for press_release in press_releases:
        if weeks == -1 or (
            weeks != -1 and (now - press_release[1]) < (60 * 60 * 24 * 7 * weeks)
        ):
            print(press_release[3], "-", press_release[6])
            print(press_release[2], end="\n\n")
            if press_release[5] != []:
                print(press_release[5], end="\n\n")
            print("Link:", press_release[4])
            print("", end="\n")
            # print(press_release)
            print("----", end="\n" * 2)


if __name__ == "__main__":
    args = argparser.get_args()

    company_dict = {
        "goog": pagedata.alphabet,
        "aapl": pagedata.apple,
        "brk": pagedata.berkshire_hathaway,
        "fb": pagedata.facebook,
        "ilmn": pagedata.illumina,
        "jnj": pagedata.johnson_and_johnson,
        "lin": pagedata.linde,
        "msft": pagedata.microsoft,
        "nflx": pagedata.netflix,
        "nvda": pagedata.nvidia,
        "tsla": pagedata.tesla,
        "txn": pagedata.texas_instruments,
        "ul": pagedata.unilever,
示例#7
0
            return t.avg_score.current
    else:

        def do_test(*args, **kwargs):
            for batch in islice(t.main_lang_data.iter_test,
                                conf.max_eval_inst):
                sorted_len, sort_idx, tag_true = batch["token"][1:4]
                tag_pred, loss = model(batch, tag_true=tag_true)
                unsort_idx = torch.sort(sort_idx)[1]
                for l, true, pred in zip(sorted_len[unsort_idx],
                                         tag_pred[unsort_idx],
                                         tag_true[unsort_idx]):
                    t.score.add(pred[:l], true[:l])
            return t.score.current

    score = t.do_eval(do_test, eval_ds_name="test")
    if t.data.is_multilingual:
        avg_score = score
        lang_scores = t.score
        for lang, lang_score in lang_scores.items():
            t.log.info(f"{lang} score: {lang_score.current:.4}")
        t.log.info(f"avg score: {avg_score:.4}")
        return avg_score, lang_scores
    return score


if __name__ == "__main__":
    conf = get_args()
    conf.bpemb_lang = conf.lang
    globals()[conf.command.replace("-", "_")](conf)
示例#8
0
#! /bin/python3
# Copyright 2014 by Lasse Schuirmann, License: GPL v3

from argparser import get_args
import sys
from graph import RawGraph

__author__ = 'lasse'

if __name__ == "__main__":
    args = get_args()
    file = args.get('input')[0]

    val = args.get('recursion')
    if val is not None:
        sys.setrecursionlimit(val[0])
    else:
        sys.setrecursionlimit(10000)

    graph = RawGraph()
    graph.from_file(file)
    print("The maximum degree is {}.".format(graph.maximum_degree()))
    connected_components = graph.get_connected_components()
    print("There are {} connected components.".format(len(connected_components)))
    max_size = 0
    for elem in connected_components:
        max_size = max(max_size, len(elem))
    print("The maximum size of a component is {}.".format(max_size))

    val = args.get('distance')
    if val is not None:
示例#9
0
import os
import sys
from argparser import get_args
import readline


def get_input(process):
    inpt = raw_input("Cancel program?[Yn]\n")
    if inpt == "Y" or inpt == "Yes" or inpt == "y":
        process.kill()
    else:
        get_input(process)


selfpath = os.path.dirname(os.path.abspath(__file__))
volfilepath = selfpath + "/voltool/volprog.py"
get_args(sys.argv[1:])
androcmd = "python {}/andropy.py".format(selfpath)
argstring = ""
for s in sys.argv[1:]:
    argstring += " " + s
s = subprocess.Popen(["xterm", "-hold", "-e", androcmd + argstring])
get_input(s)
s.communicate()
print "Android dump-process closed"
print "Starting the volatility helping tool"
print volfilepath

volcmd = "python " + volfilepath
subprocess.Popen(["lxterminal", "-e", volcmd])

def stop_screen(screen):
    curses.echo()
    curses.nocbreak()
    screen.keypad(False)
    curses.endwin()


def exit_app(ecode, screen):
    stop_screen(screen)
    sys.exit(ecode)


if __name__ == '__main__':
    a = get_args()
    s = init_screen()
    g = GameController(a[0], a[1], a[2], s)
    try:
        curses.wrapper(g.play)
    except KeyboardInterrupt:
        exit_app(1, s)
    except curses.error:
        print("Please don't resize the window!")
        exit_app(1, s)
    except RuntimeError as e:
        print(str(e))
        exit_app(1, s)

    exit_app(0, s)
示例#11
0
import os
import sys
from argparser import get_args
import readline


def get_input(process):
    inpt = raw_input("Cancel program?[Yn]\n")
    if inpt == "Y" or inpt == "Yes" or inpt == "y":
        process.kill()
    else:
        get_input(process)


selfpath = os.path.dirname(os.path.abspath(__file__))
volfilepath = selfpath + '/voltool/volprog.py'
get_args(sys.argv[1:])
androcmd = 'python {}/andropy.py'.format(selfpath)
argstring = ""
for s in sys.argv[1:]:
    argstring += ' ' + s
s = subprocess.Popen(['xterm', '-hold', '-e', androcmd + argstring])
get_input(s)
s.communicate()
print "Android dump-process closed"
print "Starting the volatility helping tool"
print volfilepath

volcmd = 'python ' + volfilepath
subprocess.Popen(['lxterminal', '-e', volcmd])