Merge lp:~strycore/lolz/quickly_trunk into lp:lolz

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
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

To post a comment you must log in.
Revision history for this message
Mathieu Comandon (strycore) :
review: Approve

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
=== modified file 'bin/lolz'
--- bin/lolz 2009-09-12 18:11:10 +0000
+++ bin/lolz 2010-01-23 21:09:13 +0000
@@ -19,22 +19,27 @@
19import os19import os
20import gtk20import gtk
21import urllib21import urllib
22import urllib2
22import datetime23import datetime
23import random24import random
24import dbus25import dbus
25import time26import time
27import logging
28import re
2629
27#check if gwibber support is installed30#check if gwibber is wanted and if support is installed
31gwibber_want = False
28gwibber_support = False32gwibber_support = False
29try:33if gwibber_want:
30 import gwibber.config34 try:
31 import gwibber.server35 import gwibber.config
3236 import gwibber.server
33 gwibber_support = True37
3438 gwibber_support = True
35except Exception, inst:39
36 logging.debug("Failed to setup dbus connection to gwibber")40 except ImportError, inst:
37 gwibber_support = False41 logging.debug("Failed to setup dbus connection to gwibber")
42 gwibber_support = False
3843
3944
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
@@ -48,7 +53,9 @@
48 fullPath = os.getcwd()53 fullPath = os.getcwd()
49sys.path.insert(0, os.path.dirname(fullPath))54sys.path.insert(0, os.path.dirname(fullPath))
5055
51from lolz import AboutLolzDialog, PreferencesLolzDialog, MicroblogDialog56from lolz import AboutLolzDialog, PreferencesLolzDialog
57if gwibber_support:
58 from lolz import MicroblogDialog
52from lolz.lolzconfig import getdatapath59from lolz.lolzconfig import getdatapath
53from lolz.AsynchTaskProgressBox import AsynchTaskProgressBox60from lolz.AsynchTaskProgressBox import AsynchTaskProgressBox
5461
@@ -129,7 +136,7 @@
129 logging.debug('day_selected() called')136 logging.debug('day_selected() called')
130 self.calendar.hide()137 self.calendar.hide()
131 d = self.calendar.get_date()138 d = self.calendar.get_date()
132 display_date = datetime.date(d[0],d[1],d[2])139 display_date = datetime.date(d[0],d[1]+1,d[2])
133 self.builder.get_object("calendar_button").set_label(display_date.isoformat())140 self.builder.get_object("calendar_button").set_label(display_date.isoformat())
134141
135 #clear out the curren set of images142 #clear out the curren set of images
@@ -251,19 +258,16 @@
251258
252259
253def __get_fail_images(date):260def __get_fail_images(date):
261 """
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" />
263 """
254 html = __get_html_for_date("http://failblog.org/",date)264 html = __get_html_for_date("http://failblog.org/",date)
255
256 mines = html.split("mine_")
257 del(mines[0])
258 images = []265 images = []
259 for m in mines:266 fail_re = "[\"\'](http://failblog.files.wordpress.com.*?jpg)[\"\']"
260 if m.find("imageid_") > -1:267 pics = re.findall(fail_re,html,re.MULTILINE | re.IGNORECASE)
261 pz = m.split("<img src=\"")268 for pic in pics:
262 url = pz[1].split("\" alt=")[0]269 logging.debug(pic)
263 if url.find("?") > -1:270 images.append(__download_image(pic,"http://failblog.org/","source: failblog.org"))
264 url = url.split("?")[0]
265 images.append(__download_image(url,"http://failblog.org/","source: failblog.org"))
266
267 logging.debug('found fail images:')271 logging.debug('found fail images:')
268 logging.debug(images)272 logging.debug(images)
269273
@@ -272,44 +276,34 @@
272276
273def __get_hotdog_images(date):277def __get_hotdog_images(date):
274 html = __get_html_for_date("http://ihasahotdog.com/",date)278 html = __get_html_for_date("http://ihasahotdog.com/",date)
275279 fail_re = "[\"\'](http://ihasahotdog.files.wordpress.com.*?jpg)[\"\']"
276 mines = html.split("mine_")280 pics = re.findall(fail_re,html,re.MULTILINE | re.IGNORECASE)
277 del(mines[0])
278 images = []281 images = []
279 for m in mines:282 for pic in pics:
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"))
281 if m.find("src=\"") > -1:
282 pz = m.split("src=\"")
283 if pz[1].find("LJT") == -1 and pz[1].find("imagestore") == -1:
284 url = pz[1].split("?")[0]
285 url = url.split("\" alt")[0]
286 images.append(__download_image(url,"http://ihasahotdog.com/","source: ihasahotdog.com"))
287 logging.debug('found hotdog images:')284 logging.debug('found hotdog images:')
288 logging.debug(images)285 logging.debug(images)
289 return images286 return images
290287
291def __get_html_for_date(url, date):288def __get_html_for_date(url, date):
292 logging.debug('getting html from ' + url + ' for ' + str(date))289 logging.debug('getting html from ' + url + ' for ' + str(date))
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)
294 day_url = url + dt_suffix291 day_url = url + dt_suffix
295 f = urllib.urlopen(day_url)292 logging.debug(day_url)
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"
294 headers = { 'User-agent' : user_agent }
295 request = urllib2.Request(day_url,None,headers)
296 request_content = urllib2.urlopen(request)
297 html = request_content.read()
297 return html298 return html
298 299
299def __get_cheez_images(date):300def __get_cheez_images(date):
300 html = __get_html_for_date("http://icanhascheezburger.com/",date)301 html = __get_html_for_date("http://icanhascheezburger.com/",date)
301
302 mines = html.split("mine_")
303 if len(mines) < 2:
304 return []
305 del(mines[0])
306 del(mines[1])
307 images = []302 images = []
308 for m in mines:303 pics_re = "\<img.*?(http://icanhascheezburger.files.wordpress.com.*?.jpg)\" alt=\"funny pictures of cats with captions.*?\>"
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)
310 pz = m.split("src")305 for pic in pics:
311 url = pz[1].split("&quot;")[1]306 images.append(__download_image(pic, pic, "source: icanhascheezburger.com"))
312 images.append(__download_image(url, "http://icanhascheezburger.com/", "source: icanhascheezburger.com"))
313 logging.debug('found cheezburger images:')307 logging.debug('found cheezburger images:')
314 logging.debug(images)308 logging.debug(images)
315 return images309 return images
@@ -323,7 +317,9 @@
323 os.makedirs(lolz_cache)317 os.makedirs(lolz_cache)
324 fname = os.path.join(lolz_cache,fname)318 fname = os.path.join(lolz_cache,fname)
325 if not os.path.exists(fname):319 if not os.path.exists(fname):
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" }
321 request = urllib2.Request(url,None,headers)
322 img_stream = urllib2.urlopen(request)
327 img_file = open(fname,'w')323 img_file = open(fname,'w')
328 img_file.write(img_stream.read())324 img_file.write(img_stream.read())
329 img_file.flush()325 img_file.flush()
330326
=== modified file 'data/ui/LolzWindow.ui'
--- data/ui/LolzWindow.ui 2009-09-12 18:11:10 +0000
+++ data/ui/LolzWindow.ui 2010-01-23 21:09:13 +0000
@@ -27,50 +27,11 @@
27 <object class="GtkMenu" id="menu1">27 <object class="GtkMenu" id="menu1">
28 <property name="visible">True</property>28 <property name="visible">True</property>
29 <child>29 <child>
30 <object class="GtkImageMenuItem" id="imagemenuitem1">
31 <property name="label">gtk-new</property>
32 <property name="visible">True</property>
33 <property name="use_action_appearance">True</property>
34 <property name="use_underline">True</property>
35 <property name="use_stock">True</property>
36 <accelerator key="n" signal="activate" modifiers="GDK_CONTROL_MASK"/>
37 </object>
38 </child>
39 <child>
40 <object class="GtkImageMenuItem" id="imagemenuitem2">
41 <property name="label">gtk-open</property>
42 <property name="visible">True</property>
43 <property name="use_underline">True</property>
44 <property name="use_stock">True</property>
45 </object>
46 </child>
47 <child>
48 <object class="GtkImageMenuItem" id="imagemenuitem3">
49 <property name="label">gtk-save</property>
50 <property name="visible">True</property>
51 <property name="use_underline">True</property>
52 <property name="use_stock">True</property>
53 </object>
54 </child>
55 <child>
56 <object class="GtkImageMenuItem" id="imagemenuitem4">
57 <property name="label">gtk-save-as</property>
58 <property name="visible">True</property>
59 <property name="use_underline">True</property>
60 <property name="use_stock">True</property>
61 </object>
62 </child>
63 <child>
64 <object class="GtkSeparatorMenuItem" id="separatormenuitem1">
65 <property name="visible">True</property>
66 </object>
67 </child>
68 <child>
69 <object class="GtkImageMenuItem" id="imagemenuitem5">30 <object class="GtkImageMenuItem" id="imagemenuitem5">
70 <property name="label">gtk-quit</property>31 <property name="label">'kthxbye</property>
71 <property name="visible">True</property>32 <property name="visible">True</property>
72 <property name="use_underline">True</property>33 <property name="image">image1</property>
73 <property name="use_stock">True</property>34 <property name="use_stock">False</property>
74 <signal name="activate" handler="quit"/>35 <signal name="activate" handler="quit"/>
75 </object>36 </object>
76 </child>37 </child>
@@ -87,43 +48,6 @@
87 <object class="GtkMenu" id="menu2">48 <object class="GtkMenu" id="menu2">
88 <property name="visible">True</property>49 <property name="visible">True</property>
89 <child>50 <child>
90 <object class="GtkImageMenuItem" id="imagemenuitem6">
91 <property name="label">gtk-cut</property>
92 <property name="visible">True</property>
93 <property name="use_underline">True</property>
94 <property name="use_stock">True</property>
95 </object>
96 </child>
97 <child>
98 <object class="GtkImageMenuItem" id="imagemenuitem7">
99 <property name="label">gtk-copy</property>
100 <property name="visible">True</property>
101 <property name="use_underline">True</property>
102 <property name="use_stock">True</property>
103 </object>
104 </child>
105 <child>
106 <object class="GtkImageMenuItem" id="imagemenuitem8">
107 <property name="label">gtk-paste</property>
108 <property name="visible">True</property>
109 <property name="use_underline">True</property>
110 <property name="use_stock">True</property>
111 </object>
112 </child>
113 <child>
114 <object class="GtkImageMenuItem" id="imagemenuitem9">
115 <property name="label">gtk-delete</property>
116 <property name="visible">True</property>
117 <property name="use_underline">True</property>
118 <property name="use_stock">True</property>
119 </object>
120 </child>
121 <child>
122 <object class="GtkSeparatorMenuItem" id="separatormenuitem2">
123 <property name="visible">True</property>
124 </object>
125 </child>
126 <child>
127 <object class="GtkImageMenuItem" id="imagemenuitem11">51 <object class="GtkImageMenuItem" id="imagemenuitem11">
128 <property name="label">gtk-preferences</property>52 <property name="label">gtk-preferences</property>
129 <property name="visible">True</property>53 <property name="visible">True</property>
@@ -137,13 +61,6 @@
137 </object>61 </object>
138 </child>62 </child>
139 <child>63 <child>
140 <object class="GtkMenuItem" id="menuitem3">
141 <property name="visible">True</property>
142 <property name="label" translatable="yes">_View</property>
143 <property name="use_underline">True</property>
144 </object>
145 </child>
146 <child>
147 <object class="GtkMenuItem" id="menuitem4">64 <object class="GtkMenuItem" id="menuitem4">
148 <property name="visible">True</property>65 <property name="visible">True</property>
149 <property name="label" translatable="yes">_Help</property>66 <property name="label" translatable="yes">_Help</property>
@@ -268,4 +185,8 @@
268 </object>185 </object>
269 </child>186 </child>
270 </object>187 </object>
188 <object class="GtkImage" id="image1">
189 <property name="visible">True</property>
190 <property name="stock">gtk-missing-image</property>
191 </object>
271</interface>192</interface>
272193
=== modified file 'debian/changelog'
--- debian/changelog 2009-09-14 16:02:03 +0000
+++ debian/changelog 2010-01-23 21:09:13 +0000
@@ -1,3 +1,9 @@
1lolz (1.238~public1) lucid; urgency=low
2
3 * New release.
4
5 -- Mathieu Comandon <strycore@gmail.com> Wed, 20 Jan 2010 22:34:30 +0100
6
1lolz (1.138) karmic; urgency=low7lolz (1.138) karmic; urgency=low
28
3 * New release.9 * New release.
410
=== modified file 'debian/control'
--- debian/control 2009-09-10 19:17:03 +0000
+++ debian/control 2010-01-23 21:09:13 +0000
@@ -16,7 +16,7 @@
16Depends: ${misc:Depends},16Depends: ${misc:Depends},
17 ${python:Depends},17 ${python:Depends},
18 python-dbus,18 python-dbus,
19 python-desktopcouch,19 python-gtk2,
20 python-gtk220 python-desktopcouch-records
21Description: I can has lolz21Description: I can has lolz
22 The least essential application ever22 The least essential application ever
2323
=== modified file 'lolz/PreferencesLolzDialog.py'
--- lolz/PreferencesLolzDialog.py 2009-09-12 18:11:10 +0000
+++ lolz/PreferencesLolzDialog.py 2010-01-23 21:09:13 +0000
@@ -17,6 +17,7 @@
17import sys17import sys
18import os18import os
19import gtk19import gtk
20
20from desktopcouch.records.server import CouchDatabase21from desktopcouch.records.server import CouchDatabase
21from desktopcouch.records.record import Record22from desktopcouch.records.record import Record
2223
2324
=== modified file 'setup.py'
--- setup.py 2009-09-19 16:38:02 +0000
+++ setup.py 2010-01-23 21:09:13 +0000
@@ -93,10 +93,10 @@
9393
94DistUtilsExtra.auto.setup(94DistUtilsExtra.auto.setup(
95 name='lolz',95 name='lolz',
96 version='1.238',96 version='1.238~public1',
97 license='GPL v3',97 license='GPL v3',
98 author='Rick Spencer',98 author='Mathieu Comandon',
99 author_email='rick.spencer@canonical.com',99 author_email='strycore@gmail.com',
100 description='I can has lolz',100 description='I can has lolz',
101 long_description='The least essential application ever',101 long_description='The least essential application ever',
102 url='https://launchpad.net/lolz',102 url='https://launchpad.net/lolz',

Subscribers

People subscribed via source and target branches

to all changes: