Beispiel #1
0
def main(argv=sys.argv[1:]):
    """
    This is the lantorrent daemon program.  it mines the db for transfers
    that it can group together and send.  Only one should be running at 
    one time
    """

    pylantorrent.log(logging.INFO, "enter %s" % (sys.argv[0]))

    # use sqlaclh to make sure the db is there
    x = LantorrentDB("sqlite:///%s" % pylantorrent.config.dbfile)
    x.close()
    con_str = pylantorrent.config.dbfile
    #con = sqlite3.connect(con_str, isolation_level="EXCLUSIVE")
    con = sqlite3.connect(con_str, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)

    done = False
    while not done:
        try:
            rows = getrows(con)
            if rows and len(rows) > 0:
                do_it_live(con, rows)
            else:
                time.sleep(5)
        except Exception, ex:
            pylantorrent.log(logging.ERROR, "top level error %s" % (str(ex)), traceback)
            con = sqlite3.connect(con_str, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
Beispiel #2
0
def main(argv=sys.argv[1:]):
    """
    This is the lantorrent daemon program.  it mines the db for transfers
    that it can group together and send.  Only one should be running at 
    one time
    """

    pylantorrent.log(logging.INFO, "enter %s" % (sys.argv[0]))

    # use sqlaclh to make sure the db is there
    x = LantorrentDB("sqlite:///%s" % pylantorrent.config.dbfile)
    x.close()
    con_str = pylantorrent.config.dbfile
    #con = sqlite3.connect(con_str, isolation_level="EXCLUSIVE")
    con = sqlite3.connect(con_str, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)

    done = False
    while not done:
        try:
            rows = getrows(con)
            if rows and len(rows) > 0:
                do_it_live(con, rows)
            else:
                time.sleep(5)
        except Exception, ex:
            pylantorrent.log(logging.ERROR, "top level error %s" % (str(ex)))
            con = sqlite3.connect(con_str, detect_types=sqlite3.PARSE_DECLTYPES|sqlite3.PARSE_COLNAMES)
Beispiel #3
0
def main(argv=sys.argv[1:]):
    """
    This program allows a file to be requested from the lantorrent system.  The
    file will be sent out of band.  When the file has been delived the 
    database entry for this request will be updated.  This program will
    block until that entry is update.

    As options, the program takes the source file, the
    target file location, the group_id and the group count.

    The lantorrent config file must have the ip and port that the requester
    is using for lantorrent delivery.
    """

    pylantorrent.log(logging.INFO, "enter")
    random.seed()

    (o, args, p) = setup_options(argv)

    # use sqlaclh to make sure the db is there
    x = LantorrentDB("sqlite:///%s" % pylantorrent.config.dbfile)
    x.close()

    con_str = pylantorrent.config.dbfile
    con = sqlite3.connect(con_str, isolation_level="EXCLUSIVE")

    rc = 0
    sz = -1
    done = False
    message = ""
    if o.reattach is None:
        (rid, sz) = request(args, con)
        try:
            (done, rc, message) = is_done(con, rid)
        except:
            done = False
            rc = 0
            message = "Check on status later, db not ready for polling"
    else:
        rid = o.reattach
        if o.cancel:
            delete_rid(con, rid)
            return 0

        (done, rc, message) = is_done(con, rid)

    if not o.nonblock and not done:
        (rc, message) = wait_until_sent(con, rid)
        done = True

    if done:
        delete_rid(con, rid)

    msg = "%d,%s,%s" % (rc, str(done), message)
    print msg

    # always return 0 if we echo the rc to stdout.  this tells the
    # user to check the output for the real rc
    return 0
Beispiel #4
0
def main(argv=sys.argv[1:]):
    """
    This program allows a file to be requested from the lantorrent system.  The
    file will be sent out of band.  When the file has been delived the 
    database entry for this request will be updated.  This program will
    block until that entry is update.

    As options, the program takes the source file, the
    target file location, the group_id and the group count.

    The lantorrent config file must have the ip and port that the requester
    is using for lantorrent delivery.
    """

    pylantorrent.log(logging.INFO, "enter")
    random.seed()

    (o, args, p) = setup_options(argv)

    # use sqlaclh to make sure the db is there
    x = LantorrentDB("sqlite:///%s" % pylantorrent.config.dbfile)
    x.close()
    
    con_str = pylantorrent.config.dbfile
    con = sqlite3.connect(con_str, isolation_level="EXCLUSIVE")

    rc = 0
    sz = -1
    done = False
    message = ""
    if o.reattach is None:
        (rid, sz) = request(args, con)
        try:
            (done, rc, message) = is_done(con, rid)
        except:
            done = False
            rc = 0
            message = "Check on status later, db not ready for polling"
    else:
        rid = o.reattach
        if o.cancel:
            delete_rid(con, rid)
            return 0
        
        (done, rc, message) = is_done(con, rid)

    if not o.nonblock and not done:
        (rc, message) = wait_until_sent(con, rid)
        done = True

    if done:
        delete_rid(con, rid)

    msg = "%d,%s,%s" % (rc, str(done), message)
    print msg

    # always return 0 if we echo the rc to stdout.  this tells the 
    # user to check the output for the real rc
    return 0