Exemplo n.º 1
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)
Exemplo n.º 2
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)
Exemplo n.º 3
0
    def StartDownload(self,url,dst_dir):
        if validators.url(url) and os.path.isdir(dst_dir):
            self._URL = url
            self._DST_DIR = dst_dir
        else:
            self._Screen._MsgBox.SetText("Invaid")
            self._Screen._MsgBox.Draw()
            self._Screen.SwapAndShow()            
            return
        
        self._Downloader = Download(url,dst_dir,None)
        if self._MD5 != None:
            if len(self._MD5) == 32:
                self._Downloader.add_hash_verification('md5' ,self._MD5) ## hashlib provide algorithms

        self._Downloader.start()
        
        self._DownloaderTimer = gobject.timeout_add(100, self.GObjectUpdateProcessInterval)
Exemplo n.º 4
0
 def StartDownload(self,url,dst_dir):
     if is_wifi_connected_now() == False:
         return
     
     if validators.url(url) and os.path.isdir(dst_dir):
         self._URL = url
         self._DST_DIR = dst_dir
     else:
         self._Screen._MsgBox.SetText("Invaid")
         self._Screen._MsgBox.Draw()
         self._Screen.SwapAndShow()            
         print("url or dst dir error")
         return
     
     self._Downloader = Download(url,dst_dir,None)
     self._Downloader.start()
     
     self._DownloaderTimer = gobject.timeout_add(100, self.GObjectUpdateProcessInterval)