Пример #1
0
    def db_update_handler(self, event): # wxGlade: MainFrame.<event_handler>
        dlg = wx.FileDialog(
            self, message="Choose a file",
            defaultDir=os.getcwd(), 
            defaultFile="",
            wildcard="targz files (*.tar.gz)|*.tar.gz",
            style=wx.OPEN | wx.MULTIPLE | wx.CHANGE_DIR
            )
        paths = None
        if dlg.ShowModal() == wx.ID_OK:
            paths = dlg.GetPaths()
        dlg.Destroy()
        updts = paths
        if updts:
            max = len(updts)*3*100000
            dlg = wx.ProgressDialog("Updating from files...",
                               "Extracting...Please be patient ",
                               maximum = max,
                               parent=self,
                               style = wx.PD_CAN_ABORT
                                | wx.PD_APP_MODAL
                                | wx.PD_ELAPSED_TIME
                                | wx.PD_ESTIMATED_TIME
                                #| wx.PD_REMAINING_TIME
                                )
            count = 1
            for updt in updts:
                import tarfile
                tar = tarfile.open(updt)
                tar.extractall(path=config.SS_HOME_DIR)
                tar.close()               
                update.apply_updates('verycd',dlg.Update,max-1) 
                update.apply_updates('comment',dlg.Update,max-1)
                update.apply_updates('lock',dlg.Update,max-1)
            dlg.Update(max,'Finished')
            update.delete_tempfiles()
            update.update_timestamp()
	    dlg.Destroy()
Пример #2
0
    def update_handler(self, event): # wxGlade: MainFrame.<event_handler>
        ids = update.get_update_ids()
        if len(ids) == 0:
            dialog_updated = UpdatedDialog(None, -1, "")
            app.SetTopWindow(dialog_updated)
            dialog_updated.ShowModal()
            dialog_updated.Destroy()
            return
        elif ids[0].startswith('new:'):
            dlg = wx.MessageDialog(self, ids[0][4:],
                               'Update Error',
                               wx.OK | wx.ICON_INFORMATION
                               #wx.YES_NO | wx.NO_DEFAULT | wx.CANCEL | wx.ICON_INFORMATION
                               )
            dlg.ShowModal()
            dlg.Destroy()
        elif config.SS_UPDATE_SOURCE == 'verycd':
            max = len(ids)
            print max
            dlg = wx.ProgressDialog("Updating Databases...",
                               'Processing 1/%d' % (max*2/3),
                               maximum = max,
                               parent=self,
                               style = wx.PD_CAN_ABORT
                                | wx.PD_APP_MODAL
                                | wx.PD_ELAPSED_TIME
                                | wx.PD_ESTIMATED_TIME
                                #| wx.PD_REMAINING_TIME
                                )
            import fetchvc
            lastid = fetchvc.update_ids(ids,dlg.Update,max)
            print lastid
            dlg.Update(max,'Finished')
            update.update_db_updtime(lastid)
            dlg.Destroy()
        elif config.SS_UPDATE_SOURCE == 'simplecd':
            group = 5
            max = ((len(ids)-1)/group+1)*3*2
            dlg = wx.ProgressDialog("Updating Databases...",
                               "Downloading 1/%d"%(max/2),
                               maximum = max,
                               parent=self,
                               style = wx.PD_CAN_ABORT
                                | wx.PD_APP_MODAL
                                | wx.PD_ELAPSED_TIME
                                | wx.PD_ESTIMATED_TIME
                                #| wx.PD_REMAINING_TIME
                                )
            keepGoing = True
            count = 0
            httpconn = httplib.HTTPConnection("www.simplecd.org")
            # group ids, 100 per group
            for i in range(0,max/3/2):
                subids = ids[i*group:i*group+group]
                for dbname in ['verycd','lock']:
                    update.download_updates(dbname,subids,httpconn=httpconn)
                    count += 1
                    (keepGoing, skip) = dlg.Update(count, "Downloading %d/%d"%(count,max/2))
                    if not keepGoing:
                        break
                if not keepGoing:
                    break
    	    # Apply_updates
    	    update.apply_updates('verycd',dlg.Update,max)
    	    #update.apply_updates('comment',dlg.Update,max)
	    open(config.SS_HOME_DIR+'/comment.updates','w').write('')
    	    update.apply_updates('lock',dlg.Update,max)
    	    dlg.Update(max,'Finished')
    	    # others
    	    if not update.delete_tempfiles().startswith('error'):
                update.update_db_updtime(ids[i*group-1])
                if i>=max/6:
                    print ids
                    update.update_db_updtime(ids[-1])
    	    dlg.Destroy()