예제 #1
0
    def cleanup(self):
        if any([download.downloading for download in self.downloads.values()]):
            if wx.MessageBox(_("还有任务在下载,是否真的退出?"), _("恒睿下载"),
                             wx.YES_NO | wx.ICON_QUESTION, self) == wx.NO:
                return False

        for download in self.downloads.values():
            download.stop_download()

        # 等待所有下载停止,超过2分钟则直接退出
        t = datetime.datetime.now()
        while any(
            [download.downloading for download in self.downloads.values()]):
            time.sleep(0.5)
            if (datetime.datetime.now() - t).total_seconds() > 120:
                break

        d = [download.to_dict() for download in self.downloads.values()]

        logfile = os.path.join(appPath, 'log.json')

        data = {
            'save_time': helper.now_str(),
            'downloads': d,
        }

        with open(logfile, 'w', encoding='utf-8') as f:
            try:
                json.dump(data, f, ensure_ascii=False, indent=4)
            except Exception as e:
                wx.MessageBox(_('不能保存下载记录:{e}').format(e=e))

        self.config.write_config()

        return True
예제 #2
0
 def on_timer(self, event):
     self.SetStatusText(helper.now_str(), 3)
     dls, tspeed = self.panel.refresh_download_lists()
     if dls > 0:
         self.SetStatusText(_('正在下载任务数:{}').format(dls), 1)
         self.SetStatusText(
             _('下载总速度:{}').format(helper.strspeed(tspeed)), 2)
     else:
         self.SetStatusText('', 1)
         self.SetStatusText('', 2)
예제 #3
0
 def init_statusbar(self):
     self.CreateStatusBar(number=4)
     self.SetStatusWidths([-1, 200, 200, 120])
     self.SetStatusText(_("欢迎使用恒睿下载..."))
     self.SetStatusText(helper.now_str(), 3)
예제 #4
0
def update_content(id, url, title, text, author, pagetype):
    db.update('cms_content', where="id=$id", vars=locals(),
        url=url, title=title, content=text, pagetype=pagetype,
        author = author, updatetime = helper.now_str())
예제 #5
0
def new_content(url, title, text, author='macfeng admin', pagetype=0):
    db.insert('cms_content', url=url, title=title, content=text,pagetype=pagetype,author=author,updatetime = helper.now_str())
예제 #6
0
 def __init__(self,Id=0,title='no title',postdate=helper.now_str(),url='/webpy/index',author='macfeng admin',content='',pagetype=0):
     super.__init__(Id,title,postdate,author,url)
     self.Content = content
     self.PageType = pagetype
예제 #7
0
 def __init__(self,Id=0,title='no title',postdate=helper.now_str(),url='/webpy/index',author='macfeng admin'):
     self.ID = Id
     self.Title = title
     self.PostDate = postdate
     self.Author = author
     self.Url = url