Beispiel #1
0
    def API(self, main_screen):
        if main_screen != None:
            if self._Done != "":
                #try to check if the installed package still there, if not ,remove the done flag file
                if FileExists(
                        os.path.join(self._ComPkgInfo["GameDir"],
                                     self._ComPkgInfo["InstallDir"])) == False:
                    done_file = os.path.join(os.path.dirname(self._Done),
                                             ".done")
                    if FileExists(done_file):
                        os.remove(done_file)

                main_screen._MsgBox.SetText("Starting")
                main_screen._MsgBox.Draw()
                main_screen.SwapAndShow()
                pygame.time.delay(300)
                ####

                pygame.event.post(
                    pygame.event.Event(RUNEVT, message=self._Done))
                ####
            else:
                #print(self._ComPkgInfo)
                #if FileExists( os.path.join(self._ComPkgInfo["GameDir"],self._ComPkgInfo["InstallDir"] )) == False:
                if self.CheckPackage(main_screen) == False:
                    main_screen.PushPage(self._Page1)
                    main_screen.Draw()
                    main_screen.SwapAndShow()
                else:
                    if self.VerifyPackage(main_screen) == False:
                        main_screen.PushPage(self._Page2)
                        main_screen.Draw()
                        main_screen.SwapAndShow()
                    else:
                        self.InstallPackage(main_screen)
Beispiel #2
0
    def InstallPackage(self, main_screen):
        main_screen._MsgBox.SetText("Installing the package")
        main_screen._MsgBox.Draw()
        main_screen.SwapAndShow()
        json_config = self._ComPkgInfo
        cur_dir = os.getcwd()

        os.chdir(json_config["GameDir"])
        for i, v in enumerate(json_config["MD5"]):
            if FileExists(v):
                os.system("unzip -o %s" % v)  ## auto overwrite

        if "Post-Up" in json_config:
            if FileExists(self._InvokeDir):
                os.chdir(self._InvokeDir)

            os.system(json_config["Post-Up"])

        os.chdir(cur_dir)
        pygame.time.delay(1000)

        main_screen._MsgBox.SetText("Package Installed")
        main_screen._MsgBox.Draw()
        main_screen.SwapAndShow()
        pygame.time.delay(500)

        pygame.event.post(pygame.event.Event(RESTARTUI, message=""))
Beispiel #3
0
def PreparationInAdv():

    if "arm" not in platform.machine():
        return

    if FileExists("%s/.gameshell_skin" % os.path.expanduser('~')) == True:
        with open("%s/.gameshell_skin" % os.path.expanduser('~'), "r") as f:
            gameshell_skin = f.read()

        gameshell_skin = gameshell_skin.strip()
        config.SKIN = gameshell_skin

    if FileExists(".powerlevel") == False:
        os.system("touch .powerlevel")

    with open(".powerlevel", "r") as f:
        powerlevel = f.read()

    powerlevel = powerlevel.strip()
    if powerlevel != "":
        config.PowerLevel = powerlevel
        if powerlevel != "supersaving":
            os.system("sudo iw wlan0 set power_save off >/dev/null")
        else:
            os.system("sudo iw wlan0 set power_save on > /dev/null")
    else:
        os.system("sudo iw wlan0 set power_save off >/dev/null")
Beispiel #4
0
def PreparationInAdv():
    global SKIN, ButtonsLayout, FB_Modes, GlobalScale
    global PowerLevel
    global RPC
    if SKIN != None:
        return

    SKIN = "../skin/DEOT"

    if FileExists("%s/.gameshell_skin" % os.path.expanduser('~')) == True:
        with open("%s/.gameshell_skin" % os.path.expanduser('~'), "r") as f:
            gameshell_skin = f.read()

        gameshell_skin = gameshell_skin.strip()
        SKIN = gameshell_skin

    if FileExists(".buttonslayout") == True:
        with open(".buttonslayout") as f:
            btnlayout = f.read()

        btnlayout = btnlayout.strip()
        ButtonsLayout = btnlayout
        if ButtonsLayout != "xbox" and ButtonsLayout != "snes":
            #ButtonsLayout = "xbox"
            ButtonsLayout = "snes"

    if FileExists(".powerlevel") == False:
        os.system("touch .powerlevel")

    with open(".powerlevel", "r") as f:
        powerlevel = f.read()

    powerlevel = powerlevel.strip()
    if powerlevel != "":
        PowerLevel = powerlevel
        if powerlevel != "supersaving":
            ArmSystem("sudo iw wlan0 set power_save off >/dev/null")
        else:
            ArmSystem("sudo iw wlan0 set power_save on > /dev/null")
    else:
        ArmSystem("sudo iw wlan0 set power_save off >/dev/null")

    if FileExists(FB_Modes):
        modes = ReadTheFileContent(FB_Modes)
        if "320x240" in modes:
            GlobalScale = 1
        if "640x480" in modes:
            GlobalScale = 2
        if "480x640" in modes:
            GlobalScale = 2
    else:
        GlobalScale = 1

    RPC = Xmlrpc('localhost', 6800)
Beispiel #5
0
    def OnLoadCb(self):
        self._Scrolled = 0
        self._PosY = 0
        self._DrawOnce = False

        ## grep Driver /etc/xorg.conf | tr -s " " | cut -d " " -f3
        ## "fbturbo"
        ## "modesetting"
        thedrv = ""

        if "arm" in platform.machine():
            if FileExists("%s/.lima" % os.path.expanduser('~')):
                thedrv = "modesetting"
            else:
                thedrv = "fbturbo"

        if thedrv == "":
            thedrv = "fbturbo"

        for i in self._MyList:
            i._Active = False

        for i in self._MyList:
            if thedrv in i._Value:
                i._Active = True
Beispiel #6
0
    def GObjectUpdateProcessInterval(self):
        ret = True
        if self._Screen.CurPage() == self:
            if self._Downloader._stop == True:
                ret = False

            dst_filename = self._Downloader.get_dest()
            if self._Downloader.isFinished():
                if self._Downloader.isSuccessful():
                    filename = self._URL.split("/")[-1].strip()
                    local_dir = self._URL.split("raw.githubusercontent.com")
                    menu_file = local_dir[1]
                    local_menu_file = "%s/aria2download%s" % (
                        os.path.expanduser('~'), menu_file)

                    dl_file = os.path.join("/tmp", filename)
                    if not os.path.exists(os.path.dirname(local_menu_file)):
                        os.makedirs(os.path.dirname(local_menu_file))

                    copyfile(dl_file, local_menu_file)
                    ret = False

            #print("dest ",dst_filename)
            if FileExists(dst_filename):
                try:
                    #print("load and draw")
                    self._img = pygame.image.load(dst_filename).convert_alpha()
                    self._Screen.Draw()
                    self._Screen.SwapAndShow()
                except Exception as ex:
                    print(ex)

            return ret
        else:
            return False
Beispiel #7
0
    def OnLoadCb(self):
        if self._URL is None:
            return
        self._img = None
        self.ClearCanvas()
        self._Screen.Draw()
        self._Screen.SwapAndShow()

        filename = self._URL.split("/")[-1].strip()
        local_dir = self._URL.split("raw.githubusercontent.com")

        if len(local_dir) > 1:
            menu_file = local_dir[1]
            local_menu_file = "%s/aria2download%s" % (os.path.expanduser('~'),
                                                      menu_file)

            if FileExists(local_menu_file):
                self._img = pygame.image.load(local_menu_file).convert_alpha()
                self._Screen.Draw()
                self._Screen.SwapAndShow()
            else:
                self._Downloader = Download(self._URL, "/tmp", None)
                self._Downloader.start()
                self._DownloaderTimer = gobject.timeout_add(
                    300, self.GObjectUpdateProcessInterval)
    def VerifyPackage(self, main_screen):
        ## do unzip and check md5sum once

        main_screen._MsgBox.SetText("Verify the package")
        main_screen._MsgBox.Draw()
        main_screen.SwapAndShow()
        pygame.time.delay(400)

        Checked = False

        json_config = self._ComPkgInfo
        if json_config == None:
            return

        if "MD5" in json_config:
            for i, v in enumerate(json_config["MD5"]):
                #print(i,v)
                if FileExists(os.path.join(json_config["GameDir"], v)):
                    print(os.path.join(json_config["GameDir"], v))
                    out = commands.getstatusoutput(
                        "md5sum %s" % os.path.join(json_config["GameDir"], v))
                    ret = out[1]
                    ret = ret.split(" ")
                    print(ret)
                    if ret[0] == json_config["MD5"][v]:
                        print("md5 is ok")
                        Checked = True

                    return Checked

        return Checked
Beispiel #9
0
    def OnLoadCb(self):
        if self._URL is None:
            return
        self._img = None
        self.ClearCanvas()
        self._Screen.Draw()
        self._Screen.SwapAndShow()

        filename = self._URL.split("/")[-1].strip()
        local_dir = self._URL.split("raw.githubusercontent.com")

        if len(local_dir) > 1:
            menu_file = local_dir[1]
            local_menu_file = "%s/aria2download%s" % (os.path.expanduser('~'),
                                                      menu_file)

            if FileExists(local_menu_file):
                #load json
                with open(local_menu_file) as json_file:
                    try:
                        local_menu_json = json.load(json_file)
                        self._Caller._MyStack.Push(local_menu_json["list"])
                    except:
                        pass

                    self.Leave()

            else:
                self._Downloader = Download(self._URL, "/tmp", None)
                self._Downloader.start()
                self._DownloaderTimer = gobject.timeout_add(
                    400, self.GObjectUpdateProcessInterval)
Beispiel #10
0
    def Click(self):

        cur_li = self._MyList[self._PsIndex]

        if cur_li._MyType == ICON_TYPES["DIR"]:
            return

        if cur_li._MyType == ICON_TYPES["FILE"]:  ## add to playlist only
            self._Screen._MsgBox.SetText("Launching...")
            self._Screen._MsgBox.Draw()
            self._Screen.SwapAndShow()
            print("Run ", cur_li._Path)

            # check ROM_SO exists
            if FileExists(self._Emulator["ROM_SO"]):
                escaped_path = CmdClean(cur_li._Path)
                cmdpath = " ".join((self._Emulator["LAUNCHER"],
                                    self._Emulator["ROM_SO"], escaped_path))
                pygame.event.post(pygame.event.Event(RUNEVT, message=cmdpath))
                return
            else:

                self._Screen.PushPage(self._RomSoConfirmDownloadPage)
                self._Screen.Draw()
                self._Screen.SwapAndShow()

            return

        self._Screen.Draw()
        self._Screen.SwapAndShow()
Beispiel #11
0
    def Init(self):
        self._PosX = self._Index * self._Screen._Width
        self._Width = self._Screen._Width
        self._Height = self._Screen._Height

        self._CanvasHWND = self._Screen._CanvasHWND

        ps = InfoPageSelector()
        ps._Parent = self
        ps._PosX = 2
        self._Ps = ps
        self._PsIndex = 0

        #                ""   pkgname, label
        alist = [["", "Airplane", "Airplane Mode"],
                 ["", "PowerOptions", "Power Options"], ["", "Wifi", "Wi-Fi"],
                 ["", "Bluetooth", "Bluetooth"], ["", "Sound", "Sound Volume"],
                 ["", "Brightness", "BackLight Brightness"],
                 ["", "Storage", ""], ["", "Time", "Timezone"],
                 ["", "Languages", "Languages"],
                 ["", "Notification", "Notification"], ["", "Update", ""],
                 ["", "About", "About"], ["", "PowerOFF", "Power off"],
                 ["", "ButtonsLayout", "Buttons Layout"],
                 ["", "LauncherGo", "Switch to LauncherGo"],
                 ["", "Lima", "GPU driver switch"],
                 ["", "GateWay", "Network gateway switch"]]

        start_x = 0
        start_y = 0

        sys.path.append(myvars.basepath)  # add self as import path
        for i, v in enumerate(alist):
            li = ListItem()
            li._Parent = self
            li._PosX = start_x
            li._PosY = start_y + i * ListItem._Height
            li._Width = Width
            li._Fonts["normal"] = self._ListFontObj

            if v[2] != "":
                li.Init(v[2])
            else:
                li.Init(v[1])

            #if v[1] == "Wifi" or v[1] == "Sound" or v[1] == "Brightness" or v[1] == "Storage" or v[1] == "Update" or v[1] == "About" or v[1] == "PowerOFF" or v[1] == "HelloWorld":
            if FileExists(myvars.basepath + "/" + v[1]):
                li._LinkObj = __import__(v[1])
                init_cb = getattr(li._LinkObj, "Init", None)
                if init_cb != None:
                    if callable(init_cb):
                        li._LinkObj.Init(self._Screen)

                self._MyList.append(li)

        self._Scroller = ListScroller()
        self._Scroller._Parent = self
        self._Scroller._PosX = self._Width - 10
        self._Scroller._PosY = 2
        self._Scroller.Init()
Beispiel #12
0
    def ReadConfig(self, fname):
        if FileExists(fname):
            if self._Config == None:
                self._Config = ConfigParser.ConfigParser()
                self._Config.optionxform = str

            self._Config.read(fname)
        else:
            print(fname, "not found")
    def GeneratePathList(self, path):
        if os.path.isdir(path) == False:
            return False

        files_path = glob.glob(path + "/*")

        ret = []

        for i, v in enumerate(files_path):
            dirmap = {}
            if os.path.isdir(
                    v) and self._Emulator["FILETYPE"] == "dir":  ## like DOSBOX
                gameshell_bat = self._Emulator["EXT"][0]

                stats = os.stat(v)
                if stats.st_gid == self._Parent._FavGID:  ##skip fav roms
                    continue

                if FileExists(v + "/" + gameshell_bat):
                    try:
                        dirmap["gamedir"] = v.decode("utf8", "ignore")
                    except:
                        dirmap["gamedir"] = v.decode("ascii", "ignore")

                    ret.append(dirmap)
            if os.path.isfile(v) and self._Emulator["FILETYPE"] == "file":
                stats = os.stat(v)
                if stats.st_gid == self._Parent._FavGID:  ##skip fav roms
                    continue

                bname = os.path.basename(v)  ### filter extension
                if len(bname) > 1:
                    is_excluded = False
                    for exclude_ext in self._Emulator[
                            "EXCLUDE"]:  ## only compares filename endswith ext in EXCLUDE,splited by ,
                        if len(exclude_ext) > 1 and bname.endswith(
                                exclude_ext):
                            is_excluded = True
                            break

                    if not is_excluded:
                        pieces = bname.split(".")
                        if len(pieces) > 1:
                            if pieces[len(pieces) -
                                      1].lower() in self._Emulator["EXT"]:
                                try:
                                    dirmap["file"] = v.decode("utf8", "ignore")
                                except:
                                    dirmap["file"] = v.decode(
                                        "ascii", "ignore")

                                ret.append(dirmap)
#            else:
#                print("not file or dir")

        return ret
Beispiel #14
0
    def Click(self):
        if len(self._MyList) == 0:
            return

        if self._PsIndex > len(self._MyList) - 1:
            return
        
        cur_li = self._MyList[self._PsIndex]
        
        if cur_li._MyType == ICON_TYPES["DIR"]:
            if cur_li._Path == "[..]":
                self._MyStack.Pop()
                self.SyncList( self._MyStack.Last() )
                self._PsIndex = 0
            else:
                self._MyStack.Push( self._MyList[self._PsIndex]._Path )
                self.SyncList( self._MyStack.Last() )
                self._PsIndex = 0
                
        if cur_li._MyType == ICON_TYPES["FILE"]: 
            self._Screen._MsgBox.SetText("Launching")
            self._Screen._MsgBox.Draw()
            self._Screen.SwapAndShow()

            if self._Emulator["FILETYPE"] == "dir":
                path = cur_li._Path +"/"+self._Emulator["EXT"][0]
            else:
                path = cur_li._Path
            
            print("Run  ",path)
            
            if self._Emulator["FILETYPE"] == "dir":
                escaped_path = CmdClean(path)
            else:
                escaped_path = CmdClean(path)
                
            custom_config = ""
            if self._Emulator["RETRO_CONFIG"] != "" and len(self._Emulator["RETRO_CONFIG"]) > 5:
                custom_config = " -c " + self._Emulator["RETRO_CONFIG"]
                
            cmdpath = " ".join( (self._Emulator["LAUNCHER"],self._Emulator["ROM_SO"], custom_config, escaped_path))
                
            if self._Emulator["ROM_SO"] =="": #empty means No needs for rom so
                pygame.event.post( pygame.event.Event(RUNEVT, message=cmdpath))
            else:
                if FileExists(self._Emulator["ROM_SO"]):
                    pygame.event.post( pygame.event.Event(RUNEVT, message=cmdpath))
                else:
                    self._Screen.PushPage(self._RomSoConfirmDownloadPage)
                    self._Screen.Draw()
                    self._Screen.SwapAndShow()
                    
            return 
            
        self._Screen.Draw()
        self._Screen.SwapAndShow()
Beispiel #15
0
def PreparationInAdv():
    global SKIN, ButtonsLayout
    global PowerLevel
    global RPC
    if SKIN != None:
        return

    SKIN = "../skin/default"

    if FileExists("%s/.gameshell_skin" % os.path.expanduser('~')) == True:
        with open("%s/.gameshell_skin" % os.path.expanduser('~'), "r") as f:
            gameshell_skin = f.read()

        gameshell_skin = gameshell_skin.strip()
        SKIN = gameshell_skin

    if FileExists(".buttonslayout") == True:
        with open(".buttonslayout") as f:
            btnlayout = f.read()

        btnlayout = btnlayout.strip()
        ButtonsLayout = btnlayout
        if ButtonsLayout != "xbox" and ButtonsLayout != "snes":
            ButtonsLayout = "xbox"

    if FileExists(".powerlevel") == False:
        os.system("touch .powerlevel")

    with open(".powerlevel", "r") as f:
        powerlevel = f.read()

    powerlevel = powerlevel.strip()
    if powerlevel != "":
        PowerLevel = powerlevel
        if powerlevel != "supersaving":
            ArmSystem("sudo iw wlan0 set power_save off >/dev/null")
        else:
            ArmSystem("sudo iw wlan0 set power_save on > /dev/null")
    else:
        ArmSystem("sudo iw wlan0 set power_save off >/dev/null")

    RPC = Xmlrpc('localhost', 6800)
    def CheckPackage(self, main_screen):  ##detect zip files
        ret = False
        json_config = self._ComPkgInfo
        if not json_config:
            return ret

        cur_dir = os.getcwd()

        if FileExists(json_config["GameDir"]):
            os.chdir(json_config["GameDir"])
        else:
            os.system("mkdir %s" % json_config["GameDir"])

        if "MD5" in json_config:
            for i, v in enumerate(json_config["MD5"]):
                if FileExists(v):
                    ret = True
                    break

        os.chdir(cur_dir)
        return ret
Beispiel #17
0
    def Click(self):

        if len(self._MyList) == 0:
            return

        if self._PsIndex > len(self._MyList) - 1:
            return

        cur_li = self._MyList[self._PsIndex]

        if cur_li._MyType == ICON_TYPES["DIR"]:
            return

        if cur_li._MyType == ICON_TYPES["FILE"]:  ## add to playlist only
            self._Screen._MsgBox.SetText("Launching...")
            self._Screen._MsgBox.Draw()
            self._Screen.SwapAndShow()
            if self._Emulator["FILETYPE"] == "dir":
                path = cur_li._Path + "/" + self._Emulator["EXT"][0]
            else:
                path = cur_li._Path

            print("Run ", path)

            # check ROM_SO exists
            if FileExists(self._Emulator["ROM_SO"]):
                escaped_path = CmdClean(path)

                custom_config = ""
                if self._Emulator["RETRO_CONFIG"] != "" and len(
                        self._Emulator["RETRO_CONFIG"]) > 5:
                    custom_config = " -c " + self._Emulator["RETRO_CONFIG"]

                cmdpath = " ".join(
                    (self._Emulator["LAUNCHER"], self._Emulator["ROM_SO"],
                     custom_config, escaped_path))

                pygame.event.post(pygame.event.Event(RUNEVT, message=cmdpath))
                return
            else:

                self._Screen.PushPage(self._RomSoConfirmDownloadPage)
                self._Screen.Draw()
                self._Screen.SwapAndShow()

            return

        self._Screen.Draw()
        self._Screen.SwapAndShow()
Beispiel #18
0
    def SendMsgToUnixSocket(self, msg):
        if FileExists(self._GSNOTIFY_SOCKET) == False:
            print(self._GSNOTIFY_SOCKET, " not existed")
            return

        try:
            s = socket.socket(socket.AF_UNIX)
            s.settimeout(1)  # 1 second timeout
            s.connect(self._GSNOTIFY_SOCKET)
            s.send(msg)
            data = s.recv(1024)
            print("received: {}".format(data))
            s.close()
        except Exception as err:
            print(err)  ## print error ,but ignore it
Beispiel #19
0
    def OsImageVersion(self):
        if FileExists("/etc/clockworkpi_os_image_version"):
            try:
                with open("/etc/clockworkpi_os_image_version") as f:
                    content = f.readlines()
                content = [x.strip() for x in content]

            except:
                print("open %s failed" % "/etc/clockworkpi_os_image_version")
                content = None

            if content != None and len(content) > 0:
                os_image_ver = {}
                os_image_ver["key"] = "os_image_ver"
                os_image_ver["label"] = "OS Image:"
                os_image_ver["value"] = content[0][:12]
                self._AList["os_image_ver"] = os_image_ver
    def OsVersion(self):
        if FileExists("/etc/os-release"):
            try:
                with open("/etc/os-release") as f:
                    content = f.readlines()
                content = [x.strip() for x in content]

            except:
                print("open %s failed" % "/etc/os-release")
                content = None

            if content != None and len(content) > 0:
                os_ver = {}
                os_ver["key"] = "os_ver"
                os_ver["label"] = "OS Version:"
                os_ver["value"] = content[0][12:]
                self._AList["os_ver"] = os_ver
Beispiel #21
0
    def Init(self):
        self._PosX = self._Index * self._Screen._Width
        self._Width = self._Screen._Width
        self._Height = self._Screen._Height

        self._CanvasHWND = self._Screen._CanvasHWND

        ps = ListPageSelector()
        ps._Parent = self
        self._Ps = ps
        self._PsIndex = 0

        start_x = 0
        start_y = 0

        if self.basepath not in sys.path:
            # add self as import path
            sys.path.append(self.basepath)

        for i, v in enumerate(self.MyPages):
            li = ListItem()
            li._Parent = self
            li._PosX = start_x
            li._PosY = start_y + i * ListItem._Height
            li._Width = Width
            li._Fonts["normal"] = self._ListFontObj

            if v[1] != "":
                li.Init(v[1])
            else:
                li.Init(v[0])

            if FileExists(self.basepath + "/" + v[0]):
                li._LinkObj = __import__(v[0])
                init_cb = getattr(li._LinkObj, "Init", None)
                if init_cb != None:
                    if callable(init_cb):
                        li._LinkObj.Init(self._Screen)

                self._MyList.append(li)

        self._Scroller = ListScroller()
        self._Scroller._Parent = self
        self._Scroller._PosX = self._Width - 10
        self._Scroller._PosY = 2
        self._Scroller.Init()
    def GenList(self):

        self._MyList = []
        if self._NetworkId != -1:
            self._AList["ip"]["value"] = "Not Connected"

            if self._Wireless.GetCurrentNetworkID(
                    self._Wireless.GetIwconfig()) == self._NetworkId:
                ip = self._Wireless.GetWirelessIP('')

                if ip is not None:
                    self._AList["ip"]["value"] = ip

            self._AList["bssid"]["value"] = self._Wireless.GetWirelessProperty(
                self._NetworkId, "bssid")
            if FileExists("/sys/class/net/wlan0/address"):
                self._AList["mac_addr"]["value"] = ReadTheFileContent(
                    "/sys/class/net/wlan0/address").strip().upper()
            else:
                self._AList["mac_addr"]["value"] = ""

        start_x = 0
        start_y = 0

        for i, v in enumerate(self._AList):
            li = InfoPageListItem()
            li._Parent = self
            li._PosX = start_x
            li._PosY = start_y + i * InfoPageListItem._Height
            li._Width = Width
            li._Fonts["normal"] = self._ListFontObj
            li._Fonts["small"] = MyLangManager.TrFont("varela12")

            if self._AList[v]["label"] != "":
                li.Init(self._AList[v]["label"])
            else:
                li.Init(self._AList[v]["key"])

            li._Flag = self._AList[v]["key"]

            li.SetSmallText(self._AList[v]["value"])

            self._MyList.append(li)
Beispiel #23
0
def PreparationInAdv():

    if "arm" not in platform.machine():
        return

    if FileExists(".powerlevel") == False:
        os.system("touch .powerlevel")

    with open(".powerlevel", "r") as f:
        powerlevel = f.read()

    powerlevel = powerlevel.strip()
    if powerlevel != "":
        config.PowerLevel = powerlevel
        if powerlevel != "supersaving":
            os.system("sudo iw wlan0 set power_save off >/dev/null")
        else:
            os.system("sudo iw wlan0 set power_save on > /dev/null")
    else:
        os.system("sudo iw wlan0 set power_save off >/dev/null")
Beispiel #24
0
    def GeneratePathList(self, path):
        if os.path.isdir(path) == False:
            return False

        files_path = glob.glob(path + "/*")

        ret = []

        for i, v in enumerate(files_path):
            dirmap = {}
            if os.path.isdir(
                    v) and self._Emulator["FILETYPE"] == "dir":  ## like DOSBOX
                gameshell_bat = self._Emulator["EXT"][0]

                stats = os.stat(v)
                if stats.st_gid == self._Parent._FavGID:  ##skip fav roms
                    continue

                if FileExists(v + "/" + gameshell_bat):
                    dirmap["gamedir"] = v.decode("utf8")
                    ret.append(dirmap)
            if os.path.isfile(v) and self._Emulator["FILETYPE"] == "file":
                stats = os.stat(v)
                if stats.st_gid == self._Parent._FavGID:  ##skip fav roms
                    continue

                bname = os.path.basename(v)  ### filter extension
                if len(bname) > 1:
                    pieces = bname.split(".")
                    if len(pieces) > 1:
                        if pieces[len(pieces) -
                                  1].lower() in self._Emulator["EXT"]:
                            dirmap["file"] = v
                            ret.append(dirmap)
#            else:
#                print("not file or dir")

        return ret
Beispiel #25
0
    MyIconPool.Init()

    setup_dbus()

    gobject.threads_init()

    gobject_main_loop = gobject.MainLoop()

    #    if pygame.display.get_active() == True:
    #        print("I am actived")

    if pygame.image.get_extended() == False:
        print("This pygame does not support PNG")
        exit()

    if FileExists(".powerlevel") == False:
        os.system("touch .powerlevel")

    with open(".powerlevel", "r") as f:
        powerlevel = f.read()

    powerlevel = powerlevel.strip()
    if powerlevel != "":
        config.PowerLevel = powerlevel
        if powerlevel != "supersaving":
            os.system("sudo iw wlan0 set power_save off")
        else:
            os.system("sudo iw wlan0 set power_save on")

    big_loop()
Beispiel #26
0
    def SyncList(self):

        self._MyList = []

        start_x = 0
        start_y = 0
        last_height = 0

        repos = []
        stk = self._MyStack.Last()
        stk_lev = self._MyStack.Length()
        repos.extend(stk)
        add_new_house = [{
            "title": "Add new warehouse...",
            "file": "master/index.json",
            "type": "add_house",
            "status": "complete"
        }]

        if stk_lev == 1:  # on top
            ware_menu = self.SyncWarehouse()
            if ware_menu != None and len(ware_menu) > 0:
                #print(ware_menu)
                repos.extend(ware_menu)

            tasks_menu = self.SyncTasks()
            if tasks_menu != None and len(tasks_menu) > 0:
                #print(tasks_menu)
                repos.extend(tasks_menu)

            #print(repos)
            repos.extend(add_new_house)

        for i, u in enumerate(repos):
            #print(i,u)
            li = GameStoreListItem()
            li._CanvasHWND = self._CanvasHWND
            li._Parent = self
            li._PosX = start_x
            li._PosY = start_y + last_height
            li._Width = Width
            li._Fonts["normal"] = self._ListFont15
            li._Fonts["small"] = self._ListFont12
            li._Active = False
            li._ReadOnly = True
            li._Value = u
            li._Type = u["type"]
            li.Init(u["title"])

            if stk_lev > 1:
                remote_file_url = u["file"]
                menu_file = remote_file_url.split(
                    "raw.githubusercontent.com")[1]
                local_menu_file = "%s/aria2download%s" % (
                    os.path.expanduser('~'), menu_file)

                if FileExists(local_menu_file):
                    li._ReadOnly = False
                else:
                    li._ReadOnly = True
            elif stk_lev == 1:
                if "status" in u:
                    if u["status"] == "complete":
                        li._ReadOnly = False

                if u["type"] == "source":
                    li._ReadOnly = False

            last_height += li._Height

            if li._Type == "launcher" or li._Type == "pico8" or li._Type == "tic80":
                li.SetSmallText("")

            self._MyList.append(li)

        self.RefreshPsIndex()
Beispiel #27
0
    def Init(self):
        self._PosX = self._Index * self._Screen._Width
        self._Width = self._Screen._Width
        self._Height = self._Screen._Height

        self._CanvasHWND = self._Screen._CanvasHWND

        ps = InfoPageSelector()
        ps._Parent = self
        ps._PosX = 2
        self._Ps = ps
        self._PsIndex = 0

        #                ""   pkgname, label
        alist = [
            # ["","Airplane","Airplane Mode"],                     # haven't looked at this yet
            ["", "PowerOptions",
             "Power Options"],  # haven't looked at this yet
            # ["","Wifi","Wi-Fi"],                                 # currently lists networks, but doesn't know we're connected
            ["", "Bluetooth", "Bluetooth"
             ],  # haven't looked at this much yet, but it lists devices
            ["", "Sound", "Sound Volume"],
            ["", "Brightness", "BackLight Brightness"],
            ["", "Storage",
             ""],  # reports 6.6gb of total storage? I thought CHIP was 4gb
            # ["","Time","Timezone"],                              # lists timezones, but hangs on selection
            ["", "Languages",
             "Languages"],  # works, but haven't localized new stuff yet
            # ["","Notification","Notification"],
            # ["","Update", ""],                                   # not needed, we can update manually for now
            ["", "About", "About"],
            # ["","PowerOFF","Power OFF"],
            # ["","ButtonsLayout","Buttons Layout"],               # not needed, this is just for switching between snes/xbox layouts
            # ["","LauncherGo","Switch to LauncherGo"],            # not needed
            # ["","Lima","GPU driver switch"],                     # not needed
            # ["","GateWay","Network gateway switch"]              # haven't looked at this yet
        ]

        start_x = 0
        start_y = 0

        sys.path.append(myvars.basepath)  # add self as import path
        for i, v in enumerate(alist):
            li = ListItem()
            li._Parent = self
            li._PosX = start_x
            li._PosY = start_y + i * ListItem._Height
            li._Width = Width
            li._Fonts["normal"] = self._ListFontObj

            if v[2] != "":
                li.Init(v[2])
            else:
                li.Init(v[1])

            #if v[1] == "Wifi" or v[1] == "Sound" or v[1] == "Brightness" or v[1] == "Storage" or v[1] == "Update" or v[1] == "About" or v[1] == "PowerOFF" or v[1] == "HelloWorld":
            if FileExists(myvars.basepath + "/" + v[1]):
                li._LinkObj = __import__(v[1])
                init_cb = getattr(li._LinkObj, "Init", None)
                if init_cb != None:
                    if callable(init_cb):
                        li._LinkObj.Init(self._Screen)

                self._MyList.append(li)

        self._Scroller = ListScroller()
        self._Scroller._Parent = self
        self._Scroller._PosX = self._Width - 10
        self._Scroller._PosY = 2
        self._Scroller.Init()
Beispiel #28
0
    def Click(self):
        if self._PsIndex > len(self._MyList) - 1:
            return

        cur_li = self._MyList[self._PsIndex]
        #if cur_li._Active == True:
        #    return

        print("cur_li._Value", cur_li._Value)

        if cur_li._Value["type"] == "source" or cur_li._Value["type"] == "dir":
            remote_file_url = cur_li._Value["file"]
            menu_file = remote_file_url.split("raw.githubusercontent.com")[
                1]  #assume master branch
            local_menu_file = "%s/aria2download%s" % (os.path.expanduser('~'),
                                                      menu_file)
            print(local_menu_file)
            if FileExists(local_menu_file) == False:
                self.LoadHouse()
            else:
                #read the local_menu_file, push into stack,display menu
                self._Downloading = None
                try:
                    with open(local_menu_file) as json_file:
                        local_menu_json = json.load(json_file)
                        print(local_menu_json)
                        self._MyStack.Push(local_menu_json["list"])

                    self.SyncList()
                    self._Screen.Draw()
                    self._Screen.SwapAndShow()
                except Exception as ex:
                    print(ex)
                    self._Screen._MsgBox.SetText("Open house failed ")
                    self._Screen._MsgBox.Draw()
                    self._Screen.SwapAndShow()

        elif cur_li._Value["type"] == "add_house":
            print("show keyboard to add ware house")
            self._Screen.PushCurPage()
            self._Screen.SetCurPage(self._Keyboard)
        else:
            #download the game probably
            remote_file_url = cur_li._Value["file"]
            menu_file = remote_file_url.split("raw.githubusercontent.com")[1]
            local_menu_file = "%s/aria2download%s" % (os.path.expanduser('~'),
                                                      menu_file)

            if FileExists(local_menu_file) == False:
                gid, ret = config.RPC.urlDownloading(remote_file_url)
                if ret == False:
                    gid = config.RPC.addUri(remote_file_url,
                                            options={"out": menu_file})
                    self._Downloading = gid
                    print("stack length ", self._MyStack.Length())
                    """
                    if self._MyStack.Length() > 1:## not on the top list page
                        try:
                            conn = sqlite3.connect(self._aria2_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)
                    """
                else:
                    print(
                        config.RPC.tellStatus(
                            gid, ["status", "totalLength", "completedLength"]))

                    self._Screen._MsgBox.SetText("Getting the game now")
                    self._Screen._MsgBox.Draw()
                    self._Screen.SwapAndShow()

                    pygame.time.delay(800)
                    self._Screen._TitleBar.Redraw()

            else:
                print("file downloaded"
                      )  # maybe check it if is installed,then execute it
                if cur_li._Value[
                        "type"] == "launcher" and cur_li._ReadOnly == False:
                    local_menu_file_path = os.path.dirname(local_menu_file)
                    game_sh = os.path.join(local_menu_file_path,
                                           cur_li._Value["title"],
                                           cur_li._Value["title"] + ".sh")
                    #game_sh = reconstruct_broken_string( game_sh)
                    print("run game: ", game_sh, os.path.exists(game_sh))
                    self._Screen.RunEXE(game_sh)

                if cur_li._Value[
                        "type"] == "pico8" and cur_li._ReadOnly == False:
                    if os.path.exists(
                            "/home/cpi/games/PICO-8/pico-8/pico8") == True:
                        game_sh = "/home/cpi/launcher/Menu/GameShell/50_PICO-8/PICO-8.sh"
                        self._Screen.RunEXE(game_sh)
                    else:
                        self._Screen._MsgBox.SetText("Purchase pico8")
                        self._Screen._MsgBox.Draw()
                        self._Screen.SwapAndShow()
                        pygame.time.delay(800)

                if cur_li._Value[
                        "type"] == "tic80" and cur_li._ReadOnly == False:
                    game_sh = "/home/cpi/apps/Menu/51_TIC-80/TIC-80.sh"
                    self._Screen.RunEXE(game_sh)