def runtimeCommand(self,sender): global globalThreadReport body = 'PuxHelper has been running for %s.'%BFun.toc2Str(self.threadInitTic) keyList = list(globalThreadReport.keys()) body = body+'\n%d Threads:'%len(keyList) for aKey in keyList: reportTime = globalThreadReport[aKey] body = body+'\n%s ago, %s'%(BFun.toc2Str(reportTime),aKey) self.pBullet.sendNote(None,body,sender)
def runtimeCommand(self, sender): global globalThreadReport body = 'PuxHelper has been running for %s.' % BFun.toc2Str( self.threadInitTic) keyList = list(globalThreadReport.keys()) body = body + '\n%d Threads:' % len(keyList) for aKey in keyList: reportTime = globalThreadReport[aKey] body = body + '\n%s ago, %s' % (BFun.toc2Str(reportTime), aKey) self.pBullet.sendNote(None, body, sender)
def torrentCommand(self,arguments,sender): # Trim completed torrents orMore = '' while len(PuxGlobal.globalRecentCompleteTorrents) > 10: PuxGlobal.globalRecentCompleteTorrents.pop(0) orMore = '+' # Build some strings completeBody = '' currentBody = '' if len(PuxGlobal.globalRecentCompleteTorrents) > 0: completeBody = 'Completed:' for completeDictionary in PuxGlobal.globalRecentCompleteTorrents: show = completeDictionary['show'] epNum = completeDictionary['epNum'] tic = completeDictionary['tic'] tocString = BFun.toc2Str(tic) temp = '\n%s Ep%d (%s ago)'%(show,epNum,tocString) completeBody = completeBody+temp currentKeys = list(PuxGlobal.globalCurrentTorrentsProgress.keys()) #currentBody = 'Transferring:' currentCounter = 0 for showName in currentKeys: for episodeDict in PuxGlobal.globalCurrentTorrentsProgress[showName]: temp = '\n%0.0f%% - Ep%d of %s'%(episodeDict['percent'],episodeDict['epNum'],showName) currentBody = currentBody+temp currentCounter = currentCounter + 1 if currentCounter > 0: currentBody = 'Transferring %d:'%currentCounter + currentBody body = '' if len(arguments) > 0: allArguments = ''.join(arguments).lower() if 'all' in allArguments: body = completeBody+'\n'+currentBody else: if 'complete' in allArguments: body = completeBody if 'current' in allArguments: # If no torrents are in progress, leave body empty. if (len(body) > 0) and (len(currentBody) > 0): body = body+'\n' body = body+currentBody if 'fast' in allArguments: body = 'fast did nothing.' # Check how long to speed up for. In hours+17 seconds. try: hours = int(arguments[-1]) except ValueError as ex: hours = 1 seconds = hours*3617 PuxGlobal.torretSpeedResetTime[0] = time.time() + seconds try: tempClient = transmissionrpc.Client() tempClient.set_session(None,alt_speed_down=99999) # Fast enough probably. body = 'Set high download speed for %0.0f hours'%hours except transmissionrpc.error.TransmissionError as ex: # Transmission not running? body = 'Couldn\'t connect to Transmission' else: if len(completeBody) > 0: body = completeBody else: body = currentBody # If body is still empty after everything, add a message if len(body) == 0: body = 'No torrents to report or invalid command.' title = None self.pBullet.sendNote(title,body,sender)
def torrentCommand(self, arguments, sender): # Trim completed torrents orMore = '' while len(PuxGlobal.globalRecentCompleteTorrents) > 10: PuxGlobal.globalRecentCompleteTorrents.pop(0) orMore = '+' # Build some strings completeBody = '' currentBody = '' if len(PuxGlobal.globalRecentCompleteTorrents) > 0: completeBody = 'Completed:' for completeDictionary in PuxGlobal.globalRecentCompleteTorrents: show = completeDictionary['show'] epNum = completeDictionary['epNum'] tic = completeDictionary['tic'] tocString = BFun.toc2Str(tic) temp = '\n%s Ep%d (%s ago)' % (show, epNum, tocString) completeBody = completeBody + temp currentKeys = list(PuxGlobal.globalCurrentTorrentsProgress.keys()) #currentBody = 'Transferring:' currentCounter = 0 for showName in currentKeys: for episodeDict in PuxGlobal.globalCurrentTorrentsProgress[ showName]: temp = '\n%0.0f%% - Ep%d of %s' % ( episodeDict['percent'], episodeDict['epNum'], showName) currentBody = currentBody + temp currentCounter = currentCounter + 1 if currentCounter > 0: currentBody = 'Transferring %d:' % currentCounter + currentBody body = '' if len(arguments) > 0: allArguments = ''.join(arguments).lower() if 'all' in allArguments: body = completeBody + '\n' + currentBody else: if 'complete' in allArguments: body = completeBody if 'current' in allArguments: # If no torrents are in progress, leave body empty. if (len(body) > 0) and (len(currentBody) > 0): body = body + '\n' body = body + currentBody if 'fast' in allArguments: body = 'fast did nothing.' # Check how long to speed up for. In hours+17 seconds. try: hours = int(arguments[-1]) except ValueError as ex: hours = 1 seconds = hours * 3617 PuxGlobal.torretSpeedResetTime[0] = time.time() + seconds try: tempClient = transmissionrpc.Client() tempClient.set_session( None, alt_speed_down=99999) # Fast enough probably. body = 'Set high download speed for %0.0f hours' % hours except transmissionrpc.error.TransmissionError as ex: # Transmission not running? body = 'Couldn\'t connect to Transmission' else: if len(completeBody) > 0: body = completeBody else: body = currentBody # If body is still empty after everything, add a message if len(body) == 0: body = 'No torrents to report or invalid command.' title = None self.pBullet.sendNote(title, body, sender)
import operator import time import math import threading import os programRunTic = BFun.tic() ppBullet = PuxBullet(sendOnly=True) # Just make sure the lg BFun.ezLog('Program started at %0.1f'%programRunTic) # Make the threads threadList = [] threadList.append(PuxThreads.TorrentT()) threadList.append(PuxThreads.PushBulletT()) # Start the threads for n in range(len(threadList)): print('Starting thread %d'%n) threadList[n].start() # Program is basically over now. for oneThread in threadList: # Wait until each thread joins (finishes) oneThread.join() # Perform program end things. runTimeString = BFun.toc2Str(programRunTic) programEndTic = BFun.tic() BFun.ezLog('Program ended at %0.1f. Ran for %s'%(programEndTic,runTimeString)) ppBullet.sendBrowsers(None,'Program ended at %0.1f. Ran for %s'%(programEndTic,runTimeString)) print('All Done!') os.system('sudo reboot')
import threading import os programRunTic = BFun.tic() ppBullet = PuxBullet(sendOnly=True) # Just make sure the lg BFun.ezLog('Program started at %0.1f' % programRunTic) # Make the threads threadList = [] threadList.append(PuxThreads.TorrentT()) threadList.append(PuxThreads.PushBulletT()) # Start the threads for n in range(len(threadList)): print('Starting thread %d' % n) threadList[n].start() # Program is basically over now. for oneThread in threadList: # Wait until each thread joins (finishes) oneThread.join() # Perform program end things. runTimeString = BFun.toc2Str(programRunTic) programEndTic = BFun.tic() BFun.ezLog('Program ended at %0.1f. Ran for %s' % (programEndTic, runTimeString)) ppBullet.sendBrowsers( None, 'Program ended at %0.1f. Ran for %s' % (programEndTic, runTimeString)) print('All Done!') os.system('sudo reboot')