Merge lp:~jsjgruber/ubuntu/precise/lernid/ubuntu-proposed into lp:ubuntu/precise/lernid
- Precise (12.04)
- ubuntu-proposed
- Merge into precise
Status: | Merged |
---|---|
Merged at revision: | 11 |
Proposed branch: | lp:~jsjgruber/ubuntu/precise/lernid/ubuntu-proposed |
Merge into: | lp:ubuntu/precise/lernid |
Diff against target: |
359 lines (+146/-29) 6 files modified
debian/changelog (+18/-0) lernid/Event.py (+4/-1) lernid/Sessions.py (+39/-11) lernid/widgets/Browser.py (+1/-1) lernid/widgets/Schedule.py (+66/-11) lernid/widgets/Slide.py (+18/-5) |
To merge this branch: | bzr merge lp:~jsjgruber/ubuntu/precise/lernid/ubuntu-proposed |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel Holbach (community) | Approve | ||
John S. Gruber (community) | Needs Resubmitting | ||
Brian Murray | Needs Fixing | ||
Ubuntu branches | Pending | ||
Review via email: mp+101766@code.launchpad.net |
Commit message
Description of the change
Patches to fix the two related bugs. Tested 11 Apr 12 in #ubuntu-classroom with a member of the classroom team.
I'm afraid I mastakenly burned through 0.8.2.2ubuntu1 in testing, please use 0.8.2.2ubuntu2 as the release version.
Built package at ppa:jsjgruber/
Log of testing in #ubuntu-classroom at http://
Changes needed because of two API changes, one in telepathy-idle and one in poppler.
lernid is not in Debian or other non-Ubuntu distribution.
John S. Gruber (jsjgruber) wrote : | # |
John S. Gruber (jsjgruber) wrote : | # |
Patches are from upstream development and are to be included in our next upstream release.
Brian Murray (brian-murray) wrote : | # |
The development of Precise has now reached Final Freeze so we are working all updates as Stable Release Updates. Subsequently, the bugs that this branch fixes will need test cases so we can recreate the problem and ensure that the fix does work. Could you please update the bugs appropriately? Thanks!
John S. Gruber (jsjgruber) wrote : | # |
The bugs have been update with test cases.
Package is in universe.
See also http://
Thank you.
Daniel Holbach (dholbach) wrote : | # |
Good work. Thanks.
Preview Diff
1 | === modified file 'debian/changelog' | |||
2 | --- debian/changelog 2011-12-31 02:04:45 +0000 | |||
3 | +++ debian/changelog 2012-04-12 16:09:22 +0000 | |||
4 | @@ -1,3 +1,21 @@ | |||
5 | 1 | lernid (0.8.2.2ubuntu2) UNRELEASED; urgency=low | ||
6 | 2 | |||
7 | 3 | * Prepare for application to Ubuntu (universe) | ||
8 | 4 | |||
9 | 5 | -- John S Gruber <JohnSGruber@gmail.com> Thu, 12 Apr 2012 11:38:30 -0400 | ||
10 | 6 | |||
11 | 7 | lernid (0.8.2.2ubuntu2~testlernidppa2) precise; urgency=low | ||
12 | 8 | |||
13 | 9 | * Dynamically load the schedule each minute at 5 seconds past the minute | ||
14 | 10 | Addresses LP: #925756 | ||
15 | 11 | |||
16 | 12 | * Slide.py have poppler render to a cairo surface and use a trick to | ||
17 | 13 | get that into the pixmap. (LP: #972069) | ||
18 | 14 | (Technique from diogodivision's "BlingSwitcher" through | ||
19 | 15 | http://www.mikedesjardins.net. Thank you.) | ||
20 | 16 | |||
21 | 17 | -- John S Gruber <JohnSGruber@gmail.com> Wed, 04 Apr 2012 22:05:00 -0400 | ||
22 | 18 | |||
23 | 1 | lernid (0.8.2.2~lr2build1) precise; urgency=low | 19 | lernid (0.8.2.2~lr2build1) precise; urgency=low |
24 | 2 | 20 | ||
25 | 3 | * Rebuild to drop python2.6 dependencies. | 21 | * Rebuild to drop python2.6 dependencies. |
26 | 4 | 22 | ||
27 | === modified file 'lernid/Event.py' | |||
28 | --- lernid/Event.py 2011-09-03 23:25:12 +0000 | |||
29 | +++ lernid/Event.py 2012-04-12 16:09:22 +0000 | |||
30 | @@ -41,7 +41,10 @@ | |||
31 | 41 | 41 | ||
32 | 42 | @property | 42 | @property |
33 | 43 | def icalurl(self): | 43 | def icalurl(self): |
35 | 44 | return self._icalurl | 44 | if self._icalurl.upper().startswith("HTTPS"): |
36 | 45 | return self._icalurl[0:4] + self._icalurl[5:] | ||
37 | 46 | else: | ||
38 | 47 | return self._icalurl | ||
39 | 45 | 48 | ||
40 | 46 | @property | 49 | @property |
41 | 47 | def classroom(self): | 50 | def classroom(self): |
42 | 48 | 51 | ||
43 | === modified file 'lernid/Sessions.py' | |||
44 | --- lernid/Sessions.py 2011-09-03 23:25:12 +0000 | |||
45 | +++ lernid/Sessions.py 2012-04-12 16:09:22 +0000 | |||
46 | @@ -25,6 +25,7 @@ | |||
47 | 25 | 25 | ||
48 | 26 | import lernid.DateTime as dt | 26 | import lernid.DateTime as dt |
49 | 27 | import io | 27 | import io |
50 | 28 | import gio, glib | ||
51 | 28 | from datetime import timedelta | 29 | from datetime import timedelta |
52 | 29 | 30 | ||
53 | 30 | one_week = timedelta(days=7) | 31 | one_week = timedelta(days=7) |
54 | @@ -35,8 +36,15 @@ | |||
55 | 35 | 36 | ||
56 | 36 | def __init__(self, **kwargs): | 37 | def __init__(self, **kwargs): |
57 | 37 | for k, v in kwargs.iteritems(): | 38 | for k, v in kwargs.iteritems(): |
60 | 38 | if k in ('title', 'description', 'instructors', 'helpers', 'local_start', 'local_end', 'slides', 'event', 'locale', 'question_token'): | 39 | if k in ('uid', 'title', 'description', 'instructors', |
61 | 39 | setattr(self, '_'+k, v) | 40 | 'helpers', 'local_start', 'local_end', 'slides', |
62 | 41 | 'event', 'locale', | ||
63 | 42 | 'question_token'): | ||
64 | 43 | setattr(self, '_'+k, v) | ||
65 | 44 | |||
66 | 45 | @property | ||
67 | 46 | def uid(self): | ||
68 | 47 | return self._uid | ||
69 | 40 | 48 | ||
70 | 41 | @property | 49 | @property |
71 | 42 | def title(self): | 50 | def title(self): |
72 | @@ -103,9 +111,12 @@ | |||
73 | 103 | if now > end: | 111 | if now > end: |
74 | 104 | return self.PAST | 112 | return self.PAST |
75 | 105 | 113 | ||
76 | 114 | def start_read_ical(url, when_done): | ||
77 | 115 | gfile = gio.File(uri=url) | ||
78 | 116 | r = gfile.load_contents_async(when_done) | ||
79 | 106 | 117 | ||
82 | 107 | def parse_ical(event): | 118 | def read_ical(gfile,result,userdata): |
83 | 108 | """Parse iCal schedule for event and generate a list of Session objects""" | 119 | event, old_ical = userdata |
84 | 109 | default_cal_error = ( | 120 | default_cal_error = ( |
85 | 110 | u"""BEGIN:VCALENDAR | 121 | u"""BEGIN:VCALENDAR |
86 | 111 | BEGIN:VEVENT | 122 | BEGIN:VEVENT |
87 | @@ -115,7 +126,23 @@ | |||
88 | 115 | SUMMARY: """ + _('Unable to load calendar %s\n') + | 126 | SUMMARY: """ + _('Unable to load calendar %s\n') + |
89 | 116 | u"""END:VEVENT | 127 | u"""END:VEVENT |
90 | 117 | END:VCALENDAR""") % event.icalurl | 128 | END:VCALENDAR""") % event.icalurl |
92 | 118 | default_cal_error2 = ( | 129 | |
93 | 130 | try: | ||
94 | 131 | |||
95 | 132 | calstring = gfile.load_contents_finish(result)[0] | ||
96 | 133 | ical = io.StringIO(unicode(calstring)) | ||
97 | 134 | except (gio.Error, glib.GError): | ||
98 | 135 | logging.error('Unable to open calendar %s' % event.icalurl) | ||
99 | 136 | if old_ical: | ||
100 | 137 | ical = old_ical | ||
101 | 138 | ical.seek(0) | ||
102 | 139 | else: | ||
103 | 140 | ical = io.StringIO(default_cal_error) | ||
104 | 141 | return ical | ||
105 | 142 | |||
106 | 143 | |||
107 | 144 | def parse_ical(event, ical): | ||
108 | 145 | default_cal_error = ( | ||
109 | 119 | u"""BEGIN:VCALENDAR | 146 | u"""BEGIN:VCALENDAR |
110 | 120 | BEGIN:VEVENT | 147 | BEGIN:VEVENT |
111 | 121 | DTSTART:20100101T000000Z | 148 | DTSTART:20100101T000000Z |
112 | @@ -124,16 +151,12 @@ | |||
113 | 124 | SUMMARY: """ + _('Unable to parse calendar %s\n') + | 151 | SUMMARY: """ + _('Unable to parse calendar %s\n') + |
114 | 125 | u"""END:VEVENT | 152 | u"""END:VEVENT |
115 | 126 | END:VCALENDAR""") % event.icalurl | 153 | END:VCALENDAR""") % event.icalurl |
121 | 127 | try: | 154 | |
117 | 128 | ical = urllib2.urlopen(event.icalurl, None, 30) | ||
118 | 129 | except IOError: | ||
119 | 130 | logging.error('Unable to open calendar %s' % event.icalurl) | ||
120 | 131 | ical = io.StringIO(default_cal_error) | ||
122 | 132 | try: | 155 | try: |
123 | 133 | cal = vobject.readOne(ical) | 156 | cal = vobject.readOne(ical) |
124 | 134 | except: | 157 | except: |
125 | 135 | logging.critical('Error parsing calendar at %s' % event.icalurl) | 158 | logging.critical('Error parsing calendar at %s' % event.icalurl) |
127 | 136 | cal = vobject.readOne(io.StringIO(default_cal_error2)) | 159 | cal = vobject.readOne(io.StringIO(default_cal_error)) |
128 | 137 | 160 | ||
129 | 138 | sessions = [] | 161 | sessions = [] |
130 | 139 | 162 | ||
131 | @@ -158,12 +181,17 @@ | |||
132 | 158 | summary = session.summary.value | 181 | summary = session.summary.value |
133 | 159 | else: | 182 | else: |
134 | 160 | summary = _('Missing Session Name') | 183 | summary = _('Missing Session Name') |
135 | 184 | if hasattr(session, "uid"): | ||
136 | 185 | uid = session.uid | ||
137 | 186 | else: | ||
138 | 187 | uid = 0 | ||
139 | 161 | if eventstart_local <= local_start <= eventend_local: | 188 | if eventstart_local <= local_start <= eventend_local: |
140 | 162 | if local_start > dt.now_local() - one_week: | 189 | if local_start > dt.now_local() - one_week: |
141 | 163 | sessions.append(Session( | 190 | sessions.append(Session( |
142 | 164 | title = summary, | 191 | title = summary, |
143 | 165 | local_start = local_start, | 192 | local_start = local_start, |
144 | 166 | local_end = local_end, | 193 | local_end = local_end, |
145 | 194 | uid = uid, | ||
146 | 167 | **session_data)) | 195 | **session_data)) |
147 | 168 | 196 | ||
148 | 169 | # reverse the list to get the events in chronological order | 197 | # reverse the list to get the events in chronological order |
149 | 170 | 198 | ||
150 | === modified file 'lernid/widgets/Browser.py' | |||
151 | --- lernid/widgets/Browser.py 2011-09-03 23:25:12 +0000 | |||
152 | +++ lernid/widgets/Browser.py 2012-04-12 16:09:22 +0000 | |||
153 | @@ -205,7 +205,7 @@ | |||
154 | 205 | self.set_location(url) | 205 | self.set_location(url) |
155 | 206 | 206 | ||
156 | 207 | def _classroom_msg_received(self, classroom, chan, sender, text): | 207 | def _classroom_msg_received(self, classroom, chan, sender, text): |
158 | 208 | if not Options.get('unsafe-override') and not chan.is_moderated() and not self._on_faculty(sender): | 208 | if not Options.get('unsafe-override') and not self._on_faculty(sender): |
159 | 209 | return | 209 | return |
160 | 210 | load, ignore = self._parse_urls(text) | 210 | load, ignore = self._parse_urls(text) |
161 | 211 | if load and not self._paused: | 211 | if load and not self._paused: |
162 | 212 | 212 | ||
163 | === modified file 'lernid/widgets/Schedule.py' | |||
164 | --- lernid/widgets/Schedule.py 2011-09-03 23:25:12 +0000 | |||
165 | +++ lernid/widgets/Schedule.py 2012-04-12 16:09:22 +0000 | |||
166 | @@ -23,6 +23,8 @@ | |||
167 | 23 | import gtk | 23 | import gtk |
168 | 24 | import os | 24 | import os |
169 | 25 | import time | 25 | import time |
170 | 26 | import urlparse | ||
171 | 27 | import random | ||
172 | 26 | import pynotify | 28 | import pynotify |
173 | 27 | import logging | 29 | import logging |
174 | 28 | from datetime import timedelta | 30 | from datetime import timedelta |
175 | @@ -30,7 +32,7 @@ | |||
176 | 30 | import lernid.DateTime as dt | 32 | import lernid.DateTime as dt |
177 | 31 | from lernid.widgets.Widget import Widget | 33 | from lernid.widgets.Widget import Widget |
178 | 32 | from lernid.lernidconfig import get_data_path | 34 | from lernid.lernidconfig import get_data_path |
180 | 33 | from lernid.Sessions import Session, parse_ical | 35 | from lernid.Sessions import Session, parse_ical, read_ical, start_read_ical |
181 | 34 | 36 | ||
182 | 35 | 37 | ||
183 | 36 | class Schedule(Widget): | 38 | class Schedule(Widget): |
184 | @@ -116,11 +118,68 @@ | |||
185 | 116 | self._schedule = None | 118 | self._schedule = None |
186 | 117 | self._current_session = None | 119 | self._current_session = None |
187 | 118 | self._update_handle = None | 120 | self._update_handle = None |
188 | 121 | self._ical = None | ||
189 | 122 | self._icalurl = None | ||
190 | 123 | self._connected = False | ||
191 | 119 | 124 | ||
192 | 120 | self.show_all() | 125 | self.show_all() |
193 | 121 | 126 | ||
194 | 122 | def do_event_connect(self, event_man, event): | 127 | def do_event_connect(self, event_man, event): |
195 | 123 | self._event = event_man.current_event() | 128 | self._event = event_man.current_event() |
196 | 129 | self._connected = True | ||
197 | 130 | def finished_initial_ical_load(gfile, result): | ||
198 | 131 | self._ical = read_ical(gfile, result, (event,self._ical)) | ||
199 | 132 | logging.debug('Finished initial ical load') | ||
200 | 133 | if not (gfile.get_uri() == self._icalurl): | ||
201 | 134 | logging.debug('Old I/O completion ignored') | ||
202 | 135 | return | ||
203 | 136 | self._update(event, self._ical) | ||
204 | 137 | secs = time.localtime().tm_sec | ||
205 | 138 | self._update_handle = glib.timeout_add_seconds(65-secs, set_timeout) | ||
206 | 139 | def scramble_case(string): | ||
207 | 140 | random.seed() | ||
208 | 141 | newstring = '' | ||
209 | 142 | for s in string: | ||
210 | 143 | if random.random() >= .5: | ||
211 | 144 | newstring += s.upper() | ||
212 | 145 | else: | ||
213 | 146 | newstring += s.lower() | ||
214 | 147 | return newstring | ||
215 | 148 | # scramble the case of the url for this event connection. | ||
216 | 149 | # Avoids occasional problem with gvfsd-http wedging | ||
217 | 150 | # particular url's after loss of connectivity | ||
218 | 151 | parsed = [j for j in urlparse.urlparse(event.icalurl)] | ||
219 | 152 | parsed[1]= scramble_case(parsed[1]) | ||
220 | 153 | self._icalurl = urlparse.urlunparse(parsed) | ||
221 | 154 | start_read_ical(self._icalurl, finished_initial_ical_load) | ||
222 | 155 | logging.debug('Started initial ical load %s' % self._icalurl) | ||
223 | 156 | |||
224 | 157 | def set_timeout(): | ||
225 | 158 | if self._connected: | ||
226 | 159 | self._update_handle = glib.timeout_add_seconds(60, self._calendar_refresh, event, self._ical) | ||
227 | 160 | # Wait at least one minute before updating again, | ||
228 | 161 | # to avoid duplicate notifications. | ||
229 | 162 | logging.debug("In set_timeout") | ||
230 | 163 | return False | ||
231 | 164 | |||
232 | 165 | def _calendar_refresh(self, event, ical): | ||
233 | 166 | def finished_refresh_ical_load(gfile, result): | ||
234 | 167 | self._ical = read_ical(gfile, result, (event, self._ical)) | ||
235 | 168 | if not (gfile.get_uri() == self._icalurl): | ||
236 | 169 | logging.debug('Old I/O completion ignored') | ||
237 | 170 | return | ||
238 | 171 | logging.debug('Finished ical load') | ||
239 | 172 | if not self._connected: | ||
240 | 173 | return | ||
241 | 174 | self._update(event, self._ical) | ||
242 | 175 | secs = time.localtime().tm_sec | ||
243 | 176 | self._update_handle = glib.timeout_add_seconds(65-secs, self._calendar_refresh, event, self._ical) | ||
244 | 177 | return | ||
245 | 178 | start_read_ical(self._icalurl, finished_refresh_ical_load) | ||
246 | 179 | logging.debug('Started ical load') | ||
247 | 180 | return False | ||
248 | 181 | |||
249 | 182 | def _update(self, event, ical): | ||
250 | 124 | def quote(text): | 183 | def quote(text): |
251 | 125 | quote_table = { | 184 | quote_table = { |
252 | 126 | '<' : '<', | 185 | '<' : '<', |
253 | @@ -134,7 +193,7 @@ | |||
254 | 134 | return_value= return_value + quote_table.get(l,l) | 193 | return_value= return_value + quote_table.get(l,l) |
255 | 135 | return return_value | 194 | return return_value |
256 | 136 | 195 | ||
258 | 137 | self._schedule = parse_ical(event) | 196 | self._schedule = parse_ical(event, ical) |
259 | 138 | self._model.clear() | 197 | self._model.clear() |
260 | 139 | self._scroll_to = None | 198 | self._scroll_to = None |
261 | 140 | for session in self._schedule: | 199 | for session in self._schedule: |
262 | @@ -153,22 +212,16 @@ | |||
263 | 153 | current_row = self._model.append(sessionrow) | 212 | current_row = self._model.append(sessionrow) |
264 | 154 | if not self._scroll_to and session.state in (session.FUTURE, session.NOW): | 213 | if not self._scroll_to and session.state in (session.FUTURE, session.NOW): |
265 | 155 | self._scroll_to = self._model.get_path(current_row) | 214 | self._scroll_to = self._model.get_path(current_row) |
268 | 156 | 215 | self._update_currency() | |
267 | 157 | self._update() | ||
269 | 158 | 216 | ||
270 | 159 | if self._scroll_to: | 217 | if self._scroll_to: |
271 | 160 | self._treeview.scroll_to_cell(self._scroll_to, use_align=True, row_align=.2) | 218 | self._treeview.scroll_to_cell(self._scroll_to, use_align=True, row_align=.2) |
272 | 161 | 219 | ||
273 | 162 | def set_timeout(): | ||
274 | 163 | self._update_handle = glib.timeout_add_seconds(60, self._update) | ||
275 | 164 | # Wait at least one minute before updating again, | ||
276 | 165 | # to avoid duplicate notifications. | ||
277 | 166 | secs = time.localtime().tm_sec | ||
278 | 167 | glib.timeout_add_seconds(65-secs, set_timeout) | ||
279 | 168 | 220 | ||
280 | 169 | self._treeview.set_headers_visible(True) | 221 | self._treeview.set_headers_visible(True) |
281 | 170 | 222 | ||
282 | 171 | def do_event_disconnect(self, event_man, event): | 223 | def do_event_disconnect(self, event_man, event): |
283 | 224 | self._connected = False | ||
284 | 172 | self._schedule = [] | 225 | self._schedule = [] |
285 | 173 | self._current_session = None | 226 | self._current_session = None |
286 | 174 | self._model.clear() | 227 | self._model.clear() |
287 | @@ -176,13 +229,15 @@ | |||
288 | 176 | glib.source_remove(self._update_handle) | 229 | glib.source_remove(self._update_handle) |
289 | 177 | self._treeview.set_headers_visible(False) | 230 | self._treeview.set_headers_visible(False) |
290 | 178 | 231 | ||
292 | 179 | def _update(self): | 232 | def _update_currency(self): |
293 | 180 | ended = False | 233 | ended = False |
294 | 181 | if self._current_session and self._current_session.state == Session.PAST: | 234 | if self._current_session and self._current_session.state == Session.PAST: |
295 | 182 | ended = True | 235 | ended = True |
296 | 183 | self._current_session = None | 236 | self._current_session = None |
297 | 184 | for i, row in enumerate(self._model): | 237 | for i, row in enumerate(self._model): |
298 | 185 | session = row[self.COL_SESSION] | 238 | session = row[self.COL_SESSION] |
299 | 239 | if self._current_session and self._current_session.uid == session.uid: | ||
300 | 240 | self._current_session = session | ||
301 | 186 | if session.state == Session.NOW: | 241 | if session.state == Session.NOW: |
302 | 187 | row[self.COL_ICON] = gtk.STOCK_GO_FORWARD | 242 | row[self.COL_ICON] = gtk.STOCK_GO_FORWARD |
303 | 188 | if session != self._current_session: | 243 | if session != self._current_session: |
304 | 189 | 244 | ||
305 | === modified file 'lernid/widgets/Slide.py' | |||
306 | --- lernid/widgets/Slide.py 2011-09-03 23:25:12 +0000 | |||
307 | +++ lernid/widgets/Slide.py 2012-04-12 16:09:22 +0000 | |||
308 | @@ -26,6 +26,8 @@ | |||
309 | 26 | import logging | 26 | import logging |
310 | 27 | import gio | 27 | import gio |
311 | 28 | import webbrowser | 28 | import webbrowser |
312 | 29 | import cairo | ||
313 | 30 | import StringIO | ||
314 | 29 | 31 | ||
315 | 30 | from lernid.widgets.Widget import Widget | 32 | from lernid.widgets.Widget import Widget |
316 | 31 | from lernid.lernidconfig import save_cache_path | 33 | from lernid.lernidconfig import save_cache_path |
317 | @@ -113,17 +115,17 @@ | |||
318 | 113 | def _classroom_msg_received(self, classroom, chan, sender, text): | 115 | def _classroom_msg_received(self, classroom, chan, sender, text): |
319 | 114 | matches = re.search(r'\[(?i)SLIDE\s+(\d+).*\]', text) | 116 | matches = re.search(r'\[(?i)SLIDE\s+(\d+).*\]', text) |
320 | 115 | if matches and self._session_slide_downloaded: | 117 | if matches and self._session_slide_downloaded: |
322 | 116 | if chan.is_moderated() or self._on_faculty(sender): | 118 | if self._on_faculty(sender): |
323 | 117 | self._change_slide_page(int(matches.groups()[0])) | 119 | self._change_slide_page(int(matches.groups()[0])) |
324 | 118 | return | 120 | return |
325 | 119 | matches = re.search(r'\[(?i)SLIDEFILE\s+(\S+)\s+(\d+).*\]', text) | 121 | matches = re.search(r'\[(?i)SLIDEFILE\s+(\S+)\s+(\d+).*\]', text) |
326 | 120 | if matches: | 122 | if matches: |
328 | 121 | if chan.is_moderated() or self._on_faculty(sender): | 123 | if self._on_faculty(sender): |
329 | 122 | self._download_slides(matches.groups()[0], int(matches.groups()[1])) | 124 | self._download_slides(matches.groups()[0], int(matches.groups()[1])) |
330 | 123 | return | 125 | return |
331 | 124 | matches = re.search(r'\[(?i)SLIDEFILE\s+(\S+).*\]', text) | 126 | matches = re.search(r'\[(?i)SLIDEFILE\s+(\S+).*\]', text) |
332 | 125 | if matches: | 127 | if matches: |
334 | 126 | if chan.is_moderated() or self._on_faculty(sender): | 128 | if self._on_faculty(sender): |
335 | 127 | self._download_slides(matches.groups()[0], 1) | 129 | self._download_slides(matches.groups()[0], 1) |
336 | 128 | return | 130 | return |
337 | 129 | 131 | ||
338 | @@ -137,8 +139,19 @@ | |||
339 | 137 | return | 139 | return |
340 | 138 | page = pdf.get_page(int(pagenumber) - 1) | 140 | page = pdf.get_page(int(pagenumber) - 1) |
341 | 139 | w, h = page.get_size() | 141 | w, h = page.get_size() |
344 | 140 | pixbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, False, 8, int(w), int(h)) | 142 | w, h = (int(w), int(h)) |
345 | 141 | page.render_to_pixbuf(0,0,int(w),int(h),1,0, pixbuf) | 143 | surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, w, h) |
346 | 144 | context = cairo.Context(surface) | ||
347 | 145 | page.render(context) | ||
348 | 146 | # technique from diogodivision's "BlingSwitcher", | ||
349 | 147 | # through http://www.mikedesjardins.net | ||
350 | 148 | temp = StringIO.StringIO() | ||
351 | 149 | surface.write_to_png(temp) | ||
352 | 150 | temp.seek(0) | ||
353 | 151 | loader = gtk.gdk.PixbufLoader() | ||
354 | 152 | loader.write(temp.getvalue()) | ||
355 | 153 | loader.close() | ||
356 | 154 | pixbuf = loader.get_pixbuf() | ||
357 | 142 | except: | 155 | except: |
358 | 143 | Statusbar.push_message(_('An error was encountered while trying to load slide number {0}'.format(pagenumber)), duration=120) | 156 | Statusbar.push_message(_('An error was encountered while trying to load slide number {0}'.format(pagenumber)), duration=120) |
359 | 144 | logging.debug("Something went wrong when loading slide %s" % pagenumber) | 157 | logging.debug("Something went wrong when loading slide %s" % pagenumber) |
To test, bring up lernid from a terminal with the command:
lernid -v
and see that, starting in a couple of minutes, you get the messages:
DEBUG:root:Started ical load
DEBUG:root:Finished ical load
about every minute.