gamestore bug fix

This commit is contained in:
cuu 2019-12-05 22:00:22 +08:00
parent 85d67dc218
commit 3371393733
3 changed files with 38 additions and 20 deletions

View File

@ -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()

View File

@ -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)

@ -1 +1 @@
Subproject commit d5b7c364d6baa93cd1d85b16cd115fd70c3898e2
Subproject commit 864bea5ca1252bc105cac47f640f47e95c81f6fa