Example #1
0
File: debug.py Project: rostob/x84
def test_xmodem(filepath, protocol='xmodem1k'):
    import os
    from x84.bbs import echo, send_modem, recv_modem, getterminal
    term = getterminal()

    echo(u"\r\n\r\n")

    # test bbs sending to client
    stream = open(filepath, 'rb')
    echo(u"Sending {0} using protocol {1}. \r\n"
         u"Start your receiving program now. \r\n"
         u"Press ^X twice to cancel: "
         .format(filepath, protocol))
    status = send_modem(stream, protocol)
    if not status:
        echo(u"\r\nThat didn't go so well.. "
             u"status={0}; sorry!\r\n".format(status))
        term.inkey()
        return

    # test client sending to bbs
    echo(u"Now its your turn cowboy -- send me anything\r\n"
         u"using the {0} protocol. really, I don't care.\r\n"
         .format(protocol))
    stream = open(os.devnull, 'wb')
    if not recv_modem(stream, protocol):
        echo(u"That didn't go so well.. sorry!\r\n")
        term.inkey()
        return

    echo(u"fine shooting, soldier!\r\n")
    term.inkey()
Example #2
0
def test_xmodem(filepath, protocol='xmodem1k'):
    import os
    from x84.bbs import echo, send_modem, recv_modem, getterminal
    term = getterminal()

    echo(u"\r\n\r\n")

    # test bbs sending to client
    stream = open(filepath, 'rb')
    echo(u"Sending {0} using protocol {1}. \r\n"
         u"Start your receiving program now. \r\n"
         u"Press ^X twice to cancel: ".format(filepath, protocol))
    status = send_modem(stream, protocol)
    if not status:
        echo(u"\r\nThat didn't go so well.. "
             u"status={0}; sorry!\r\n".format(status))
        term.inkey()
        return

    # test client sending to bbs
    echo(u"Now its your turn cowboy -- send me anything\r\n"
         u"using the {0} protocol. really, I don't care.\r\n".format(protocol))
    stream = open(os.devnull, 'wb')
    if not recv_modem(stream, protocol):
        echo(u"That didn't go so well.. sorry!\r\n")
        term.inkey()
        return

    echo(u"fine shooting, soldier!\r\n")
    term.inkey()
Example #3
0
def download_files(term, session, protocol='xmodem1k'):
    """ Download flagged files. """
    if not len(browser.flagged_files):
        return False
    echo(term.clear)
    flagged = browser.flagged_files.copy()
    for fname in flagged:
        _fname = fname[fname.rfind(os.path.sep) + 1:].decode('utf8')
        echo(
            term.bold_green(u'Start your {protocol} receiving program '
                            u'to begin transferring {_fname}...\r\n'.format(
                                protocol=protocol, _fname=_fname)))
        echo(u'Press ^X twice to cancel\r\n')

        fin = open(fname, 'rb')
        if not send_modem(fin, protocol):
            echo(term.bold_red(u'Transfer failed!\r\n'))
        else:
            browser.flagged_files.remove(fname)
            session.user['flaggedfiles'] = browser.flagged_files
            echo(term.bold(u'Transfer(s) finished.\r\n'))
    term.inkey()
Example #4
0
def download_files(term, session, protocol='xmodem1k'):
    """ Download flagged files. """
    if not len(browser.flagged_files):
        return False
    echo(term.clear)
    flagged = browser.flagged_files.copy()
    for fname in flagged:
        _fname = fname[fname.rfind(os.path.sep) + 1:].decode('utf8')
        echo(term.bold_green(
            u'Start your {protocol} receiving program '
            u'to begin transferring {_fname}...\r\n'
            .format(protocol=protocol, _fname=_fname)))
        echo(u'Press ^X twice to cancel\r\n')

        fin = open(fname, 'rb')
        if not send_modem(fin, protocol):
            echo(term.bold_red(u'Transfer failed!\r\n'))
        else:
            browser.flagged_files.remove(fname)
            session.user['flaggedfiles'] = browser.flagged_files
            echo(term.bold(u'Transfer(s) finished.\r\n'))
    term.inkey()