From 33713937336e50123049ddf4520efdffa6247ae9 Mon Sep 17 00:00:00 2001 From: cuu Date: Thu, 5 Dec 2019 22:00:22 +0800 Subject: [PATCH] gamestore bug fix --- Menu/GameShell/21_GameStore/__init__.py | 40 ++++++++++++++----------- sys.py/appinstaller.py | 16 ++++++++-- sys.py/pyaria2_rpc | 2 +- 3 files changed, 38 insertions(+), 20 deletions(-) diff --git a/Menu/GameShell/21_GameStore/__init__.py b/Menu/GameShell/21_GameStore/__init__.py index ff904d7..6c559c7 100644 --- a/Menu/GameShell/21_GameStore/__init__.py +++ b/Menu/GameShell/21_GameStore/__init__.py @@ -187,8 +187,9 @@ def dict_factory(cursor, row): class GameStorePage(Page): _FootMsg = ["Nav","","Up","Back","Select"] _MyList = [] - _ListFont = MyLangManager.TrFont("notosanscjk12") - + _ListFont12 = MyLangManager.TrFont("notosanscjk12") + _ListFont15 = MyLangManager.TrFont("varela15") + _AList = {} _Scrolled = 0 @@ -238,7 +239,7 @@ class GameStorePage(Page): if self._MyStack.Length() == 1: # on top sqlite3_menu= self.SyncSqlite() if sqlite3_menu != None and len(sqlite3_menu) > 0: - print(sqlite3_menu) + #print(sqlite3_menu) repos.extend(sqlite3_menu ) print(repos) @@ -250,7 +251,7 @@ class GameStorePage(Page): li._PosX = start_x li._PosY = start_y + last_height li._Width = Width - li._Fonts["normal"] = self._ListFont + li._Fonts["normal"] = self._ListFont15 li._Active = False li._Value = u li.Init( u["title"] ) @@ -259,7 +260,6 @@ class GameStorePage(Page): self._MyList.append(li) - self._MyStack.Push(repos) def Init(self): if self._Screen != None: @@ -296,10 +296,10 @@ class GameStorePage(Page): return cur_li = self._MyList[self._PsIndex] - if cur_li._Active == True: - return + #if cur_li._Active == True: + # return - print(cur_li._Value) + print("cur_li._Value",cur_li._Value) if cur_li._Value["type"] == "dir": remote_file_url = cur_li._Value["file"] @@ -345,15 +345,19 @@ class GameStorePage(Page): if ret == False: gid = config.RPC.addUri( remote_file_url, options={"out": menu_file}) self._Downloading = remote_file_url - try: - conn = sqlite3.connect("aria2tasks.db") - c = conn.cursor() - c.execute("INSERT INTO tasks(gid,title,file,type,status,fav) VALUES ('"+gid+"','"+cur_li._Value["title"]+"','"+cur_li._Value["file"]+"','"+cur_li._Value["type"]+"','active','0')") + print("stack length ",self._MyStack.Length()) + if self._MyStack.Length() > 1:## not on the top list page + try: + conn = sqlite3.connect("aria2tasks.db") + c = conn.cursor() + c.execute("INSERT INTO tasks(gid,title,file,type,status,fav) VALUES ('"+gid+"','"+cur_li._Value["title"]+"','"+cur_li._Value["file"]+"','"+cur_li._Value["type"]+"','active','0')") - conn.commit() - conn.close() - except Exception as ex: - print("SQLITE3 ",ex) + conn.commit() + conn.close() + except Exception as ex: + print("SQLITE3 ",ex) + else: + print(config.RPC.tellStatus(gid,["status","totalLength","completedLength"])) self._Screen._MsgBox.SetText("Getting the game now") self._Screen._MsgBox.Draw() @@ -367,7 +371,8 @@ class GameStorePage(Page): self._Scrolled = 0 self._PosY = 0 self._DrawOnce = False - #sync + #sync + print("OnLoadCb") self.SyncList() def OnReturnBackCb(self): @@ -387,6 +392,7 @@ class GameStorePage(Page): self.Click() if event.key == CurKeys["X"]: + print(self._MyStack.Length() ) if self._MyStack.Length() > 1: self._MyStack.Pop() self.SyncList() diff --git a/sys.py/appinstaller.py b/sys.py/appinstaller.py index 6b1ef9d..53d5434 100644 --- a/sys.py/appinstaller.py +++ b/sys.py/appinstaller.py @@ -2,25 +2,37 @@ import sqlite3 import json from wicd import misc +from pyaria2_rpc.pyaria2 import Wsrpc import libs.websocket as websocket aria2_ws = "ws://localhost:6800/jsonrpc" aria2_db = "aria2tasks.db" +rpc = Wsrpc('localhost',6800) + @misc.threaded def game_install_thread(): pass def on_message(ws, message): + global rpc print("got message") print(message) #decode json #lookup in the sqlite db ,update the status[error,complete], #uncompress the game into destnation folder in the game_install_thread aria2_noti = json.loads(message) - - + if "method" in aria2_noti and aria2_noti["method"] == "aria2.onDownloadError": + gid = aria2_noti["params"][0]["gid"] + msg = rpc.tellStatus(gid) + ws.send(msg) + + if "method" in aria2_noti and aria2_noti["method"] == "aria2.onDownloadComplete": + gid = aria2_noti["params"][0]["gid"] + msg = rpc.tellStatus(gid) + ws.send(msg) + def on_error(ws, error): print(error) diff --git a/sys.py/pyaria2_rpc b/sys.py/pyaria2_rpc index d5b7c36..864bea5 160000 --- a/sys.py/pyaria2_rpc +++ b/sys.py/pyaria2_rpc @@ -1 +1 @@ -Subproject commit d5b7c364d6baa93cd1d85b16cd115fd70c3898e2 +Subproject commit 864bea5ca1252bc105cac47f640f47e95c81f6fa