Beispiel #1
0
def run_server():
    _parse_opt()
    global _options, _use_ipv6, _port
    conf.parse_file(_options.conf_file)

    if not _options.no_daemon and conf.is_unix:
        daemon.daemon_start()

    daemon.pid_start()

    try:
        s = snc.socket(None, _port)
    except snc.Error:
        daemon.pid_end()

    log.info("orzoj-server started, listening on {0}".format(_port))

    threading.Thread(target=work.thread_work, name="work.thread_work").start()

    while not control.test_termination_flag():
        try:
            (conn, addr) = s.accept(1)
        except snc.ErrorTimeout:
            continue
        except snc.Error as e:
            control.set_termination_flag()
            break

        log.info("connected by {0!r}".format(addr))
        work.thread_new_judge_connection(conn).start()

    s.close()
    while threading.active_count() > 1:
        log.debug("waiting for threads, current active count: {0}".format(
            threading.active_count()))
        for i in threading.enumerate():
            log.debug("active thread: {0!r}".format(i.name))
        time.sleep(1)

    daemon.pid_end()
Beispiel #2
0
def run_judge():
    _parse_opt()
    global _options, _server_addr, _server_port, _pid_file

    conf.parse_file(_options.conf_file)

    if not _options.no_daemon and conf.is_unix:
        daemon.daemon_start()

    daemon.pid_start()

    try:
        s = snc.socket(_server_addr, _server_port)
    except snc.Error:
        daemon.pid_end()

    try:
        work.connect(s)
    except work.Error:
        log.error("error occurred, terminating program")

    daemon.pid_end()
Beispiel #3
0
#!/usr/bin/env python
from orzoj import snc, conf

conf.parse_file("test-snc-client.conf")

HOST = '127.0.0.1'
PORT = 9351

s = snc.socket(HOST, PORT)

ss = snc.snc(s)

ss.write_str(raw_input("Please enter the message:"))
print "Received: {0!r}".format(ss.read_str())

ss.close()
s.close()
#!/usr/bin/env python
import sys
from orzoj import snc, conf, filetrans

if len(sys.argv) != 2:
    sys.exit("usage: %s <file saving path>" % sys.argv[0])

conf.parse_file("test-snc-server.conf")

PORT = 9351
s = snc.socket(None, PORT)
(conn, addr) = s.accept()
print 'Connected by', addr
ss = snc.snc(conn, True)

print "speed: {0}" . format(filetrans.recv(sys.argv[1], ss))

ss.close()
conn.close()
s.close()

Beispiel #5
0
#!/usr/bin/env python

from orzoj.judge import limiter
from orzoj import conf

conf.parse_file("test-limiter.conf")

l = limiter.limiter_dict["default"]

for i in range(2):

    with open("prog.in", "r") as f:
        l.run({"TARGET" : ["./prog", "arg1", "arg2"]}, stdin = f,
                stdout = limiter.SAVE_OUTPUT, stderr = limiter.NULL)

    print "l.stdout={0!r}\nl.stderr={1!r}".format(l.stdout, l.stderr)

    print "execution status:", l.exe_status
    print "time: {0} [sec]" .format(l.exe_time * 1e-6)
    print "mem: {0} [kb]" . format(l.exe_mem)
    print "extra infomation: {0!r}" . format(l.exe_extra_info)