def show_unread(self, rssid): t = Template() t.load(os.path.join(Globals.workpath, 'plugins/rssreader/unread_message.py'), 'python') RssDb.init(Globals.rss_dbfile) feed = RssDb.Feed.get(rssid) data = RssDb.Data.select(RssDb.and_(RssDb.Data.c.feed_id==rssid, RssDb.Data.c.read==False), order_by=[RssDb.desc(RssDb.Data.c.pubDate)]) x = dict4ini.DictIni() x.html.chanel_title = feed.title x.html.chanel_url = feed.link x.html.chanel_image_url = feed.imagelink x.html.newsletter = [] for i in data: v = dict4ini.DictIni() v.title = i.title v.link = i.link v.description = i.description v.date = i.pubDate.strftime("%Y-%m-%d %H:%M:%S") v.comments = i.comments v.comments_gif = ('file:///' + os.path.join(Globals.workpath, 'plugins/rssreader/comments.png').replace(':', '|')).replace('\\', '/') x.html.newsletter.append(v) text = t.value('html', x.dict(), encoding='utf-8') filename = os.path.join(tempfile.gettempdir(), 'rssreader.html') file(filename, 'w').write(text) self.publisher.sendMessage('change_html', filename)
def show_modules_info(win): files = glob.glob(os.path.join(win.workpath, 'plugins/*/*.pin')) plugins = [] for f in files: key = os.path.basename(os.path.dirname(f)) x = dict4ini.DictIni(f) tr_color = '#CCFFFF' platform = x.info.get('platform', '') platform = platform.upper() p = { 'name': key, 'desc': x.info.get('description', ''), 'homepage': x.info.get('homepage', ''), 'author': x.info.get('author', ''), 'date': x.info.get('date', ''), 'platform': platform, 'version': x.info.get('version', ''), 'tr_color': tr_color } plugins.append(p) m = [] for j, k in enumerate(x.modules.values()): i = x.get(k) if j % 2: t_color = '#FFFFFF' else: t_color = '#66FF00' m.append({ 'name': x[k].get('name', ''), 'homepage': x[k].get('homepage', ''), 'download': x[k].get('download', ''), 'description': x[k].get('description', ''), 'version': x[k].get('version', ''), 't_color': t_color }) p['modules'] = m from modules.meteor import Template template = Template() import T_modulesinfo template.load(T_modulesinfo, 'python') f = os.path.join(win.app.userpath, 'modulesinfo.html') try: fout = file(f, "w") fout.write(template.value('html', {'body': plugins})) fout.close() common.webopen(f) except: error.traceback() common.showerror(win, tr("Output modules information error!"))
def OnChanged(self, event): t = Template() t.load(os.path.join(Globals.workpath, 'plugins/rssreader/single_message.txt'), 'text') RssDb.init(Globals.rss_dbfile) item = event.GetIndex() index = self.list.GetItemData(item) data = RssDb.Data.get_by(guid=self.guids[index]) v = {} v["title"] = data.title v["link"] = data.link v["description"] = data.description v["date"] = data.pubDate.strftime("%Y-%m-%d %H:%M:%S") v["comments"] = data.comments v["comments_gif"] = ('file:///' + os.path.join(Globals.workpath, 'plugins/rssreader/comments.png').replace(':', '|')).replace('\\', '/') text = t.value('text', v, encoding='utf-8') filename = os.path.join(tempfile.gettempdir(), 'rssreader.html') file(filename, 'w').write(text) self.publisher.sendMessage('change_html', filename) #cal read status def check_and_update(self=self, index=item): if self.list.GetFirstSelected() == index: wx.CallAfter(self.OnCheck, index, True) t = threading.Timer(Globals.mainframe.pref.rss_read_time, check_and_update) t.start()
def show_modules_info(win): files = glob.glob(os.path.join(win.workpath, 'plugins/*/*.pin')) plugins = [] for f in files: key = os.path.basename(os.path.dirname(f)) x = dict4ini.DictIni(f) tr_color = '#CCFFFF' platform = x.info.get('platform', '') platform = platform.upper() p = {'name':key, 'desc':x.info.get('description', ''), 'homepage':x.info.get('homepage', ''), 'author':x.info.get('author', ''), 'date':x.info.get('date', ''), 'platform':platform, 'version':x.info.get('version', ''), 'tr_color':tr_color} plugins.append(p) m = [] for j, k in enumerate(x.modules.values()): i = x.get(k) if j % 2: t_color = '#FFFFFF' else: t_color = '#66FF00' m.append({'name':x[k].get('name', ''), 'homepage':x[k].get('homepage', ''), 'download':x[k].get('download', ''), 'description':x[k].get('description', ''), 'version':x[k].get('version', ''), 't_color':t_color}) p['modules'] = m from modules.meteor import Template template = Template() import T_modulesinfo template.load(T_modulesinfo, 'python') f = os.path.join(win.app.userpath, 'modulesinfo.html') try: fout = file(f, "w") fout.write(template.value('html', {'body':plugins})) fout.close() common.webopen(f) except: error.traceback() common.showerror(win, tr("Output modules information error!"))