Example #1
0
def statusString(remoteCall, result):
    """ Generate and print status txt to stdout from the result of an xml rpc status call """
    s = result

    # yyyymmddThh:mm:ss
    t = s['time'].value
    y = int(t[0:4])
    m = int(t[4:6])
    d = int(t[6:8])
    #z = int(t[8:1])
    h = int(t[9:11])
    min = int(t[12:14])
    sec = int(t[15:17])

    currentTime = datetime(y, m, d, h, min, sec)
    # NOTE: Could try: getting values from the result dict, and default to a None for
    # each, for the case of possible later versions of hellanzb expecting more/different
    # arguments -- they won't necessarily fail (not a big deal)
    uptime = s['uptime']
    isPaused = s['is_paused']
    totalSpeed = s['rate']
    totalNZBs = s['total_dl_nzbs']
    totalFiles = s['total_dl_files']
    totalSegments = s['total_dl_segments']
    totalMb = s['total_dl_mb']
    version = s['version']
    currentNZBs = s['currently_downloading']
    processingNZBs = s['currently_processing']
    queuedNZBs = s['queued']
    queuedMB = s['queued_mb']
    eta = s['eta']
    maxrate = s['maxrate']
    percentComplete = s['percent_complete']
    logEntries = s['log_entries'][-6:]

    if isPaused:
        totalSpeed = 'Paused'
    elif totalSpeed == 0:
        totalSpeed = 'Idle'
    else:
        totalSpeed = '%.1fKB/s' % (totalSpeed)

    downloading = 'Downloading: '
    processing = 'Processing: '
    failedProcessing = 'Failed Processing: '
    queued = 'Queued: '
    downloadingSpacer = ' ' * len(downloading)

    downloading += statusFromList(currentNZBs, len(downloading))
    processing += statusFromList(processingNZBs, len(processing))

    def queuedMBFunc(item):
        msg = '(%s) %s' % (item['id'], item['nzbName'])
        if 'total_mb' in item:
            msg += ' [%s MB]' % item['total_mb']
        return msg

    queued += statusFromList(queuedNZBs, len(queued), func=queuedMBFunc)

    # FIXME: show if any archives failed during processing?
    #f = failedProcessing

    now = currentTime.strftime('%I:%M%p')

    # FIXME: optionally don't show ascii
    # hellanzb version %s

    one = """%s  up %s  """
    one = one % (now, uptime)
    two = """downloaded %i nzbs, %i files, %i segments""" % (
        totalNZBs, totalFiles, totalSegments)
    threePrefix = '\n'
    if maxrate > 0:
        part = 'max rate ' + str(maxrate) + 'KB/s'
        threePrefix += part + ' ' * (len(one) - len(part))
    else:
        threePrefix += ' ' * len(one)

    three = threePrefix + """(%i MB)""" % \
        (totalMb)

    msg = one + two + three
    msg += cmHella(version)

    for entry in logEntries:
        log = entry.values()[0]
        if log.strip() == '':
            continue

        # maintain 80 character max width for all log messages
        lines = log.split('\n')
        for line in lines:
            msg += truncateToMultiLine(line.rstrip(), length=80) + '\n'

    msg += \
"""
%s""" % (downloading)

    if len(currentNZBs):
        msg += \
"""    
%s%s, %s MB queued, ETA: %s (%i%%)""" % (downloadingSpacer, totalSpeed, queuedMB, prettyEta(eta),
                                       percentComplete)

    msg += \
"""

%s
%s
    """.rstrip() % (processing, queued)

    if isinstance(msg, unicode):
        # FIXME: I'm pretty sure 'latin-1' did not fix a particular problem here, causing
        # me to use utf-8. I didn't document the cause. Is utf-8 totally necessary here?
        msg = msg.encode('utf-8')
    noLogFile(str(msg))

    reactor.stop()
Example #2
0
def statusString(remoteCall, result):
    """ Generate and print status txt to stdout from the result of an xml rpc status call """
    s = result

    # yyyymmddThh:mm:ss
    t = s['time'].value
    y = int(t[0:4])
    m = int(t[4:6])
    d = int(t[6:8])
    #z = int(t[8:1])
    h = int(t[9:11])
    min = int(t[12:14])
    sec = int(t[15:17])
    
    currentTime = datetime(y, m, d, h, min, sec)
    # NOTE: Could try: getting values from the result dict, and default to a None for
    # each, for the case of possible later versions of hellanzb expecting more/different
    # arguments -- they won't necessarily fail (not a big deal)
    uptime = s['uptime']
    isPaused = s['is_paused']
    totalSpeed = s['rate']
    totalNZBs = s['total_dl_nzbs']
    totalFiles = s['total_dl_files']
    totalSegments = s['total_dl_segments']
    totalMb = s['total_dl_mb']
    version = s['version']
    currentNZBs = s['currently_downloading']
    processingNZBs = s['currently_processing']
    queuedNZBs = s['queued']
    queuedMB = s['queued_mb']
    eta = s['eta']
    maxrate = s['maxrate']
    percentComplete = s['percent_complete']
    logEntries = s['log_entries'][-6:]

    if isPaused:
        totalSpeed = 'Paused'
    elif totalSpeed == 0:
        totalSpeed = 'Idle'
    else:
        totalSpeed = '%.1fKB/s' % (totalSpeed)
    
    downloading = 'Downloading: '
    processing = 'Processing: '
    failedProcessing = 'Failed Processing: '
    queued = 'Queued: '
    downloadingSpacer = ' '*len(downloading)

    downloading += statusFromList(currentNZBs, len(downloading))
    processing += statusFromList(processingNZBs, len(processing))
    def queuedMBFunc(item):
        msg = '(%s) %s' % (item['id'], item['nzbName'])
        if 'total_mb' in item:
            msg += ' [%s MB]' % item['total_mb']
        return msg
    queued += statusFromList(queuedNZBs, len(queued), func=queuedMBFunc)

    # FIXME: show if any archives failed during processing?
    #f = failedProcessing

    now = currentTime.strftime('%I:%M%p')

    # FIXME: optionally don't show ascii
    # hellanzb version %s

    one = """%s  up %s  """
    one = one % (now, uptime)
    two =  """downloaded %i nzbs, %i files, %i segments""" % (totalNZBs, totalFiles,
                                                              totalSegments)
    threePrefix = '\n'
    if maxrate > 0:
        part = 'max rate ' + str(maxrate) + 'KB/s'
        threePrefix += part + ' '*(len(one) - len(part))
    else:
        threePrefix += ' '*len(one)
        
    three = threePrefix + """(%i MB)""" % \
        (totalMb)
    
    msg = one + two + three
    msg += cmHella(version)

    for entry in logEntries:
        log = entry.values()[0]
        if log.strip() == '':
            continue

        # maintain 80 character max width for all log messages
        lines = log.split('\n')
        for line in lines:
            msg += truncateToMultiLine(line.rstrip(), length = 80) + '\n'
        
    msg += \
"""
%s""" % (downloading)

    if len(currentNZBs):
        msg += \
"""    
%s%s, %s MB queued, ETA: %s (%i%%)""" % (downloadingSpacer, totalSpeed, queuedMB, prettyEta(eta),
                                       percentComplete)

    msg += \
"""

%s
%s
    """.rstrip() % (processing, queued)

    if isinstance(msg, unicode):
        # FIXME: I'm pretty sure 'latin-1' did not fix a particular problem here, causing
        # me to use utf-8. I didn't document the cause. Is utf-8 totally necessary here?
        msg = msg.encode('utf-8')
    noLogFile(str(msg))
    
    reactor.stop()
Example #3
0
    def asciiArt():
        keys = Codez.allCodez.keys()
        index = keys[random.randint(0, len(keys) - 1)]
        return Codez.allCodez[index]
    asciiArt = staticmethod(asciiArt)

    def aolSay():
        if len(Codez.aolSays):
            return Codez.aolSays[random.randint(0, len(Codez.aolSays) - 1)]
        return None
    aolSay = staticmethod(aolSay)
    
C = Codez

C('cmhella', cmHella())

C('k0w0', """
               MoO0Oo0Oo0
         (__)
         /oo\\\\################
         \\\\/ ################ |
             ################ |
             ################ |
             ################
              | |        | |
              ^ ^        ^ ^
""")

C('k0w1', """
                    Mo000O0oo0OOO
Example #4
0
        index = keys[random.randint(0, len(keys) - 1)]
        return Codez.allCodez[index]

    asciiArt = staticmethod(asciiArt)

    def aolSay():
        if len(Codez.aolSays):
            return Codez.aolSays[random.randint(0, len(Codez.aolSays) - 1)]
        return None

    aolSay = staticmethod(aolSay)


C = Codez

C('cmhella', cmHella())

C(
    'k0w0', r"""
               MoO0Oo0Oo0
         (__)
         /oo\\################
         \\/ ################ |
             ################ |
             ################ |
             ################
              | |        | |
              ^ ^        ^ ^
""")

C(