Commits

Michael Shepanski committed 2605034

Fix GoogleCalendar bullet images

  • Participants
  • Parent commits 15d4b2e

Comments (0)

Files changed (2)

File pkmeter/meters/googlecalendar.py

 #! /usr/bin/python
 # -*- coding: utf-8 -*-
-import datetime, HTMLParser, optparse, codecs, sys
+import datetime, HTMLParser, optparse, shutil, codecs, sys
 from pkmeter.meters.basemeter import BaseMeter
 from pkmeter import utils
 from pkmeter.utils import settings
 
+BULLETIMG = "%s/googlecalendar-bullet-%s.cache"
+
 
 class GoogleCalendar(BaseMeter):
 
             return self.rclines
         utils.gen.info("  GOOGLE_CALENDAR_FEEDS set (meter enabled)")
         self.rclines.append("### %s ###" % self.__class__.__name__)
-        self.add_execpi('30', "python %s -y %s" % (__file__.rstrip('c'), self.ypos))
+        self.add_execpi('300', "python %s -y %s" % (__file__.rstrip('c'), self.ypos))
         self.add_spacer()
         return self.rclines
 
     def add_events(self):
         for event in self.events:
             self.numevents += 1
+            imgpath = self.copy_img(event, event['color'], self.numevents)
             voffset = self.ypos + 31 + ((self.numevents - 1) * 11)
             title = "${goto 20}%s" % utils.truncate(event["title"], 25)
             timestr = self.event_time(event['date'])
-            self.rclines.append("${image %s/bullets/bullet_%s.png -p 0,%s -s 16x16}${voffset -11}" % (settings.IMGPATH, event["color"], voffset))
+            self.rclines.append("${image %s -p 0,%s -s 16x16}${voffset -11}" % (imgpath, voffset))
             self.add_row(title, timestr, execp=True)
             if self.numevents >= settings.GOOGLE_CALENDAR_NUMEVENTS: break
 
         time = time.replace(":00", "").replace("12am", "All Day").lstrip("0")
         return "%s, %s" % (day, time)
 
+    def copy_img(self, event, color, i):
+        shareimg = "%s/bullets/bullet_%s.png" % (settings.IMGPATH, color)
+        cacheimg = "%s/googlecalendar-bullet-%s.cache" % (settings.CACHEDIR, i)
+        shutil.copyfile(shareimg, cacheimg)
+        return cacheimg
+
+
 
 if __name__ == '__main__':
     sys.stdout = codecs.getwriter('UTF-8')(sys.stdout)

File share/img/bullets/transparent.png

Added
New image