Browse Source

run.py add CurrentPage.OnAria2CompleteCb
21_Warehouse/__init__.py text correspondence[_FootMsg]
Warehouse beta now

cuu 4 years ago
parent
commit
ad4a82bad5
2 changed files with 20 additions and 2 deletions
  1. 3 0
      Menu/GameShell/21_Warehouse/__init__.py
  2. 17 2
      sys.py/run.py

+ 3 - 0
Menu/GameShell/21_Warehouse/__init__.py

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

+ 17 - 2
sys.py/run.py

@@ -23,6 +23,7 @@ import gobject
 import socket
 import pygame
 from sys import exit
+import json
 
 #from beeprint import pp
 ########
@@ -481,7 +482,21 @@ def gobject_pygame_event_timer(main_screen):
 @misc.threaded
 def aria2_ws(main_screen):
     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):
         print(error)
@@ -490,7 +505,7 @@ def aria2_ws(main_screen):
         print("### closed ###")
     
      
-    websocket.enableTrace(True)
+    #websocket.enableTrace(True)
     try:
         ws = websocket.WebSocketApp("ws://localhost:6800/jsonrpc",
                               on_message = on_message,