Merge lp:~strycore/lolz/quickly_trunk into lp:lolz
- quickly_trunk
- Merge into quickly_trunk
Proposed by
Mathieu Comandon
Status: | Needs review | ||||
---|---|---|---|---|---|
Proposed branch: | lp:~strycore/lolz/quickly_trunk | ||||
Merge into: | lp:lolz | ||||
Diff against target: |
343 lines (+64/-140) 6 files modified
bin/lolz (+45/-49) data/ui/LolzWindow.ui (+7/-86) debian/changelog (+6/-0) debian/control (+2/-2) lolz/PreferencesLolzDialog.py (+1/-0) setup.py (+3/-3) |
||||
To merge this branch: | bzr merge lp:~strycore/lolz/quickly_trunk | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mathieu Comandon (community) | Approve | ||
Review via email: mp+17951@code.launchpad.net |
Commit message
lolz , now with lolcats again, and it does not fail at getting pictures who fail
Description of the change
To post a comment you must log in.
Unmerged revisions
- 35. By Mathieu Comandon
-
Fixed retrieval of images from icanhaz and failblog + made Gwibber an option
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'bin/lolz' | |||
2 | --- bin/lolz 2009-09-12 18:11:10 +0000 | |||
3 | +++ bin/lolz 2010-01-23 21:09:13 +0000 | |||
4 | @@ -19,22 +19,27 @@ | |||
5 | 19 | import os | 19 | import os |
6 | 20 | import gtk | 20 | import gtk |
7 | 21 | import urllib | 21 | import urllib |
8 | 22 | import urllib2 | ||
9 | 22 | import datetime | 23 | import datetime |
10 | 23 | import random | 24 | import random |
11 | 24 | import dbus | 25 | import dbus |
12 | 25 | import time | 26 | import time |
13 | 27 | import logging | ||
14 | 28 | import re | ||
15 | 26 | 29 | ||
17 | 27 | #check if gwibber support is installed | 30 | #check if gwibber is wanted and if support is installed |
18 | 31 | gwibber_want = False | ||
19 | 28 | gwibber_support = False | 32 | gwibber_support = False |
29 | 29 | try: | 33 | if gwibber_want: |
30 | 30 | import gwibber.config | 34 | try: |
31 | 31 | import gwibber.server | 35 | import gwibber.config |
32 | 32 | 36 | import gwibber.server | |
33 | 33 | gwibber_support = True | 37 | |
34 | 34 | 38 | gwibber_support = True | |
35 | 35 | except Exception, inst: | 39 | |
36 | 36 | logging.debug("Failed to setup dbus connection to gwibber") | 40 | except ImportError, inst: |
37 | 37 | gwibber_support = False | 41 | logging.debug("Failed to setup dbus connection to gwibber") |
38 | 42 | gwibber_support = False | ||
39 | 38 | 43 | ||
40 | 39 | 44 | ||
41 | 40 | # Check if we are working in the source tree or from the installed | 45 | # Check if we are working in the source tree or from the installed |
42 | @@ -48,7 +53,9 @@ | |||
43 | 48 | fullPath = os.getcwd() | 53 | fullPath = os.getcwd() |
44 | 49 | sys.path.insert(0, os.path.dirname(fullPath)) | 54 | sys.path.insert(0, os.path.dirname(fullPath)) |
45 | 50 | 55 | ||
47 | 51 | from lolz import AboutLolzDialog, PreferencesLolzDialog, MicroblogDialog | 56 | from lolz import AboutLolzDialog, PreferencesLolzDialog |
48 | 57 | if gwibber_support: | ||
49 | 58 | from lolz import MicroblogDialog | ||
50 | 52 | from lolz.lolzconfig import getdatapath | 59 | from lolz.lolzconfig import getdatapath |
51 | 53 | from lolz.AsynchTaskProgressBox import AsynchTaskProgressBox | 60 | from lolz.AsynchTaskProgressBox import AsynchTaskProgressBox |
52 | 54 | 61 | ||
53 | @@ -129,7 +136,7 @@ | |||
54 | 129 | logging.debug('day_selected() called') | 136 | logging.debug('day_selected() called') |
55 | 130 | self.calendar.hide() | 137 | self.calendar.hide() |
56 | 131 | d = self.calendar.get_date() | 138 | d = self.calendar.get_date() |
58 | 132 | display_date = datetime.date(d[0],d[1],d[2]) | 139 | display_date = datetime.date(d[0],d[1]+1,d[2]) |
59 | 133 | self.builder.get_object("calendar_button").set_label(display_date.isoformat()) | 140 | self.builder.get_object("calendar_button").set_label(display_date.isoformat()) |
60 | 134 | 141 | ||
61 | 135 | #clear out the curren set of images | 142 | #clear out the curren set of images |
62 | @@ -251,19 +258,16 @@ | |||
63 | 251 | 258 | ||
64 | 252 | 259 | ||
65 | 253 | def __get_fail_images(date): | 260 | def __get_fail_images(date): |
66 | 261 | """ | ||
67 | 262 | example url : <img class="mine_3010416640" title="epic-fail-prison-guard-fail" src="http://failblog.files.wordpress.com/2009/12/epic-fail-prison-guard-fail.jpg" alt="epic fail pictures" /> | ||
68 | 263 | """ | ||
69 | 254 | html = __get_html_for_date("http://failblog.org/",date) | 264 | html = __get_html_for_date("http://failblog.org/",date) |
70 | 255 | |||
71 | 256 | mines = html.split("mine_") | ||
72 | 257 | del(mines[0]) | ||
73 | 258 | images = [] | 265 | images = [] |
82 | 259 | for m in mines: | 266 | fail_re = "[\"\'](http://failblog.files.wordpress.com.*?jpg)[\"\']" |
83 | 260 | if m.find("imageid_") > -1: | 267 | pics = re.findall(fail_re,html,re.MULTILINE | re.IGNORECASE) |
84 | 261 | pz = m.split("<img src=\"") | 268 | for pic in pics: |
85 | 262 | url = pz[1].split("\" alt=")[0] | 269 | logging.debug(pic) |
86 | 263 | if url.find("?") > -1: | 270 | images.append(__download_image(pic,"http://failblog.org/","source: failblog.org")) |
79 | 264 | url = url.split("?")[0] | ||
80 | 265 | images.append(__download_image(url,"http://failblog.org/","source: failblog.org")) | ||
81 | 266 | |||
87 | 267 | logging.debug('found fail images:') | 271 | logging.debug('found fail images:') |
88 | 268 | logging.debug(images) | 272 | logging.debug(images) |
89 | 269 | 273 | ||
90 | @@ -272,44 +276,34 @@ | |||
91 | 272 | 276 | ||
92 | 273 | def __get_hotdog_images(date): | 277 | def __get_hotdog_images(date): |
93 | 274 | html = __get_html_for_date("http://ihasahotdog.com/",date) | 278 | html = __get_html_for_date("http://ihasahotdog.com/",date) |
97 | 275 | 279 | fail_re = "[\"\'](http://ihasahotdog.files.wordpress.com.*?jpg)[\"\']" | |
98 | 276 | mines = html.split("mine_") | 280 | pics = re.findall(fail_re,html,re.MULTILINE | re.IGNORECASE) |
96 | 277 | del(mines[0]) | ||
99 | 278 | images = [] | 281 | images = [] |
108 | 279 | for m in mines: | 282 | for pic in pics: |
109 | 280 | if m.find("src") > -1 and m.find("Add this to your blog") == -1: | 283 | images.append(__download_image(pic,"http://ihasahotdog.com/","source: ihasahotdog.com")) |
102 | 281 | if m.find("src=\"") > -1: | ||
103 | 282 | pz = m.split("src=\"") | ||
104 | 283 | if pz[1].find("LJT") == -1 and pz[1].find("imagestore") == -1: | ||
105 | 284 | url = pz[1].split("?")[0] | ||
106 | 285 | url = url.split("\" alt")[0] | ||
107 | 286 | images.append(__download_image(url,"http://ihasahotdog.com/","source: ihasahotdog.com")) | ||
110 | 287 | logging.debug('found hotdog images:') | 284 | logging.debug('found hotdog images:') |
111 | 288 | logging.debug(images) | 285 | logging.debug(images) |
112 | 289 | return images | 286 | return images |
113 | 290 | 287 | ||
114 | 291 | def __get_html_for_date(url, date): | 288 | def __get_html_for_date(url, date): |
115 | 292 | logging.debug('getting html from ' + url + ' for ' + str(date)) | 289 | logging.debug('getting html from ' + url + ' for ' + str(date)) |
117 | 293 | dt_suffix = str(date.year) + "/" + str(date.month + 1) + "/" + str(date.day) | 290 | dt_suffix = str(date.year) + "/" + str(date.month) + "/" + str(date.day) |
118 | 294 | day_url = url + dt_suffix | 291 | day_url = url + dt_suffix |
121 | 295 | f = urllib.urlopen(day_url) | 292 | logging.debug(day_url) |
122 | 296 | html = f.read() | 293 | user_agent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20100106 Ubuntu/10.04 (lucid) Firefox/3.5.7" |
123 | 294 | headers = { 'User-agent' : user_agent } | ||
124 | 295 | request = urllib2.Request(day_url,None,headers) | ||
125 | 296 | request_content = urllib2.urlopen(request) | ||
126 | 297 | html = request_content.read() | ||
127 | 297 | return html | 298 | return html |
128 | 298 | 299 | ||
129 | 299 | def __get_cheez_images(date): | 300 | def __get_cheez_images(date): |
130 | 300 | html = __get_html_for_date("http://icanhascheezburger.com/",date) | 301 | html = __get_html_for_date("http://icanhascheezburger.com/",date) |
131 | 301 | |||
132 | 302 | mines = html.split("mine_") | ||
133 | 303 | if len(mines) < 2: | ||
134 | 304 | return [] | ||
135 | 305 | del(mines[0]) | ||
136 | 306 | del(mines[1]) | ||
137 | 307 | images = [] | 302 | images = [] |
143 | 308 | for m in mines: | 303 | pics_re = "\<img.*?(http://icanhascheezburger.files.wordpress.com.*?.jpg)\" alt=\"funny pictures of cats with captions.*?\>" |
144 | 309 | if m.find("src") > -1 and m.find("Add this to your blog") == -1: | 304 | pics = re.findall(pics_re,html,re.MULTILINE | re.IGNORECASE | re.DOTALL) |
145 | 310 | pz = m.split("src") | 305 | for pic in pics: |
146 | 311 | url = pz[1].split(""")[1] | 306 | images.append(__download_image(pic, pic, "source: icanhascheezburger.com")) |
142 | 312 | images.append(__download_image(url, "http://icanhascheezburger.com/", "source: icanhascheezburger.com")) | ||
147 | 313 | logging.debug('found cheezburger images:') | 307 | logging.debug('found cheezburger images:') |
148 | 314 | logging.debug(images) | 308 | logging.debug(images) |
149 | 315 | return images | 309 | return images |
150 | @@ -323,7 +317,9 @@ | |||
151 | 323 | os.makedirs(lolz_cache) | 317 | os.makedirs(lolz_cache) |
152 | 324 | fname = os.path.join(lolz_cache,fname) | 318 | fname = os.path.join(lolz_cache,fname) |
153 | 325 | if not os.path.exists(fname): | 319 | if not os.path.exists(fname): |
155 | 326 | img_stream = urllib.urlopen(url) | 320 | headers = { 'User-agent' : "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.7) Gecko/20100106 Ubuntu/10.04 (lucid) Firefox/3.5.7" } |
156 | 321 | request = urllib2.Request(url,None,headers) | ||
157 | 322 | img_stream = urllib2.urlopen(request) | ||
158 | 327 | img_file = open(fname,'w') | 323 | img_file = open(fname,'w') |
159 | 328 | img_file.write(img_stream.read()) | 324 | img_file.write(img_stream.read()) |
160 | 329 | img_file.flush() | 325 | img_file.flush() |
161 | 330 | 326 | ||
162 | === modified file 'data/ui/LolzWindow.ui' | |||
163 | --- data/ui/LolzWindow.ui 2009-09-12 18:11:10 +0000 | |||
164 | +++ data/ui/LolzWindow.ui 2010-01-23 21:09:13 +0000 | |||
165 | @@ -27,50 +27,11 @@ | |||
166 | 27 | <object class="GtkMenu" id="menu1"> | 27 | <object class="GtkMenu" id="menu1"> |
167 | 28 | <property name="visible">True</property> | 28 | <property name="visible">True</property> |
168 | 29 | <child> | 29 | <child> |
169 | 30 | <object class="GtkImageMenuItem" id="imagemenuitem1"> | ||
170 | 31 | <property name="label">gtk-new</property> | ||
171 | 32 | <property name="visible">True</property> | ||
172 | 33 | <property name="use_action_appearance">True</property> | ||
173 | 34 | <property name="use_underline">True</property> | ||
174 | 35 | <property name="use_stock">True</property> | ||
175 | 36 | <accelerator key="n" signal="activate" modifiers="GDK_CONTROL_MASK"/> | ||
176 | 37 | </object> | ||
177 | 38 | </child> | ||
178 | 39 | <child> | ||
179 | 40 | <object class="GtkImageMenuItem" id="imagemenuitem2"> | ||
180 | 41 | <property name="label">gtk-open</property> | ||
181 | 42 | <property name="visible">True</property> | ||
182 | 43 | <property name="use_underline">True</property> | ||
183 | 44 | <property name="use_stock">True</property> | ||
184 | 45 | </object> | ||
185 | 46 | </child> | ||
186 | 47 | <child> | ||
187 | 48 | <object class="GtkImageMenuItem" id="imagemenuitem3"> | ||
188 | 49 | <property name="label">gtk-save</property> | ||
189 | 50 | <property name="visible">True</property> | ||
190 | 51 | <property name="use_underline">True</property> | ||
191 | 52 | <property name="use_stock">True</property> | ||
192 | 53 | </object> | ||
193 | 54 | </child> | ||
194 | 55 | <child> | ||
195 | 56 | <object class="GtkImageMenuItem" id="imagemenuitem4"> | ||
196 | 57 | <property name="label">gtk-save-as</property> | ||
197 | 58 | <property name="visible">True</property> | ||
198 | 59 | <property name="use_underline">True</property> | ||
199 | 60 | <property name="use_stock">True</property> | ||
200 | 61 | </object> | ||
201 | 62 | </child> | ||
202 | 63 | <child> | ||
203 | 64 | <object class="GtkSeparatorMenuItem" id="separatormenuitem1"> | ||
204 | 65 | <property name="visible">True</property> | ||
205 | 66 | </object> | ||
206 | 67 | </child> | ||
207 | 68 | <child> | ||
208 | 69 | <object class="GtkImageMenuItem" id="imagemenuitem5"> | 30 | <object class="GtkImageMenuItem" id="imagemenuitem5"> |
210 | 70 | <property name="label">gtk-quit</property> | 31 | <property name="label">'kthxbye</property> |
211 | 71 | <property name="visible">True</property> | 32 | <property name="visible">True</property> |
214 | 72 | <property name="use_underline">True</property> | 33 | <property name="image">image1</property> |
215 | 73 | <property name="use_stock">True</property> | 34 | <property name="use_stock">False</property> |
216 | 74 | <signal name="activate" handler="quit"/> | 35 | <signal name="activate" handler="quit"/> |
217 | 75 | </object> | 36 | </object> |
218 | 76 | </child> | 37 | </child> |
219 | @@ -87,43 +48,6 @@ | |||
220 | 87 | <object class="GtkMenu" id="menu2"> | 48 | <object class="GtkMenu" id="menu2"> |
221 | 88 | <property name="visible">True</property> | 49 | <property name="visible">True</property> |
222 | 89 | <child> | 50 | <child> |
223 | 90 | <object class="GtkImageMenuItem" id="imagemenuitem6"> | ||
224 | 91 | <property name="label">gtk-cut</property> | ||
225 | 92 | <property name="visible">True</property> | ||
226 | 93 | <property name="use_underline">True</property> | ||
227 | 94 | <property name="use_stock">True</property> | ||
228 | 95 | </object> | ||
229 | 96 | </child> | ||
230 | 97 | <child> | ||
231 | 98 | <object class="GtkImageMenuItem" id="imagemenuitem7"> | ||
232 | 99 | <property name="label">gtk-copy</property> | ||
233 | 100 | <property name="visible">True</property> | ||
234 | 101 | <property name="use_underline">True</property> | ||
235 | 102 | <property name="use_stock">True</property> | ||
236 | 103 | </object> | ||
237 | 104 | </child> | ||
238 | 105 | <child> | ||
239 | 106 | <object class="GtkImageMenuItem" id="imagemenuitem8"> | ||
240 | 107 | <property name="label">gtk-paste</property> | ||
241 | 108 | <property name="visible">True</property> | ||
242 | 109 | <property name="use_underline">True</property> | ||
243 | 110 | <property name="use_stock">True</property> | ||
244 | 111 | </object> | ||
245 | 112 | </child> | ||
246 | 113 | <child> | ||
247 | 114 | <object class="GtkImageMenuItem" id="imagemenuitem9"> | ||
248 | 115 | <property name="label">gtk-delete</property> | ||
249 | 116 | <property name="visible">True</property> | ||
250 | 117 | <property name="use_underline">True</property> | ||
251 | 118 | <property name="use_stock">True</property> | ||
252 | 119 | </object> | ||
253 | 120 | </child> | ||
254 | 121 | <child> | ||
255 | 122 | <object class="GtkSeparatorMenuItem" id="separatormenuitem2"> | ||
256 | 123 | <property name="visible">True</property> | ||
257 | 124 | </object> | ||
258 | 125 | </child> | ||
259 | 126 | <child> | ||
260 | 127 | <object class="GtkImageMenuItem" id="imagemenuitem11"> | 51 | <object class="GtkImageMenuItem" id="imagemenuitem11"> |
261 | 128 | <property name="label">gtk-preferences</property> | 52 | <property name="label">gtk-preferences</property> |
262 | 129 | <property name="visible">True</property> | 53 | <property name="visible">True</property> |
263 | @@ -137,13 +61,6 @@ | |||
264 | 137 | </object> | 61 | </object> |
265 | 138 | </child> | 62 | </child> |
266 | 139 | <child> | 63 | <child> |
267 | 140 | <object class="GtkMenuItem" id="menuitem3"> | ||
268 | 141 | <property name="visible">True</property> | ||
269 | 142 | <property name="label" translatable="yes">_View</property> | ||
270 | 143 | <property name="use_underline">True</property> | ||
271 | 144 | </object> | ||
272 | 145 | </child> | ||
273 | 146 | <child> | ||
274 | 147 | <object class="GtkMenuItem" id="menuitem4"> | 64 | <object class="GtkMenuItem" id="menuitem4"> |
275 | 148 | <property name="visible">True</property> | 65 | <property name="visible">True</property> |
276 | 149 | <property name="label" translatable="yes">_Help</property> | 66 | <property name="label" translatable="yes">_Help</property> |
277 | @@ -268,4 +185,8 @@ | |||
278 | 268 | </object> | 185 | </object> |
279 | 269 | </child> | 186 | </child> |
280 | 270 | </object> | 187 | </object> |
281 | 188 | <object class="GtkImage" id="image1"> | ||
282 | 189 | <property name="visible">True</property> | ||
283 | 190 | <property name="stock">gtk-missing-image</property> | ||
284 | 191 | </object> | ||
285 | 271 | </interface> | 192 | </interface> |
286 | 272 | 193 | ||
287 | === modified file 'debian/changelog' | |||
288 | --- debian/changelog 2009-09-14 16:02:03 +0000 | |||
289 | +++ debian/changelog 2010-01-23 21:09:13 +0000 | |||
290 | @@ -1,3 +1,9 @@ | |||
291 | 1 | lolz (1.238~public1) lucid; urgency=low | ||
292 | 2 | |||
293 | 3 | * New release. | ||
294 | 4 | |||
295 | 5 | -- Mathieu Comandon <strycore@gmail.com> Wed, 20 Jan 2010 22:34:30 +0100 | ||
296 | 6 | |||
297 | 1 | lolz (1.138) karmic; urgency=low | 7 | lolz (1.138) karmic; urgency=low |
298 | 2 | 8 | ||
299 | 3 | * New release. | 9 | * New release. |
300 | 4 | 10 | ||
301 | === modified file 'debian/control' | |||
302 | --- debian/control 2009-09-10 19:17:03 +0000 | |||
303 | +++ debian/control 2010-01-23 21:09:13 +0000 | |||
304 | @@ -16,7 +16,7 @@ | |||
305 | 16 | Depends: ${misc:Depends}, | 16 | Depends: ${misc:Depends}, |
306 | 17 | ${python:Depends}, | 17 | ${python:Depends}, |
307 | 18 | python-dbus, | 18 | python-dbus, |
310 | 19 | python-desktopcouch, | 19 | python-gtk2, |
311 | 20 | python-gtk2 | 20 | python-desktopcouch-records |
312 | 21 | Description: I can has lolz | 21 | Description: I can has lolz |
313 | 22 | The least essential application ever | 22 | The least essential application ever |
314 | 23 | 23 | ||
315 | === modified file 'lolz/PreferencesLolzDialog.py' | |||
316 | --- lolz/PreferencesLolzDialog.py 2009-09-12 18:11:10 +0000 | |||
317 | +++ lolz/PreferencesLolzDialog.py 2010-01-23 21:09:13 +0000 | |||
318 | @@ -17,6 +17,7 @@ | |||
319 | 17 | import sys | 17 | import sys |
320 | 18 | import os | 18 | import os |
321 | 19 | import gtk | 19 | import gtk |
322 | 20 | |||
323 | 20 | from desktopcouch.records.server import CouchDatabase | 21 | from desktopcouch.records.server import CouchDatabase |
324 | 21 | from desktopcouch.records.record import Record | 22 | from desktopcouch.records.record import Record |
325 | 22 | 23 | ||
326 | 23 | 24 | ||
327 | === modified file 'setup.py' | |||
328 | --- setup.py 2009-09-19 16:38:02 +0000 | |||
329 | +++ setup.py 2010-01-23 21:09:13 +0000 | |||
330 | @@ -93,10 +93,10 @@ | |||
331 | 93 | 93 | ||
332 | 94 | DistUtilsExtra.auto.setup( | 94 | DistUtilsExtra.auto.setup( |
333 | 95 | name='lolz', | 95 | name='lolz', |
335 | 96 | version='1.238', | 96 | version='1.238~public1', |
336 | 97 | license='GPL v3', | 97 | license='GPL v3', |
339 | 98 | author='Rick Spencer', | 98 | author='Mathieu Comandon', |
340 | 99 | author_email='rick.spencer@canonical.com', | 99 | author_email='strycore@gmail.com', |
341 | 100 | description='I can has lolz', | 100 | description='I can has lolz', |
342 | 101 | long_description='The least essential application ever', | 101 | long_description='The least essential application ever', |
343 | 102 | url='https://launchpad.net/lolz', | 102 | url='https://launchpad.net/lolz', |