Beispiel #1
0
def putfile(filename, remotefilename, forceput):
    conn = Connection()
    log = getSyslog()
    req_unsolicited = conn.connect()
    if req_unsolicited:
        #Receive unsolicited
        status, buf, uns = conn.receive()
        if status != 0x9000:
            log.logerr('Unsolicited fail')
            exit(-1)
        log.log('Unsolicited', TLVParser(buf))
    progress = partial(util.display_console_progress_bar,
                       util.get_terminal_width())
    if forceput:
        fops.putfile(conn, log, filename, remotefilename, progress=progress)
    else:
        try:
            fops.updatefile(conn,
                            log,
                            filename,
                            remotefilename,
                            False,
                            progress=progress)
        except exc.invResponseException as e:
            log.logerr("Unable to use updatefile fallback to putfile")
            fops.putfile(conn,
                         log,
                         filename,
                         remotefilename,
                         progress=progress)
Beispiel #2
0
def put_file(filename):
    progress = partial( util.display_console_progress_bar, util.get_terminal_width() )

    try:
        fops.updatefile( conn, log, filename, progress=progress )
    except exc.invResponseException as e:
        log.logerr( "Unable to use updatefile fallback to putfile" )
        fops.putfile( conn, log, filename, progress=progress )
Beispiel #3
0
def __getfile_command(toks, conn, log):
    remote_file = toks[1]
    if len(toks) == 3:
        local_file = toks[2]
    else:
        local_file = None
    progress = partial(utils.display_console_progress_bar,
                       utils.get_terminal_width())
    fops.getfile(conn, log, remote_file, local_file, progress)
Beispiel #4
0
def __updatefile_command(toks, conn, log):
    filename = toks[1]
    if not os.path.isfile(filename):
        filename = os.path.join(__SCRIPT_ROOT, filename)
    do_sign = toks.get("sign")
    if do_sign == None: do_sign = False
    renfile = toks.get("rename")
    if renfile != None: renfile = renfile[0]
    progress = partial(utils.display_console_progress_bar,
                       utils.get_terminal_width())
    fops.updatefile(conn, log, filename, renfile, do_sign, progress)
def checkfile( filename ):
    conn = Connection()
    log = getSyslog()
    req_unsolicited = conn.connect()
    if req_unsolicited:
        #Receive unsolicited
        status, buf, uns = conn.receive()
        if status != 0x9000:
            log.logerr('Unsolicited fail')
            exit(-1)
        log.log('Unsolicited', TLVParser(buf) )
    progress = partial( util.display_console_progress_bar, util.get_terminal_width() )
    openfile( conn, log, filename, progress )