def __init__(self, trayicon, tooltip):
super(TaskBarIcon, self).__init__()
self.show_no_updates = False
# Set trayicon and tooltip
icon = wx.Icon(wx.Bitmap(trayicon))
self.SetIcon(icon, tooltip)
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DCLICK, self.on_upgrade)
self.Bind(wx.adv.EVT_TASKBAR_BALLOON_CLICK, self.on_bubble)
self.upd_error_count = 0
self.checking_updates = False
self.updates_available = False
self.shutdown_scheduled = False
self.reboot_scheduled = False
self.bootup_time = getBootUp()
if update_interval and update_method:
self.timer = wx.Timer(self)
self.Bind(wx.EVT_TIMER, self.on_timer, self.timer)
self.timer.Start(update_interval)
if update_startup:
self.on_timer(None)
if check_bootup_log:
last_check = check_file_date(xml_file)
now = datetime.datetime.now()
if (self.bootup_time + datetime.timedelta(hours=1) > now) and \
(self.bootup_time + datetime.timedelta(minutes=30) > last_check):
log, errorlog, reboot = check_eventlog(self.bootup_time)
if errorlog:
error_str = _(u"Update error detected\n"
u"during system start up.")
self.ShowBalloon(title=_(u'WPKG Error'), text=error_str, msec=20*1000, flags=wx.ICON_ERROR)
title = _(u"System start error")
dlg = ViewLogDialog(title=title,log=errorlog)
dlg.ShowModal()
if check_last_upgrade:
# Check if the last changes to the local wpkg.xml are older than a specific time
# Inform USER that he should upgrade the System
last_check = check_file_date(xml_file)
if last_check < (datetime.datetime.now() - datetime.timedelta(days=last_upgrade_interval)):
dlg_str = _(u"System should be updated!\n\n"
u"System wasn't updated in over {} days.").format(str(last_upgrade_interval))
dlg = wx.MessageDialog(None, dlg_str, _(u"Attention!"), wx.OK | wx.ICON_EXCLAMATION)
dlg.ShowModal()
self.on_upgrade(None)
评论列表
文章目录