def detalle_descarga(item): itemlist = [] try: client = ThriftClient(host=SERVER, port=PORT) except: itemlist.append( Item(title="Login incorrecto", channel=CHANNELNAME, action="mainlist")) return itemlist lista = client.statusDownloads() for p in lista: if p.fid == int(item.url): titulo = p.name.encode("iso-8859-15") detalles = "%s %s@%skb/s %s %s%% / %s MB" % ( p.statusmsg, p.format_eta, p.speed / 1000, p.format_size, p.percent, ((p.size - p.bleft) / 1024) / 1024) itemlist.append( Item(title=titulo, channel=CHANNELNAME, action="detalle_descarga", url="%s" % p.fid)) itemlist.append( Item(title=detalles, channel=CHANNELNAME, action="detalle_descarga", url="%s" % p.fid)) return itemlist if len(itemlist) == 0: itemlist.append( Item(title="Ninguna descarga activa", channel=CHANNELNAME, action="ver_activas"))
def ver_activas(item): itemlist = [] try: client = ThriftClient(host=SERVER, port=PORT) except: itemlist.append( Item(title="Login incorrecto", channel=CHANNELNAME, action="mainlist")) return itemlist lista = client.statusDownloads() for p in lista: itemlist.append( Item(title=p.name.encode("iso-8859-15"), channel=CHANNELNAME, action="detalle_descarga", url="%s" % p.fid)) if len(itemlist) == 0: itemlist.append( Item(title="Ninguna descarga activa", channel=CHANNELNAME, action="mainlist")) return itemlist
def reiniciar_paquete(item): itemlist = [] try: client = ThriftClient(host=SERVER, port=PORT) except: itemlist.append( Item(title="Login incorrecto", channel=CHANNELNAME, action="mainlist")) return itemlist client.restartPackage(int(item.url)) time.sleep(15) lista = client.statusDownloads() # hallado = 0 # for p in lista: # if p.pid == int(item.url): hallado = 1 # if hallado == 1: itemlist.append( Item(title="Paquete reiniciado", channel=CHANNELNAME, action="ver_cola")) # else: # itemlist.append( Item( title="Error al reiniciar el paquete", channel=CHANNELNAME, action="ver_cola" ) ) return itemlist
def ver_activas(item): itemlist = [] try: client = ThriftClient(host=SERVER, port=PORT) except: itemlist.append( Item( title="Login incorrecto", channel=CHANNELNAME, action="mainlist" ) ) return itemlist lista = client.statusDownloads() for p in lista: itemlist.append( Item( title=p.name.encode("iso-8859-15"), channel=CHANNELNAME, action="detalle_descarga",url="%s" % p.fid ) ) if len(itemlist) == 0: itemlist.append( Item( title="Ninguna descarga activa", channel=CHANNELNAME, action="mainlist" ) ) return itemlist
def detalle_descarga(item): itemlist = [] try: client = ThriftClient(host=SERVER, port=PORT) except: itemlist.append( Item( title="Login incorrecto", channel=CHANNELNAME, action="mainlist" ) ) return itemlist lista = client.statusDownloads() for p in lista: if p.fid == int(item.url): titulo =p.name.encode("iso-8859-15") detalles = "%s %s@%skb/s %s %s%% / %s MB" % (p.statusmsg,p.format_eta,p.speed / 1000,p.format_size,p.percent, ((p.size - p.bleft)/1024)/1024) itemlist.append( Item( title=titulo, channel=CHANNELNAME, action="detalle_descarga",url="%s" % p.fid ) ) itemlist.append( Item( title=detalles, channel=CHANNELNAME, action="detalle_descarga",url="%s" % p.fid ) ) return itemlist if len(itemlist) == 0: itemlist.append( Item( title="Ninguna descarga activa", channel=CHANNELNAME, action="ver_activas" ) )
def reiniciar_paquete(item): itemlist = [] try: client = ThriftClient(host=SERVER, port=PORT) except: itemlist.append( Item( title="Login incorrecto", channel=CHANNELNAME, action="mainlist" ) ) return itemlist client.restartPackage(int(item.url)) time.sleep(15) lista = client.statusDownloads() # hallado = 0 # for p in lista: # if p.pid == int(item.url): hallado = 1 # if hallado == 1: itemlist.append( Item( title="Paquete reiniciado", channel=CHANNELNAME, action="ver_cola" ) ) # else: # itemlist.append( Item( title="Error al reiniciar el paquete", channel=CHANNELNAME, action="ver_cola" ) ) return itemlist