rename submodule

This commit is contained in:
cuu 2019-12-04 21:36:04 +08:00
parent e9ed6d7cf1
commit 764aa61b7f
7 changed files with 86 additions and 15 deletions

1
.gitignore vendored
View File

@ -21,3 +21,4 @@ screenshots/*
*.log *.log
.DS_Store .DS_Store
sys.py/.* sys.py/.*
sys.py/*.db

6
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "sys.py/pyaria2-rpc"] [submodule "sys.py/pyaria2_rpc"]
path = sys.py/pyaria2-rpc path = sys.py/pyaria2_rpc
url = https://github.com/cuu/pyaria2-rpc.git url = https://github.com/cuu/pyaria2_rpc.git

View File

@ -2,6 +2,7 @@ session=${1:-gameshell}
case $session in case $session in
hdmi ) hdmi )
exec ~/launcher/aria2c --conf-path=~/launcher/aria2.conf
feh --bg-center ~/launcher/sys.py/gameshell/wallpaper/desktopbg.jpg feh --bg-center ~/launcher/sys.py/gameshell/wallpaper/desktopbg.jpg
cd ~/launcher/sys.py/ ; python appinstaller.py& cd ~/ cd ~/launcher/sys.py/ ; python appinstaller.py& cd ~/
exec ~/launcher/load.sh & exec ~/launcher/load.sh &
@ -9,7 +10,8 @@ hdmi )
#exec /usr/bin/twm -f ~/launcher/.twmrc #exec /usr/bin/twm -f ~/launcher/.twmrc
exec ~/launcher/dwm-mod exec ~/launcher/dwm-mod
;; ;;
gameshell ) gameshell )
exec ~/launcher/aria2c --conf-path=~/launcher/aria2.conf
feh --bg-center ~/launcher/sys.py/gameshell/wallpaper/loading.png feh --bg-center ~/launcher/sys.py/gameshell/wallpaper/loading.png
cd ~/launcher/sys.py/ ; python appinstaller.py& cd ~/ cd ~/launcher/sys.py/ ; python appinstaller.py& cd ~/
exec ~/launcher/load.sh & exec ~/launcher/load.sh &

View File

@ -6,7 +6,7 @@ import platform
import glob import glob
import json import json
import gobject import gobject
import sqlite3
#from beeprint import pp #from beeprint import pp
from libs.roundrects import aa_round_rect from libs.roundrects import aa_round_rect
@ -177,6 +177,13 @@ class Aria2DownloadProcessPage(Page):
self._FileNameLabel.Draw() self._FileNameLabel.Draw()
self._SizeLabel.Draw() self._SizeLabel.Draw()
def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
class GameStorePage(Page): class GameStorePage(Page):
_FootMsg = ["Nav","","","Back","Select"] _FootMsg = ["Nav","","","Back","Select"]
_MyList = [] _MyList = []
@ -203,6 +210,19 @@ class GameStorePage(Page):
{"title":"github.com/cuu/gamestore","file":"https://raw.githubusercontent.com/cuu/gamestore/master/index.json","type":"dir"} {"title":"github.com/cuu/gamestore","file":"https://raw.githubusercontent.com/cuu/gamestore/master/index.json","type":"dir"}
] ]
self._MyStack.Push(repos) self._MyStack.Push(repos)
def SyncSqlite(self):
try:
conn = sqlite3.connect("aria2tasks.db")
conn.row_factory = sqlite3.Row
c = conn.cursor()
ret = c.execute("SELECT * FROM tasks").fetchall()
conn.close()
return ret
except Exception as ex:
print(ex)
return None
return None
def SyncList(self): def SyncList(self):
@ -214,6 +234,12 @@ class GameStorePage(Page):
repos = self._MyStack.Last() repos = self._MyStack.Last()
if self._MyStack.Length() == 1: # on top
sqlite3_menu= self.SyncSqlite()
if sqlite3_menu != None and len(sqlite3_menu) > 0:
print(sqlite3_menu)
repos.extend(sqlite3_menu )
for i,u in enumerate( repos ): for i,u in enumerate( repos ):
#print(i,u) #print(i,u)
li = InfoPageListItem() li = InfoPageListItem()
@ -277,33 +303,64 @@ class GameStorePage(Page):
menu_file = remote_file_url.split("master")[1] #assume master branch menu_file = remote_file_url.split("master")[1] #assume master branch
local_menu_file = "%s/aria2Download%s" % (os.path.expanduser('~'),menu_file ) local_menu_file = "%s/aria2Download%s" % (os.path.expanduser('~'),menu_file )
if FileExists( local_menu_file ) == False: if FileExists( local_menu_file ) == False:
if config.RPC.urlDownloading(remote_file_url) == False: print(local_menu_file, "non-existed")
config.RPC.addUri( remote_file_url, options={"out": menu_file}) gid,ret = config.RPC.urlDownloading(remote_file_url)
if ret == False:
gid = config.RPC.addUri( remote_file_url, options={"out": menu_file})
self._Downloading = remote_file_url self._Downloading = remote_file_url
self._Screen._MsgBox.SetText("Loading")
self._Screen._MsgBox.Draw()
self._Screen.SwapAndShow()
else:
print(gid," url is downloading")
self._Screen._MsgBox.SetText("Loading")
self._Screen._MsgBox.Draw()
self._Screen.SwapAndShow()
else: else:
#read the local_menu_file, push into stack,display menu #read the local_menu_file, push into stack,display menu
self._Downloading = None self._Downloading = None
local_menu_json = json.load(local_menu_file)
with open(local_menu_file) as json_file: with open(local_menu_file) as json_file:
local_menu_json = json.load(json_file) local_menu_json = json.load(json_file)
self._MyStack.Push(local_menu_json["lists"]) self._MyStack.Push(local_menu_json["lists"])
self.SyncList() self.SyncList()
self._Screen.Draw()
self._Screen.SwapAndShow()
else: else:
#download the game probably #download the game probably
remote_file_url = cur_li._Value["file"] remote_file_url = cur_li._Value["file"]
menu_file = remote_file_url.split("master")[1] menu_file = remote_file_url.split("master")[1]
local_menu_file = "%s/aria2Download%s" % (os.path.expanduser('~'),menu_file ) local_menu_file = "%s/aria2Download%s" % (os.path.expanduser('~'),menu_file )
print cur_li._Value["type"] if config.RPC.urlDownloading(remote_file_url) == 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 VALUES ('"+gid+"','"+cur_li._Value["title"]+"','"+cur_li._Value["file"]+"','"+cur_li._Value["type"]+"','active')")
conn.commit()
conn.close()
except Exception as ex:
print(ex)
self._Screen._MsgBox.SetText("Getting the game now")
self._Screen._MsgBox.Draw()
seff._Screen.SwapAndShow()
def OnLoadCb(self): def OnLoadCb(self):
self._Scrolled = 0 self._Scrolled = 0
self._PosY = 0 self._PosY = 0
self._DrawOnce = False self._DrawOnce = False
#sync #sync
self.SyncList()
def OnReturnBackCb(self): def OnReturnBackCb(self):
pass pass
""" """

View File

@ -6,6 +6,7 @@ from wicd import misc
import libs.websocket as websocket import libs.websocket as websocket
aria2_ws = "ws://localhost:6800/jsonrpc" aria2_ws = "ws://localhost:6800/jsonrpc"
aria2_db = "aria2tasks.db"
@misc.threaded @misc.threaded
def game_install_thread(): def game_install_thread():
@ -14,6 +15,12 @@ def game_install_thread():
def on_message(ws, message): def on_message(ws, message):
print("got message") print("got message")
print(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)
def on_error(ws, error): def on_error(ws, error):
print(error) print(error)
@ -50,9 +57,13 @@ def init_sqlite3():
sql_create_tasks_table = """ CREATE TABLE IF NOT EXISTS tasks ( sql_create_tasks_table = """ CREATE TABLE IF NOT EXISTS tasks (
id integer PRIMARY KEY, id integer PRIMARY KEY,
gid text NOT NULL, gid text NOT NULL,
title text NOT NULL,
file text NOT NULL,
type text NOT NULL,
status text, status text,
totalLength text, totalLength text,
completedLength text completedLength text,
fav text
); """ ); """
conn = create_connection(database) conn = create_connection(database)

View File

@ -2,7 +2,7 @@
import os import os
import platform import platform
from UI.util_funcs import FileExists,ArmSystem from UI.util_funcs import FileExists,ArmSystem
from pyaria2 import Xmlrpc from pyaria2_rpc.pyaria2 import Xmlrpc
CurKeySet = "GameShell" ## >>> PC or GameShell <<< CurKeySet = "GameShell" ## >>> PC or GameShell <<<
@ -35,7 +35,7 @@ PowerLevel = "balance_saving"
def PreparationInAdv(): def PreparationInAdv():
global SKIN,ButtonsLayout global SKIN,ButtonsLayout
global PowerLevel global PowerLevel
global RPC
if SKIN != None: if SKIN != None:
return return
@ -73,7 +73,7 @@ def PreparationInAdv():
else: else:
ArmSystem("sudo iw wlan0 set power_save off >/dev/null") ArmSystem("sudo iw wlan0 set power_save off >/dev/null")
RPC = Xmlrpc('localhost', 6800) RPC = Xmlrpc('localhost', 6800)
PreparationInAdv() PreparationInAdv()
##sys.py/.powerlevel ##sys.py/.powerlevel