예제 #1
0
파일: tester.py 프로젝트: bmewing/mit6034
def test_online(verbosity=1):
    lab = get_lab_module()

    try:
        server = xmlrpc.Server(server_url, allow_none=True)
        tests = server.get_tests(username, password, lab.__name__)
    except NotImplementedError:
        print("Your version of Python doesn't seem to support HTTPS, for")
        print("secure test submission.  Would you like to downgrade to HTTP?")
        print("(note that this could theoretically allow a hacker with access")
        print("to your local network to find your 6.034 password)")
        answer = input("(Y/n) >>> ")
        if len(answer) == 0 or answer[0] in "Yy":
            server = xmlrpc.Server(server_url.replace("https", "http"))
            tests = server.get_tests(username, password, lab.__name__)
        else:
            print("Ok, not running your tests.")
            print("Please try again on another computer.")
            print("Linux Athena computers are known to support HTTPS,")
            print("if you use the version of Python in the 'python' locker.")
            sys.exit(0)

    ntests = len(tests)
    ncorrect = 0

    lab = get_lab_module()

    target_dir = get_target_upload_filedir()

    tarball_data = get_tarball_data(target_dir,
                                    "lab%s.tar.bz2" % lab.LAB_NUMBER)

    print("Submitting to the 6.034 Webserver...")

    server.submit_code(username, password, lab.__name__,
                       xmlrpc.Binary(tarball_data))

    print("Done submitting code.")
    print("Running test cases...")

    for index, testcode in enumerate(tests):
        dispindex = index + 1
        summary = test_summary(dispindex, ntests)

        try:
            answer = run_test(testcode, get_lab_module())
        except Exception:
            show_exception(summary, testcode)
            continue

        correct, expected = server.send_answer(username, password,
                                               lab.__name__, testcode[0],
                                               answer)
        show_result(summary, testcode, correct, answer, expected, verbosity)
        if correct: ncorrect += 1

    response = server.status(username, password, lab.__name__)
    print(response)
    print("!! Please note that lab0 has no sever-side test cases.")
    print("You receive a 5 if you submit on-time.")
예제 #2
0
def gnuradio_stop_graph(host="localhost", port=8080):
    try:
        import xmlrpc
    except ImportError:
        print("xmlrpc is missing to use this function.")
    else:
        s = xmlrpc.Server("http://%s:%d" % (host, port))
        s.stop()
        s.wait()
예제 #3
0
    def __init__(self, auth=None, cainfo=None):

        self.auth = auth
        self.cainfo = cainfo
        self.errors = []
        self.trace = []
        self.calls = {}
        self.multicall = False
        self.url = ConfigEngine().manifold_url()
        self.server = xmlrpc.Server(self.url, verbose=False, allow_none=True)
예제 #4
0
def gnuradio_start_graph(host="localhost", port=8080):
    try:
        import xmlrpc
    except ImportError:
        print("xmlrpclib is missing to use this function.")
    else:
        s = xmlrpc.Server("http://%s:%d" % (host, port))
        try:
            s.start()
        except xmlrpc.Fault as e:
            print("ERROR: %s" % e.faultString)
예제 #5
0
def gnuradio_set_vars(host="localhost", port=8080, **kargs):
    try:
        import xmlrpc
    except ImportError:
        print("xmlrpc is missing to use this function.")
    else:
        s = xmlrpc.Server("http://%s:%d" % (host, port))
        for k, v in kargs.iteritems():
            try:
                getattr(s, "set_%s" % k)(v)
            except xmlrpc.Fault:
                print("Unknown variable '%s'" % k)
        s = None
예제 #6
0
def gnuradio_get_vars(*args, **kargs):
    if "host" not in kargs:
        kargs["host"] = "127.0.0.1"
    if "port" not in kargs:
        kargs["port"] = 8080
    rv = {}
    try:
        import xmlrpc
    except ImportError:
        print("xmlrpc is missing to use this function.")
    else:
        s = xmlrpc.Server("http://%s:%d" % (kargs["host"], kargs["port"]))
        for v in args:
            try:
                res = getattr(s, "get_%s" % v)()
                rv[v] = res
            except xmlrpc.Fault:
                print("Unknown variable '%s'" % v)
        s = None
    if len(args) == 1:
        return rv[args[0]]
    return rv
예제 #7
0
    contacts_filename = pdb_filename.replace(
        '.pdb', output_postfix + contacts_extension)
    rings_filename = pdb_filename.replace('.pdb', output_postfix + '.rings')
    ari_filename = pdb_filename.replace('.pdb', output_postfix +
                                        '.ari')  # ATOM-RING INTERACTIONS
    ri_filename = pdb_filename.replace('.pdb', output_postfix +
                                       '.ri')  # RING-RING INTERACTIONS
    amri_filename = pdb_filename.replace('.pdb', output_postfix +
                                         '.amri')  # AMIDE-RING INTERACTIONS
    amam_filename = pdb_filename.replace('.pdb', output_postfix +
                                         '.amam')  # AMIDE-AMIDE INTERACTIONS

    script_filename = pdb_filename.replace('.pdb', output_postfix + '.pml')

    if args.xml_rpc:
        srv = xmlrpc.Server('http://{}:{}'.format(host, port))

    do = None

    if args.script:

        final_output = ''

        def do(command):

            global final_output  # DON'T FORGET I EXIST!
            final_output = final_output + command + '\n'

    elif args.xml_rpc:
        do = srv.do