run.py add CurrentPage.OnAria2CompleteCb

21_Warehouse/__init__.py text correspondence[_FootMsg]
Warehouse beta now
This commit is contained in:
cuu 2019-12-19 05:13:07 +00:00
parent 9b1c89af4c
commit ad4a82bad5
2 changed files with 20 additions and 2 deletions

View File

@ -927,6 +927,9 @@ class GameStorePage(Page):
def OnAria2CompleteCb(self,gid): def OnAria2CompleteCb(self,gid):
print("OnAria2CompleteCb ", gid) print("OnAria2CompleteCb ", gid)
self.SyncList()
self._Screen.Draw()
self._Screen.SwapAndShow()
def raw_github_com(self,_url):#eg: github.com/clockworkpi/warehouse def raw_github_com(self,_url):#eg: github.com/clockworkpi/warehouse
if _url.startswith("github.com")== False: if _url.startswith("github.com")== False:

View File

@ -23,6 +23,7 @@ import gobject
import socket import socket
import pygame import pygame
from sys import exit from sys import exit
import json
#from beeprint import pp #from beeprint import pp
######## ########
@ -481,7 +482,21 @@ def gobject_pygame_event_timer(main_screen):
@misc.threaded @misc.threaded
def aria2_ws(main_screen): def aria2_ws(main_screen):
def on_message(ws, message): def on_message(ws, message):
print(message) print("run.py aria2_ws on_message: ",message)
try:
aria2_noti = json.loads(message)
if "method" in aria2_noti and aria2_noti["method"] == "aria2.onDownloadError":
gid = aria2_noti["params"][0]["gid"]
if "method" in aria2_noti and aria2_noti["method"] == "aria2.onDownloadComplete":
gid = aria2_noti["params"][0]["gid"]
on_comp_cb = getattr(main_screen._CurrentPage,"OnAria2CompleteCb",None)
if on_comp_cb != None:
if callable( on_comp_cb ):
main_screen._CurrentPage.OnAria2CompleteCb(gid)
#game_install_thread(gid)
except Exception as ex:
print(ex)
def on_error(ws, error): def on_error(ws, error):
print(error) print(error)
@ -490,7 +505,7 @@ def aria2_ws(main_screen):
print("### closed ###") print("### closed ###")
websocket.enableTrace(True) #websocket.enableTrace(True)
try: try:
ws = websocket.WebSocketApp("ws://localhost:6800/jsonrpc", ws = websocket.WebSocketApp("ws://localhost:6800/jsonrpc",
on_message = on_message, on_message = on_message,