Beispiel #1
0
 def update(self):
     self.get_unreads()
     if self.mail_count == 0:
         self.data = ['No new mail...']
         self.tooltip = 'No new mail...'
         self.mails_old = {}
         return False
     if 'Inbox' in self.mails:
         self.remove_duplicates()
     data = []
     # loop through user's mailbox list instead, to ensure correct mailbox order
     for mailbox in self.mailboxes:
         if mailbox not in self.mails:
             continue
         mails = []
         for mail in self.mails[mailbox]:
             mails.append((mail['Subject'],
                          self.open_browser,
                          formatTooltip([
                             ('From', mail['From']),
                             ('Date', mail['Date'])
                          ])
             ))
         data.append((
             '%s (%s)' % (mailbox, len(mails)),
             mails
         ))
     self.data = data
     self.tooltip = '%i new mail(s)!' % self.mail_count
     return (True if not self.mail_failed else None)
Beispiel #2
0
 def notify(self):
     if len(self.new) == 0:
         return False
     notifications = []
     for n in self.new:
         notifications.append((
             n['name'],
             formatTooltip([
                 ('Uploaded', bytes_to_str(n['uploaded'])),
                 ('Ratio', '%.2f' % n['ratio'])
             ])
         ))
     self.notifications = notifications
     return True
Beispiel #3
0
 def update(self):
     temps = Temps(self.method)
     self.critical = False
     self.critical_value = 0.0
     data = []
     templist = []
     fanlist = []
     for temp in temps:
         if self.ignore(temp['id']):
             continue
         values = []
         for t in temp['values']:
             if self.ignore(t['id']):
                 continue
             if t['value'][-1] == 'C':
                 val = float(t['value'].replace('\xc2\xb0C', ''))
                 templist.append(val)
                 if val >= self.max and val > self.critical_value:
                     self.critical = True
                     self.critical_value = val
                     self.critical_id = t['id']
             else:
                 val = float(t['value'])
                 fanlist.append(val)
                 t['value'] = '%s RPM' % t['value']
             values.append('%s: %s' % (t['id'], t['value']))
         data.append((
             temp['id'],
             values
         ))
     temp_avg = sum(templist) / len(templist)
     fan_avg = sum(fanlist) / len(fanlist)
     
     step = '5'
     top = max(templist)
     for key in self.steps:
         if top < self.steps[key]:
             step = key
             break
     self.icon = 'temp' + step
     
     self.data = data
     temp_str = 'no information' if len(templist) == 0 else '%.1f\xc2\xb0C' % temp_avg
     fan_str = 'no information' if len(fanlist) == 0 else '%.1f RPM' % fan_avg
     self.tooltip = formatTooltip([
         ('Temperatures', temp_str),
         ('Fan speeds', fan_str)
     ])
     return self.critical
Beispiel #4
0
 def notify(self):
     self.filter_new_ones()
     notifications = []
     for mailbox in self.mails_new:
         for mail in self.mails_new[mailbox]:
             mail_from = mail['From'].replace('<','&lt;').replace('>','&gt;')
             notifications.append((
                 mail['Subject'],
                 formatTooltip([
                     ('From', mail_from),
                     ('Date', mail['Date'])
                 ])
             ))
     self.notifications = notifications
     return (len(notifications) > 0)
Beispiel #5
0
 def update(self):
     self.pkgs = self.ArchPkgs.search()
     if self.pkgs == None:
         return None
     count = len(self.pkgs)
     if count == 0:
         self.tooltip = 'No updates, your system is up-to-date!'
         self.data = 'Your system is up-to-date!'
         return False
     else:
         self.tooltip = '%i update(s)!' % count
         data = []
         for repo in self.repos:
             repo_pkgs = [p for p in self.pkgs if p.repo == repo]
             repo_count = len(repo_pkgs)
             if repo_count > 0:
                 p = repo_pkgs[0]
                 data.append((
                     '%s (%i)' % (repo, repo_count),
                     [('%s (%s -> %s)' % (p.name, p.version_old, p.version),
                       formatTooltip([(p.info[key][0],p.info[key][1]) for key in p.info if isint(key)])) for p in repo_pkgs]
                 ))
         self.data = data
         return True
Beispiel #6
0
 def update(self):
     try:
         self.torrents = self.rtorrent.get_torrents()
         downloaded, uploaded, downspeed, upspeed = self.rtorrent.get_global_vars()
     except:
         self.tooltip = 'RTorrent or RPC server isn\'t running.'
         self.data = self.tooltip
         self.icon = 'idle'
         return False
     if len(self.torrents) == 0:
         self.uncompleted = []
         self.tooltip = 'No torrents opened.'
         self.data = self.tooltip
         self.icon = 'idle'
         return False
     
     self.filter_new()
     
     data = []
     downloading_count = 0
     seeding_count = 0
     completed_count = 0
     stopped_count = 0
     ETA = 0
     
     for t in self.torrents:
         if len(t['name']) > self.settings['menu-wrap']-16:
             t_name = t['name'][:self.settings['menu-wrap']-19] + '...'
         else:
             t_name = t['name']
         if t['state'] == 0:
             if t['percentage'] == 100.0:
                 state = 'completed'
                 state_symbol = '\xe2\x9c\x93'
                 completed_count += 1
             else:
                 state = 'stopped'
                 state_symbol = '\xc3\x97'
                 stopped_count += 1
         else:
             if t['percentage'] == 100.0:
                 state = 'seeding'
                 state_symbol = '\xe2\x86\x91'
                 seeding_count += 1
             else:
                 state = 'downloading'
                 state_symbol = '\xe2\x86\x93'
                 downloading_count += 1
         if t['ETA'] > ETA: ETA = t['ETA']
         info = [
             ('Full name',t['name']),
             ('ETA', seconds_to_str(t['ETA'])) if t['ETA'] > 0 else None,
             ('Downloaded', bytes_to_str(t['downloaded']) + ((' / ' + bytes_to_str(t['size'])) if t['percentage'] != 100.0 else '')),
             ('Uploaded', bytes_to_str(t['uploaded'])),
             ('Ratio', '%.2f' % t['ratio']),
             ('Down', bytes_to_str(t['downspeed'], True) + '/s') if t['percentage'] != 100.0 or t['state'] != 0 else None,
             ('Up', bytes_to_str(t['upspeed'], True) + '/s') if t['state'] != 0 else None,
             ('Peers', '%i peers / %i seeds (%i)' % (t['peers'], t['seeds'], t['total-peers'])),
             ('Files', str(t['files']) + ' / ' + str(t['total-files'])),
             ('Total size', bytes_to_str(t['total-size'])) if t['total-size'] != t['downloaded'] else None
         ]
         info = [i for i in info if i != None]
         data.append((
             '[%s] %s (%s%%)' % (state_symbol, t_name, ('%.2f' % t['percentage']) if t['percentage'] != 100.0 else '100'),
             formatTooltip(info)
         ))
     self.data = data
     
     tooltip = [
         '%i\xe2\x86\x93 / %i\xe2\x86\x91 / %i\xe2\x9c\x93 / %i\xc3\x97' % (downloading_count, seeding_count, completed_count, stopped_count),
         ('Downloaded', bytes_to_str(downloaded)),
         ('Uploaded', bytes_to_str(uploaded)),
         ('Down', bytes_to_str(downspeed, True) + '/s'),
         ('Up', bytes_to_str(upspeed, True) + '/s'),
         ('ETA', seconds_to_str(ETA)) if ETA > 0 else None
     ]
     tooltip = [t for t in tooltip if t != None]
     self.tooltip = formatTooltip(tooltip)
     
     if len(self.new) > 0:
         self.icon = 'new'
     elif downloading_count > 0:
         if seeding_count > 0:
             self.icon = 'both'
         else:
             self.icon = 'downloading'
     elif seeding_count > 0:
         self.icon = 'seeding'
     else:
         self.icon = 'stopped'
     
     return (len(self.new) > 0)