Merge lp:~rockstar/entertainer/kill-fixmes into lp:entertainer

Proposed by Paul Hummer
Status: Merged
Merged at revision: not available
Proposed branch: lp:~rockstar/entertainer/kill-fixmes
Merge into: lp:entertainer
Diff against target: None lines
To merge this branch: bzr merge lp:~rockstar/entertainer/kill-fixmes
Reviewer Review Type Date Requested Status
Samuel Buffet (community) Approve
Matt Layman Approve
Review via email: mp+3474@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) wrote :

First of all, please review my more-pylint-fun branch, as this branch depends
on that one.

While working on the more-pylint-fun branch, I noticed that all of the FIXME
comments had to do entirely with incomplete functionality that will never be
implemented in its current form (like in the backend) or asking questions that
really didn't need to be asked, like "Is this safe?" where, if it weren't safe,
we would get a bug filed.

I basically just removed the FIXME lines, and enabled the avoidance of FIXME in
pylint. My next branch will probably address a bunch of the TODO issues, which
seem to have a bit more complication to them.

--
Paul Hummer
http://theironlion.net
1024/862FF08F C921 E962 58F8 5547 6723 0E8C 1C4D 8AC5 862F F08F

Revision history for this message
Matt Layman (mblayman) wrote :

 approve merge_conditional

This branch looks fine, but I have a couple of comments about the pylintrc. You've removed W0511 but still have the XXX comment.

I see that you removed TODO and XXX from the things to check. Do you think you could add an XXX comment indicating that we plan on adding TODO back to the list of things to check.

review: Approve
Revision history for this message
Samuel Buffet (samuel-buffet) wrote :
Download full text (8.6 KiB)

This branch is also merged with *more-pylint-fun*.

So as long as *more-pylint-fun* is okay I approve this one as well.

Paul, thanks to clean the bug tracker and remove all that.

here is a diff against *more-pylint-fun*

=== modified file 'entertainerlib/backend/components/mediacache/image_cache.py'
--- entertainerlib/backend/components/mediacache/image_cache.py 2009-02-07 22:12:25 +0000
+++ entertainerlib/backend/components/mediacache/image_cache.py 2009-02-08 20:31:58 +0000
@@ -107,8 +107,6 @@
         if self.isFileInCache(filename):
             self.removeFile(filename)
             self.addFile(filename)
- #FIXME: This is maybe too expensive method for this purpose!
- # Try to optimise it.

     def addDirectory(self, path):
         """
@@ -165,7 +163,6 @@
         """
         self.removeDirectory(path)
         self.addDirectory(path)
- #FIXME: This is very expensive method to call! Try to optimise it.

     def isFileInCache(self, filename):
         """Check if file is already in cache. Returns boolean value."""
@@ -250,12 +247,10 @@
             a_title = path[path.rfind('/')+1:].replace('_',' ').title()
             a_description = ""

- #FIXME: If not found we could generate fancy album thumb
         if os.path.exists(album_thumb):
             thumbnailer = ImageThumbnailer(album_thumb)
             thumbnailer.create_thumbnail()
             a_hash = thumbnailer.get_hash()
- del thumbnailer #FIXME: Does this make any sense?
         else:
             a_hash = ""

=== modified file 'entertainerlib/backend/components/mediacache/video_cache.py'
--- entertainerlib/backend/components/mediacache/video_cache.py 2009-02-07 22:12:25 +0000
+++ entertainerlib/backend/components/mediacache/video_cache.py 2009-02-08 20:31:58 +0000
@@ -239,7 +239,6 @@
         thash = thumbnailer.get_hash()
         del thumbnailer

- #FIXME: read resolution, length etc. from video file and add to db
         self.__db_cursor.execute("""INSERT INTO videofile(filename, hash)
                                     VALUES (:fn, :hash)""",
                                     { 'fn': filename, 'hash': thash, } )

=== modified file 'entertainerlib/frontend/gui/screens/photo_albums.py'
--- entertainerlib/frontend/gui/screens/photo_albums.py 2009-02-07 21:43:35 +0000
+++ entertainerlib/frontend/gui/screens/photo_albums.py 2009-02-08 20:31:58 +0000
@@ -106,7 +106,7 @@
                 nro_of_photos = str(nro_of_photos)
             item = TextMenuItem(0.4393, 0.0781, album.get_title(),
                 nro_of_photos)
- item.set_userdata(album) #FIXME: Should we use URLs as KEYS?
+ item.set_userdata(album)
             self.menu.add_actor(item)

         self.add(self.menu)

=== modified file 'entertainerlib/frontend/gui/screens/video_osd.py'
--- entertainerlib/frontend/gui/screens/video_osd.py 2009-02-03 23:37:57 +0000
+++ entertainerlib/frontend/gui/screens/video_osd.py 2009-02-08 20:31:58 +0000
@@ -212,8 +212,6 @@
         if event_type == UserEvent.PLAYER_STOP:
             self.display_progress_bar(hide_after_delay=False)
             self.pause_texture.hide()
- #FIXME
- ...

Read more...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'entertainerlib/backend/backend_server.py'
2--- entertainerlib/backend/backend_server.py 2009-02-07 00:44:47 +0000
3+++ entertainerlib/backend/backend_server.py 2009-02-08 07:01:25 +0000
4@@ -6,8 +6,6 @@
5 __author__ = "Lauri Taimila <lauri@taimila.com>"
6 __version__ = "0.1"
7
8-import sys
9-
10 import gobject
11
12 from entertainerlib.utils.configuration import Configuration
13@@ -46,6 +44,7 @@
14 self.config = Configuration()
15 self.logger = Logger().getLogger('backend.BackendServer')
16 self.message_bus = MessageBus()
17+ self._port = self.config.get_port()
18
19 # Connection server - Thread that listens incoming socket connections
20 self.connection_server = None
21@@ -69,34 +68,19 @@
22
23 def initialize_configuration(self):
24 """Initialize configuration"""
25- try:
26- cfg_dict = { MessageType.CONTENT_CONF_UPDATED :
27- MessagePriority.VERY_HIGH,
28- MessageType.PREFERENCES_CONF_UPDATED :
29- MessagePriority.VERY_HIGH }
30- self.message_bus.registerMessageHandler(self.config, cfg_dict)
31- self.logger.debug("Configuration intialized successfully")
32- except:
33- print "Couldn't read configuration file! Execution aborted..."
34- sys.exit(1)
35+ cfg_dict = {
36+ MessageType.CONTENT_CONF_UPDATED : MessagePriority.VERY_HIGH,
37+ MessageType.PREFERENCES_CONF_UPDATED : MessagePriority.VERY_HIGH
38+ }
39+ self.message_bus.registerMessageHandler(self.config, cfg_dict)
40+ self.logger.debug("Configuration intialized successfully")
41
42 def initialize_connection_server(self):
43 """Initialize connection server."""
44- try:
45- self._port = self.config.get_port()
46- self.connection_server = ConnectionServer(self._port,
47- self.message_bus)
48- # Start listening incoming connections
49- self.connection_server.start()
50- except:
51- self.logger.error("ConnectionServer initialization failed!")
52- message = 'Error occured. Please see '
53- message += self.config.ENTERTAINER_LOG
54- message += ' for more information. This is probably not a fatal'
55- message += ' error. Just wait one minute and try again.'
56- print message
57- print "Execution aborted!"
58- sys.exit(1)
59+ self.connection_server = ConnectionServer(self._port,
60+ self.message_bus)
61+ # Start listening incoming connections
62+ self.connection_server.start()
63
64 def initialize_scheduler(self):
65 """Initialize message scheduler."""
66
67=== modified file 'entertainerlib/backend/components/feeds/feed_fetcher.py'
68--- entertainerlib/backend/components/feeds/feed_fetcher.py 2009-02-06 08:13:48 +0000
69+++ entertainerlib/backend/components/feeds/feed_fetcher.py 2009-02-07 21:43:35 +0000
70@@ -52,14 +52,9 @@
71 last_update = datetime(dt[0], dt[1], dt[2],
72 dt[3], dt[4], dt[5])
73 except AttributeError:
74- try:
75- dt = data.entries[0].date_parsed
76- last_update = datetime(dt[0], dt[1], dt[2],
77- dt[3], dt[4], dt[5])
78- except:
79- self.logger.warning("Couldn't determine feed date of " \
80- + data.feed.title)
81- continue # Skip to the next feed
82+ dt = data.entries[0].date_parsed
83+ last_update = datetime(dt[0], dt[1], dt[2],
84+ dt[3], dt[4], dt[5])
85
86 #Check if this feed has new entries
87 db_cursor.execute("""SELECT date,time
88
89=== modified file 'entertainerlib/backend/components/mediacache/image_cache.py'
90--- entertainerlib/backend/components/mediacache/image_cache.py 2009-02-06 08:13:48 +0000
91+++ entertainerlib/backend/components/mediacache/image_cache.py 2009-02-08 08:44:46 +0000
92@@ -57,37 +57,26 @@
93 thumb_file = os.path.join(self.config.IMAGE_THUMB_DIR, element)
94 try:
95 os.remove(thumb_file)
96- except:
97+ except OSError:
98 self.logger.error(
99 "Media manager couldn't remove thumbnail : %s"
100 % thumb_file)
101- try:
102- os.remove(self.config.IMAGE_DB)
103- self._createImageCacheDatabase()
104- except:
105- raise IOError("Couldn't clear image cache")
106+ os.remove(self.config.IMAGE_DB)
107+ self._createImageCacheDatabase()
108
109
110 def addFile(self, filename):
111 """
112 Add image file to the cache. Do nothing if file is already cached.
113 """
114- try:
115- filename = filename.encode('utf8')
116- if (not self.isFileInCache(filename) and
117- self.isSupportedFormat(filename)):
118- # Do not add album thumbnail to images
119- if (filename[filename.rfind('/') +1:filename.rfind('.')] ==
120- ".entertainer_album"):
121- return
122- try:
123- self._addJPEGfile(filename)
124- except Exception, e:
125- self.logger.error("Couldn't cache file: " + filename)
126- self.logger.debug("Exception: " + str(e.message))
127- except Exception, e:
128- self.logger.error("Problem With " + filename)
129- self.logger.error("Exception: " + e.message)
130+ filename = filename.encode('utf8')
131+ if (not self.isFileInCache(filename) and
132+ self.isSupportedFormat(filename)):
133+ # Do not add album thumbnail to images
134+ if (filename[filename.rfind('/') +1:filename.rfind('.')] ==
135+ ".entertainer_album"):
136+ return
137+ self._addJPEGfile(filename)
138
139 def removeFile(self, filename):
140 """
141@@ -105,7 +94,7 @@
142 thumb = os.path.join(self.config.IMAGE_THUMB_DIR, name)
143 try:
144 os.remove(thumb)
145- except:
146+ except OSError:
147 self.logger.error("Couldn't remove thumbnail: " + thumb)
148 self.db_cursor.execute("""DELETE
149 FROM image
150@@ -118,8 +107,6 @@
151 if self.isFileInCache(filename):
152 self.removeFile(filename)
153 self.addFile(filename)
154- #FIXME: This is maybe too expensive method for this purpose!
155- # Try to optimise it.
156
157 def addDirectory(self, path):
158 """
159@@ -153,10 +140,7 @@
160 WHERE filename LIKE '""" + path + "%'")
161 for row in self.db_cursor:
162 thumb_file = row[0] + ".jpg"
163- try:
164- os.remove(os.path.join(self.config.IMAGE_THUMB_DIR, thumb_file))
165- except:
166- pass
167+ os.remove(os.path.join(self.config.IMAGE_THUMB_DIR, thumb_file))
168
169 # Remove folder thumbnails
170 self.db_cursor.execute("""SELECT hash
171@@ -164,10 +148,7 @@
172 WHERE path LIKE '""" + path + "%'")
173 for row in self.db_cursor:
174 thumb_file = row[0] + ".jpg"
175- try:
176- os.remove(os.path.join(self.config.IMAGE_THUMB_DIR, thumb_file))
177- except:
178- pass
179+ os.remove(os.path.join(self.config.IMAGE_THUMB_DIR, thumb_file))
180
181 # Clean cache database
182 self.db_cursor.execute(
183@@ -182,7 +163,6 @@
184 """
185 self.removeDirectory(path)
186 self.addDirectory(path)
187- #FIXME: This is very expensive method to call! Try to optimise it.
188
189 def isFileInCache(self, filename):
190 """Check if file is already in cache. Returns boolean value."""
191@@ -260,19 +240,17 @@
192 inf_f = open(album_info)
193 a_title = inf_f.readline()[6:]
194 a_description = inf_f.readline()[12:]
195- except:
196+ except IOError:
197 a_title = path[path.rfind('/')+1:].replace('_',' ').title()
198 a_description = ""
199 else:
200 a_title = path[path.rfind('/')+1:].replace('_',' ').title()
201 a_description = ""
202
203- #FIXME: If not found we could generate fancy album thumb
204 if os.path.exists(album_thumb):
205 thumbnailer = ImageThumbnailer(album_thumb)
206 thumbnailer.create_thumbnail()
207 a_hash = thumbnailer.get_hash()
208- del thumbnailer #FIXME: Does this make any sense?
209 else:
210 a_hash = ""
211
212@@ -302,13 +280,10 @@
213 str(tmp.day), str(tmp.hour) + ":" + str(tmp.minute) + ":" +
214 str(tmp.second)]
215
216- try:
217- title, description = self._readMetadataFile(filename)
218- except:
219- # Generate name from filename
220- tmp = filename[filename.rfind('/') + 1 : filename.rfind('.')]
221- title = tmp.replace('_',' ').title() # Make title more attractive
222- description = "" # No description for this image file
223+ # Generate name from filename
224+ tmp = filename[filename.rfind('/') + 1 : filename.rfind('.')]
225+ title = tmp.replace('_',' ').title() # Make title more attractive
226+ description = "" # No description for this image file
227
228 im = Image.open(filename)
229 width, height = im.size
230@@ -346,27 +321,3 @@
231 VALUES(?,?,?,?,?,?,?,?,?,?)""", db_row)
232 self.db_conn.commit()
233
234- def _readMetadataFile(self, filename):
235- """
236- Reads image title and description from explicite metadata file if
237- the file exists. If file doesn't exist, this method throws an
238- exception, which indicates to the caller that metadata should be
239- received from some place else.
240- """
241- # Generate metadata filename
242- abs_path = filename[:filename.rfind('/') + 1] # Cut filename off
243- img_file = filename[filename.rfind('/') + 1:] # Cut path off
244- metadata_file = abs_path + "." + img_file[:img_file.rfind('.')] + \
245- ".info"
246-
247- if os.path.exists(metadata_file):
248- try:
249- info_file = open(metadata_file)
250- title = info_file.readline()[6:]
251- description = info_file.readline()[12:]
252- return title, description
253- except:
254- raise Exception("Couldn't read existing metadata file.")
255- else:
256- raise Exception("Metadata file doesn't exist.")
257-
258
259=== modified file 'entertainerlib/backend/components/mediacache/music_cache.py'
260--- entertainerlib/backend/components/mediacache/music_cache.py 2009-02-06 08:13:48 +0000
261+++ entertainerlib/backend/components/mediacache/music_cache.py 2009-02-07 21:43:35 +0000
262@@ -55,34 +55,20 @@
263 """
264 covers = os.listdir(self.config.ALBUM_ART_DIR)
265 for element in covers:
266- try:
267- os.remove(os.path.join(self.config.ALBUM_ART_DIR, element))
268- except:
269- pass
270- try:
271- os.remove(self.config.MUSIC_DB)
272- self.__createMusicCacheDatabase()
273- except:
274- raise IOError("Couldn't clear music cache")
275+ os.remove(os.path.join(self.config.ALBUM_ART_DIR, element))
276+
277+ os.remove(self.config.MUSIC_DB)
278+ self.__createMusicCacheDatabase()
279
280 def addFile(self, filename):
281 """Add audio file to the cache."""
282- try:
283- filename = filename.encode('utf8')
284- if (not self.isFileInCache(filename) and
285- self.isSupportedFormat(filename)):
286- try:
287- if self.__getFileExtension(filename) == "mp3":
288- self.__addMP3file(filename)
289- elif self.__getFileExtension(filename) == "ogg":
290- self.__addOGGfile(filename)
291- except Exception, e:
292- self.logger.error("Couldn't cache file: " + filename)
293- self.logger.debug("Exception: " + e.message)
294- except Exception, e:
295- self.logger.error("Problem With " + filename)
296- self.logger.error("Exception: " + e.message)
297-
298+ filename = filename.encode('utf8')
299+ if (not self.isFileInCache(filename) and
300+ self.isSupportedFormat(filename)):
301+ if self.__getFileExtension(filename) == "mp3":
302+ self.__addMP3file(filename)
303+ elif self.__getFileExtension(filename) == "ogg":
304+ self.__addOGGfile(filename)
305
306 def removeFile(self, filename):
307 """Remove audio file from the cache."""
308@@ -111,7 +97,7 @@
309 try:
310 os.remove(os.path.join(self.config.ALBUM_ART_DIR,
311 albumart_file))
312- except:
313+ except OSError:
314 self.logger.error("Couldn't remove albumart: " +
315 os.path.join(self.config.ALBUM_ART_DIR, albumart_file))
316
317@@ -181,7 +167,7 @@
318 try:
319 os.remove(os.path.join(self.config.ALBUM_ART_DIR,
320 albumart_file))
321- except:
322+ except OSError:
323 self.logger.error(
324 "Couldn't remove albumart: " +
325 os.path.join(self.config.ALBUM_ART_DIR, albumart_file))
326@@ -264,12 +250,8 @@
327 - Get tags
328 - Insert data to the music cache database
329 """
330- try:
331- mp3_file = eyeD3.Mp3AudioFile(filename, eyeD3.ID3_ANY_VERSION)
332- tags = mp3_file.getTag()
333- except:
334- self.logger.error("Couldn't read ID3tags: " + filename)
335- return
336+ mp3_file = eyeD3.Mp3AudioFile(filename, eyeD3.ID3_ANY_VERSION)
337+ tags = mp3_file.getTag()
338
339 if tags is None:
340 self.logger.error("Couldn't read ID3tags: " + filename)
341@@ -297,11 +279,8 @@
342 title = self.__DEFAULT['title']
343
344 # Get track genre
345- try:
346- genre = str(tags.getGenre())
347- if genre is None or len(genre) == 0:
348- genre = self.__DEFAULT['genre']
349- except:
350+ genre = str(tags.getGenre())
351+ if genre is None or len(genre) == 0:
352 genre = self.__DEFAULT['genre']
353
354 # Get track number
355@@ -357,12 +336,8 @@
356 - Get tags
357 - Insert data to the music cache database
358 """
359- try:
360- ogg_file = ogg.vorbis.VorbisFile(filename)
361- info = ogg_file.comment().as_dict()
362- except:
363- self.logger.error("Couldn't index file: " + filename)
364- return
365+ ogg_file = ogg.vorbis.VorbisFile(filename)
366+ info = ogg_file.comment().as_dict()
367
368 # Get length
369 length = round(ogg_file.time_total(-1))
370
371=== modified file 'entertainerlib/backend/components/mediacache/video_cache.py'
372--- entertainerlib/backend/components/mediacache/video_cache.py 2009-02-06 08:13:48 +0000
373+++ entertainerlib/backend/components/mediacache/video_cache.py 2009-02-08 08:44:46 +0000
374@@ -49,34 +49,19 @@
375 covers = os.listdir(self.config.MOVIE_ART_DIR)
376 for element in covers:
377 if element[-3:] == "jpg":
378- try:
379- os.remove(os.path.join(self.config.MOVIE_ART_DIR, element))
380- except:
381- self.logger.error(
382- "Media manager couldn't remove movie cover.")
383+ os.remove(os.path.join(self.config.MOVIE_ART_DIR, element))
384
385- try:
386- os.remove(self.config.VIDEO_DB)
387- except:
388- pass
389+ os.remove(self.config.VIDEO_DB)
390 self.__createVideoCacheDatabase()
391
392 def addFile(self, filename):
393 """
394 This method adds a new file to the cache.
395 """
396- try:
397- filename = filename.encode('utf8')
398- if not self.isFileInCache(filename) and \
399- self.isSupportedFormat(filename):
400- try:
401- self._addVideoFile(filename)
402- except Exception, e:
403- self.logger.error("Couldn't cache file: " + filename)
404- self.logger.debug("Exception: " + e.message)
405- except Exception, e:
406- self.logger.error("Problem With " + filename)
407- self.logger.error("Exception: " + e.message)
408+ filename = filename.encode('utf8')
409+ if not self.isFileInCache(filename) and \
410+ self.isSupportedFormat(filename):
411+ self._addVideoFile(filename)
412
413 def removeFile(self, filename):
414 """
415@@ -116,15 +101,9 @@
416
417 # Remove thumbnail and cover art
418 if os.path.exists(art) and not self.__hasSeriesEpisodes(series):
419- try:
420- os.remove(art)
421- except:
422- self.logger.error("Couldn't remove movie art" + art)
423+ os.remove(art)
424 if os.path.exists(thumb):
425- try:
426- os.remove(thumb)
427- except:
428- self.logger.error("Couldn't remove thumbnail" + thumb)
429+ os.remove(thumb)
430
431 def updateFile(self, filename):
432 """
433@@ -255,17 +234,11 @@
434 def _addVideoFile(self, filename):
435 """Add video file to the video cache."""
436 # Generate thumbnail
437- try:
438- thumbnailer = VideoThumbnailer(filename)
439- thumbnailer.create_thumbnail()
440- thash = thumbnailer.get_hash()
441- del thumbnailer
442- except Exception, e:
443- thash = None
444- self.logger.error("Problem Creating Thumbnail: " + filename)
445- self.logger.debug("Exception: " + e.message)
446+ thumbnailer = VideoThumbnailer(filename)
447+ thumbnailer.create_thumbnail()
448+ thash = thumbnailer.get_hash()
449+ del thumbnailer
450
451- #FIXME: read resolution, length etc. from video file and add to db
452 self.__db_cursor.execute("""INSERT INTO videofile(filename, hash)
453 VALUES (:fn, :hash)""",
454 { 'fn': filename, 'hash': thash, } )
455@@ -279,11 +252,7 @@
456 def __searchMetadata(self, filename):
457 """Search metadata for video file from the Internet."""
458 search_thread = None
459- try:
460- search_thread = VideoMetadataSearch(filename)
461- except:
462- self.logger.error(
463- "Invalid TV-Series episode filename detected: " + filename)
464+ search_thread = VideoMetadataSearch(filename)
465
466 if search_thread is not None:
467 search_thread.start()
468
469=== modified file 'entertainerlib/backend/components/mediacache/video_metadata_search.py'
470--- entertainerlib/backend/components/mediacache/video_metadata_search.py 2008-12-07 20:41:05 +0000
471+++ entertainerlib/backend/components/mediacache/video_metadata_search.py 2009-02-07 22:12:25 +0000
472@@ -102,11 +102,7 @@
473 Search metadata from IMDB and update video cache database.
474 """
475 search_results = []
476- try:
477- search_results = self.IMDb.search_movie(self.title)
478- except:
479- self.logger.error("IMDB search failed")
480- return # Network error or too many results to handle
481+ search_results = self.IMDb.search_movie(self.title)
482
483 if len(search_results) == 0:
484 return # No matches for this search
485@@ -114,69 +110,42 @@
486 if search_results[0]['kind'] == "movie":
487 # We trust that the first search result is the best
488 movie = search_results[0]
489- try:
490- self.IMDb.update(movie)
491- except:
492- self.logger.error(
493- "Metadata search failed for: " + self.filename)
494- return
495+ self.IMDb.update(movie)
496
497 video_type = "MOVIE"
498- try:
499- title = movie['title']
500- year = movie['year']
501- # convert to 5-stars rating
502- rating = round(float(movie['rating']) / 2)
503-
504- genres = ','.join(movie['genres'])
505- try:
506- plot_outline = movie['plot outline']
507- except:
508- plot_outline = ""
509-
510- try:
511- plot_string = movie['plot'][0]
512- plot = plot_string[plot_string.rfind("::")+2:].lstrip()
513- except:
514- plot = _("Plot not available")
515-
516- # IMDb returns sometimes list and sometimes string
517- if(type(plot)) is list:
518- plot = plot[0]
519- if(type(plot_outline)) is list:
520- plot_outline = plot_outline[0]
521-
522- try:
523- runtime = movie['runtime'][0]
524- int(runtime) # Raises exception if not integer
525- except:
526- runtime = 0
527- p = self._get_persons(movie)
528- row = (video_type, title, "", runtime, genres, rating,
529- year, plot_outline, plot, 0, 0, p[0], p[1], p[2],
530- p[3], p[4], p[5], p[6], p[7], p[8], self.filename)
531- self._update_video_cache(row)
532-
533- # Download and save cover art
534- try:
535- self._download_cover_art(movie['cover url'], title)
536- except:
537- pass
538- except:
539- self.logger.error("Couldn't find metadata from IMDB for: " +
540- self.filename)
541- return
542+ title = movie['title']
543+ year = movie['year']
544+ # convert to 5-stars rating
545+ rating = round(float(movie['rating']) / 2)
546+
547+ genres = ','.join(movie['genres'])
548+ plot_outline = movie['plot outline']
549+
550+ plot_string = movie['plot'][0]
551+ plot = plot_string[plot_string.rfind("::")+2:].lstrip()
552+
553+ # IMDb returns sometimes list and sometimes string
554+ if(type(plot)) is list:
555+ plot = plot[0]
556+ if(type(plot_outline)) is list:
557+ plot_outline = plot_outline[0]
558+
559+ runtime = movie['runtime'][0]
560+ int(runtime) # Raises exception if not integer
561+ p = self._get_persons(movie)
562+ row = (video_type, title, "", runtime, genres, rating,
563+ year, plot_outline, plot, 0, 0, p[0], p[1], p[2],
564+ p[3], p[4], p[5], p[6], p[7], p[8], self.filename)
565+ self._update_video_cache(row)
566+
567+ # Download and save cover art
568+ self._download_cover_art(movie['cover url'], title)
569
570 elif search_results[0]['kind'] == "tv series":
571 series = search_results[0]
572 # We trust that the first search result is the best
573- try:
574- self.IMDb.update(series)
575- self.IMDb.update(series, "episodes")
576- except:
577- self.logger.error("Couldn't find metadata from IMDB for: " +
578- self.filename)
579- return
580+ self.IMDb.update(series)
581+ self.IMDb.update(series, "episodes")
582
583 video_type = "TV-SERIES"
584 p = self._get_persons(series)
585@@ -186,34 +155,19 @@
586
587 series_title = series['title']
588 genres = ','.join(series['genres'])
589- try:
590- time = series['runtime']
591- runtime = time[0][:time[0].find(":")]
592- int(runtime) # This raises exception if runtime is not integer
593- except:
594- runtime = 0
595- try:
596- year = series['series years']
597- except:
598- year = series['year']
599- try:
600- title = series['episodes'][self.season][self.episode]['title']
601- except:
602- title = _("%(episode)d. Episode") % {'episode': self.episode}
603- try:
604- plot = series['episodes'][self.season][self.episode]['plot']
605- except:
606- plot = _("No plot outline available")
607+ time = series['runtime']
608+ runtime = time[0][:time[0].find(":")]
609+ int(runtime) # This raises exception if runtime is not integer
610+ year = series['series years']
611+ title = series['episodes'][self.season][self.episode]['title']
612+ plot = series['episodes'][self.season][self.episode]['plot']
613 row = (video_type, title, series_title, runtime, genres, rating, \
614 year, "", plot, self.season, self.episode, p[0], p[1], \
615 p[2], p[3], p[4], p[5] ,p[6], p[7], p[8], self.filename)
616 self._update_video_cache(row)
617
618 # Download and save cover art
619- try:
620- self._download_cover_art(series['cover url'], series_title)
621- except:
622- pass
623+ self._download_cover_art(series['cover url'], series_title)
624 else:
625 # This file wasn't identified to be a movie or a TV-series episode.
626 return
627@@ -224,36 +178,32 @@
628 @param db_row: List that contains all information we want to store into
629 cache
630 """
631- try:
632- db_conn = sqlite.connect(self.config.VIDEO_DB)
633- db_cursor = db_conn.cursor()
634- db_cursor.execute("""UPDATE metadata
635- SET type=?,
636- title=?,
637- series_title=?,
638- runtime=?,
639- genres=?,
640- rating=?,
641- year=?,
642- plot_outline=?,
643- plot=?,
644- season=?,
645- episode=?,
646- actor_1=?,
647- actor_2=?,
648- actor_3=?,
649- actor_4=?,
650- actor_5=?,
651- writer_1=?,
652- writer_2=?,
653- director_1=?,
654- director_2=?
655- WHERE filename=?""", db_row)
656- db_conn.commit()
657- db_conn.close()
658- except Exception, e:
659- self.logger.error("Exception occured during video cache update: " +
660- e.message)
661+ db_conn = sqlite.connect(self.config.VIDEO_DB)
662+ db_cursor = db_conn.cursor()
663+ db_cursor.execute("""UPDATE metadata
664+ SET type=?,
665+ title=?,
666+ series_title=?,
667+ runtime=?,
668+ genres=?,
669+ rating=?,
670+ year=?,
671+ plot_outline=?,
672+ plot=?,
673+ season=?,
674+ episode=?,
675+ actor_1=?,
676+ actor_2=?,
677+ actor_3=?,
678+ actor_4=?,
679+ actor_5=?,
680+ writer_1=?,
681+ writer_2=?,
682+ director_1=?,
683+ director_2=?
684+ WHERE filename=?""", db_row)
685+ db_conn.commit()
686+ db_conn.close()
687
688
689 def _get_persons(self, movie):
690@@ -263,42 +213,15 @@
691 @param movie: Movie name
692 @return: List of strings containing actors, directors and writers
693 """
694- try:
695- a1 = movie['actors'][0]['name']
696- except:
697- a1 = ""
698- try:
699- a2 = movie['actors'][1]['name']
700- except:
701- a2 = ""
702- try:
703- a3 = movie['actors'][2]['name']
704- except:
705- a3 = ""
706- try:
707- a4 = movie['actors'][3]['name']
708- except:
709- a4 = ""
710- try:
711- a5 = movie['actors'][4]['name']
712- except:
713- a5 = ""
714- try:
715- w1 = movie['writer'][0]['name']
716- except:
717- w1 = ""
718- try:
719- w2 = movie['writer'][1]['name']
720- except:
721- w2 = ""
722- try:
723- d1 = movie['director'][0]['name']
724- except:
725- d1 = ""
726- try:
727- d2 = movie['director'][1]['name']
728- except:
729- d2 = ""
730+ a1 = movie['actors'][0]['name']
731+ a2 = movie['actors'][1]['name']
732+ a3 = movie['actors'][2]['name']
733+ a4 = movie['actors'][3]['name']
734+ a5 = movie['actors'][4]['name']
735+ w1 = movie['writer'][0]['name']
736+ w2 = movie['writer'][1]['name']
737+ d1 = movie['director'][0]['name']
738+ d2 = movie['director'][1]['name']
739
740 return [a1, a2, a3, a4, a5, w1, w2, d1, d2]
741
742@@ -311,10 +234,7 @@
743 # Check if we have cover art for this series or movie already
744 if not os.path.exists(
745 os.path.join(self.config.MOVIE_ART_DIR, title + ".jpg")):
746- try:
747- image = urllib.urlopen(url)
748- except:
749- return
750+ image = urllib.urlopen(url)
751 dest = open(os.path.join(
752 self.config.MOVIE_ART_DIR, title + ".jpg"), 'w')
753 dest.write(image.read())
754
755=== modified file 'entertainerlib/backend/core/client_connection.py'
756--- entertainerlib/backend/core/client_connection.py 2008-08-16 04:28:47 +0000
757+++ entertainerlib/backend/core/client_connection.py 2009-02-07 21:43:35 +0000
758@@ -52,11 +52,7 @@
759 # Receive dictionary
760 dict_str = self.client.readline()
761 dictionary = None
762- try:
763- dictionary = cPickle.loads(dict_str[:-1])
764- except:
765- self.logger.error(
766- 'Client sent malformed message dict to the backend!')
767+ dictionary = cPickle.loads(dict_str[:-1])
768
769 # This client to the message bus if desired
770 if dictionary != None and len(dictionary) > 0:
771@@ -87,10 +83,6 @@
772 @param message: Received Message object
773 """
774 message_str = cPickle.dumps(message, cPickle.HIGHEST_PROTOCOL)
775- try:
776- self.client_out.sendall(message_str)
777- self.client_out.sendall("\nEND_OF_MESSAGE_OBJECT\n")
778- except:
779- self.logger.error(
780- "Socket broken! Client didn't receive a message.")
781+ self.client_out.sendall(message_str)
782+ self.client_out.sendall("\nEND_OF_MESSAGE_OBJECT\n")
783
784
785=== modified file 'entertainerlib/frontend/frontend_client.py'
786--- entertainerlib/frontend/frontend_client.py 2009-02-07 19:47:17 +0000
787+++ entertainerlib/frontend/frontend_client.py 2009-02-07 22:12:25 +0000
788@@ -60,24 +60,14 @@
789
790 def initialize_backend_connection(self):
791 '''Connect to the backend server.'''
792- try:
793- backend_connection = BackendConnection()
794- self.logger.debug('Connected to the Entertainer backend server.')
795- except:
796- print 'Couldn\'t connect to the backend server. Execution aborted!'
797- print 'Make sure that Entertainer backend server is up and running.'
798- sys.exit(1)
799+ backend_connection = BackendConnection()
800+ self.logger.debug('Connected to the Entertainer backend server.')
801
802 return backend_connection
803
804 def quit_frontend(self):
805 '''Clean up the connection to the backend then close the frontend.'''
806- try:
807- self.backend_connection.close_connection()
808- except Exception, e:
809- print 'Error closing Backend Connection:', e.message
810- print 'Closing anyway'
811- sys.exit(0)
812+ self.backend_connection.close_connection()
813
814 gtk.main_quit()
815 sys.exit(0)
816
817=== modified file 'entertainerlib/frontend/gui/screens/audio_play.py'
818--- entertainerlib/frontend/gui/screens/audio_play.py 2009-02-06 08:33:50 +0000
819+++ entertainerlib/frontend/gui/screens/audio_play.py 2009-02-08 07:01:25 +0000
820@@ -1,4 +1,5 @@
821 '''AudioPlay - Screen displays information of currently playing audio'''
822+# pylint: disable-msg=W0221
823
824 __licence__ = "GPLv2"
825 __copyright__ = "2007, Lauri Taimila"
826
827=== modified file 'entertainerlib/frontend/gui/screens/disc.py'
828--- entertainerlib/frontend/gui/screens/disc.py 2009-02-03 23:37:57 +0000
829+++ entertainerlib/frontend/gui/screens/disc.py 2009-02-07 21:43:35 +0000
830@@ -81,7 +81,6 @@
831 self._create_album_cover_texture(artist, title)
832 self._create_list_indicator()
833
834- # Check if artfile exists. If it doesn't let's make a search for it.
835 art_file = os.path.join(self.config.ALBUM_ART_DIR,
836 artist + " - " + title + ".jpg")
837 if artist != "Unknown artist" and not os.path.exists(art_file):
838@@ -89,7 +88,7 @@
839 self.config.ALBUM_ART_DIR, self._update_albumart)
840 art_search.start()
841
842- except: # No disc in drive
843+ except IndexError: # No disc in drive
844 no_disc = Label(0.05, "title", 0.5, 0.5,
845 _("No audio disc in drive"))
846 no_disc.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
847
848=== modified file 'entertainerlib/frontend/gui/screens/photo.py'
849--- entertainerlib/frontend/gui/screens/photo.py 2009-02-03 23:37:57 +0000
850+++ entertainerlib/frontend/gui/screens/photo.py 2009-02-08 07:43:25 +0000
851@@ -60,10 +60,8 @@
852 """
853 Change current image. Display image from given index.
854 """
855- try:
856+ if self.texture:
857 self.texture.destroy()
858- except AttributeError:
859- pass # No previous texture in memory. No problem, let's continue
860
861 # Create a new texture and display it
862 image = self.images[index]
863
864=== modified file 'entertainerlib/frontend/gui/screens/photo_albums.py'
865--- entertainerlib/frontend/gui/screens/photo_albums.py 2009-02-03 23:37:57 +0000
866+++ entertainerlib/frontend/gui/screens/photo_albums.py 2009-02-08 08:44:46 +0000
867@@ -106,7 +106,7 @@
868 nro_of_photos = str(nro_of_photos)
869 item = TextMenuItem(0.4393, 0.0781, album.get_title(),
870 nro_of_photos)
871- item.set_userdata(album) #FIXME: Should we use URLs as KEYS?
872+ item.set_userdata(album)
873 self.menu.add_actor(item)
874
875 self.add(self.menu)
876@@ -170,10 +170,7 @@
877 Update album preview. Display preview images from the current album.
878 @param album: Currently selected album in menu
879 """
880- try:
881- gobject.source_remove(self.preview_fade)
882- except:
883- pass # If there is no image switcher enabled that's ok
884+ gobject.source_remove(self.preview_fade)
885
886 new = self._create_album_preview(album)
887
888
889=== modified file 'entertainerlib/frontend/gui/screens/tv_episodes.py'
890--- entertainerlib/frontend/gui/screens/tv_episodes.py 2009-02-03 23:37:57 +0000
891+++ entertainerlib/frontend/gui/screens/tv_episodes.py 2009-02-08 07:43:25 +0000
892@@ -82,11 +82,8 @@
893 """
894 Create a thumbnail texture. This is called as menu is scrolled
895 """
896- try:
897+ if self.thumb:
898 self.thumb.hide()
899- del self.thumb
900- except:
901- pass # No problem, this is just the first time we call this method
902
903 # Thumbnail. Use cover art if thumbnail doesn't exist
904 menu_item = self.episode_menu.get_current_menuitem()
905
906=== modified file 'entertainerlib/frontend/gui/screens/video_osd.py'
907--- entertainerlib/frontend/gui/screens/video_osd.py 2009-02-03 23:37:57 +0000
908+++ entertainerlib/frontend/gui/screens/video_osd.py 2009-02-08 08:44:46 +0000
909@@ -212,8 +212,6 @@
910 if event_type == UserEvent.PLAYER_STOP:
911 self.display_progress_bar(hide_after_delay=False)
912 self.pause_texture.hide()
913- #FIXME
914- print "CREATE VIDEO STOPPED SCREEN HERE"
915
916 # Video aspect ratio changed. Display aspect ratio logo on screen
917 elif event_type == UserEvent.USE_ASPECT_RATIO_1:
918
919=== modified file 'entertainerlib/frontend/gui/widgets/grid_menu.py'
920--- entertainerlib/frontend/gui/widgets/grid_menu.py 2009-02-06 08:13:48 +0000
921+++ entertainerlib/frontend/gui/widgets/grid_menu.py 2009-02-08 08:44:46 +0000
922@@ -202,14 +202,12 @@
923 """
924 Override clutter.Group method. Returns number of menuitems.
925 """
926- #FIXME: Is this safe?
927 return len(self.items)
928
929 def get_nth_child(self, index):
930 """
931 Override clutter.Group method. Returns one menuitem.
932 """
933- #FIXME: Is this safe?
934 return self.items[index]
935
936 def get_number_of_items(self):
937@@ -522,7 +520,6 @@
938 # BELOW IS ANIMATION CODE FOR MENU CURSOR. SHOULD CURSOR BE ANIMATED?
939 # if self.animate:
940 # # Finish previous animation before new
941-# # FIXME: Doesn't seem to work as it should
942 # if self.cursor_timeline is not None and (
943 # self.cursor_timeline.is_playing():
944 # self.cursor_timeline.pause()
945@@ -585,7 +582,6 @@
946 # y = self.itemgroup.get_y()
947 #
948 # # Finish previous animation before new
949-# # FIXME: Doesn't seem to work as it should
950 # if self.content_timeline is not None and (
951 # self.content_timeline.is_playing():
952 # self.content_timeline.pause()
953
954=== modified file 'entertainerlib/frontend/gui/widgets/image_menu.py'
955--- entertainerlib/frontend/gui/widgets/image_menu.py 2008-12-08 17:26:56 +0000
956+++ entertainerlib/frontend/gui/widgets/image_menu.py 2009-02-08 07:43:25 +0000
957@@ -62,7 +62,7 @@
958 This method is called when widget is set active or inactive. This
959 method allows widget to react this action.
960 """
961- try:
962+ if len(self.items):
963 if self.active:
964 self.cursor.show()
965 self.items[self.logical_position].set_active(True)
966@@ -71,8 +71,6 @@
967 self.cursor.hide()
968 self.items[self.logical_position].set_active(False)
969 self.set_opacity(128)
970- except:
971- pass # No items in menu
972
973 def _scale_menuitem(self, menuitem):
974 """
975
976=== modified file 'entertainerlib/frontend/gui/widgets/menu.py'
977--- entertainerlib/frontend/gui/widgets/menu.py 2008-11-19 21:50:24 +0000
978+++ entertainerlib/frontend/gui/widgets/menu.py 2009-02-08 08:44:46 +0000
979@@ -191,7 +191,6 @@
980 """
981 # Set current menuitem
982 self.__items[self.__current].set_active(False)
983- #FIXME: What if there is not that many?
984 self.__current = self.__current + 8
985 self.__items[self.__current].set_active(True)
986
987
988=== modified file 'entertainerlib/frontend/gui/widgets/text_menu.py'
989--- entertainerlib/frontend/gui/widgets/text_menu.py 2008-11-05 17:38:30 +0000
990+++ entertainerlib/frontend/gui/widgets/text_menu.py 2009-02-08 07:43:25 +0000
991@@ -47,7 +47,7 @@
992 This method is called when widget is set active or inactive. This
993 method allows widget to react this action.
994 """
995- try:
996+ if len(self.items):
997 if self.active:
998 self.cursor.show()
999 self.items[self.logical_position].set_active(True)
1000@@ -56,9 +56,7 @@
1001 self.cursor.hide()
1002 self.items[self.logical_position].set_active(False)
1003 self.set_opacity(128)
1004- except:
1005- pass # No items in menu
1006-
1007+
1008 def get_index(self, text):
1009 """
1010 Returns index of label with the text as passed, returns -1 if not found
1011
1012=== modified file 'entertainerlib/frontend/media_player.py'
1013--- entertainerlib/frontend/media_player.py 2009-01-08 15:38:26 +0000
1014+++ entertainerlib/frontend/media_player.py 2009-02-08 08:44:46 +0000
1015@@ -235,7 +235,6 @@
1016 """
1017 if self.playlist is not None:
1018 if self.shuffle:
1019- # FIXME: Should we remember order of randomly played tracks
1020 self.set_media(self.playlist.get_random(), True)
1021 elif self.playlist.has_previous():
1022 self.set_media(self.playlist.get_previous(), True)
1023
1024=== modified file 'entertainerlib/frontend/medialibrary/music.py'
1025--- entertainerlib/frontend/medialibrary/music.py 2009-02-07 17:12:21 +0000
1026+++ entertainerlib/frontend/medialibrary/music.py 2009-02-08 08:44:46 +0000
1027@@ -63,10 +63,7 @@
1028 @return: CompactDisc
1029 """
1030 cdrom = DiscID.open()
1031- try:
1032- disc_id = DiscID.disc_id(cdrom)
1033- except:
1034- raise Exception("No media in drive.")
1035+ disc_id = DiscID.disc_id(cdrom)
1036 return CompactDisc(disc_id)
1037
1038 def get_playlists(self):
1039@@ -265,7 +262,6 @@
1040 self.title = title
1041 self.total_length = 0
1042
1043- #FIXME: Album needs to be refactored to have no dependence on the db.
1044 if not cursor:
1045 self.db_connection = sqlite.connect(self.config.MUSIC_DB)
1046 self.cursor = self.db_connection.cursor()
1047@@ -282,7 +278,6 @@
1048 self.tracks.append(Track(row[0], row[1], row[2], row[3], self,
1049 row[5], row[6], row[7], row[8], row[9],
1050 row[10], row[11]))
1051- #self.artist = row[3] #FIXME: Should we set artist somewhere else?
1052 self.total_length += int(row[9])
1053 if len(self.tracks) == 0:
1054 raise AlbumHasNoTracks()
1055@@ -290,7 +285,6 @@
1056
1057 def __str__(self):
1058 return self.title
1059- #return '%s - %s' % (self.artist, self.title)
1060
1061 def get_title(self):
1062 """
1063@@ -447,8 +441,6 @@
1064 Get album that contains this Track.
1065 @return: Album object
1066 """
1067- #FIXME: when Album constructor removes work-around, get_album needs to
1068- # remove the default False and get the cursor from the media library
1069 if not isinstance(self.album, Album):
1070 album = Album(self.album, cursor)
1071 self.album = album
1072@@ -461,9 +453,6 @@
1073 Get album art URL of this Track
1074 @return: String (or None if there is no album art for this track)
1075 """
1076- #FIXME: when Album constructor removes work-around, get_album_art_url
1077- # needs to remove the default False and get the cursor from the media
1078- # library
1079 self.get_album(cursor) # Need to have an album object
1080
1081 if self.album.has_album_art():
1082@@ -599,8 +588,6 @@
1083
1084 query_info = CDDB.query(disc_id)[1]
1085
1086- # FIXME: query_info contains code that we could use instead of TRY
1087- # EXCEPT
1088 #See CDDB documentation for more information.
1089 #http://cddb-py.sourceforge.net/CDDB/README
1090
1091@@ -629,7 +616,7 @@
1092 track_title = read_info['TTITLE' + str(i)]
1093 self.tracks.append(CompactDiscTrack(i + 1, track_title,
1094 length))
1095- except:
1096+ except TypeError:
1097 query = query_info[0]
1098 self.artist = query['title'][:query['title'].index(' / ')]
1099 self.album = query['title'][query['title'].index(' / ') + 3:]
1100
1101=== modified file 'entertainerlib/tests/mock.py'
1102--- entertainerlib/tests/mock.py 2009-02-04 00:52:34 +0000
1103+++ entertainerlib/tests/mock.py 2009-02-08 07:01:25 +0000
1104@@ -268,7 +268,7 @@
1105 if make_album:
1106 self.album = MockAlbum(make_track=False)
1107
1108- def get_album(self):
1109+ def get_album(self, cursor=False):
1110 '''See `Track.get_album`.'''
1111 return self.album
1112
1113
1114=== modified file 'entertainerlib/tests/test_feedconfigtools.py'
1115--- entertainerlib/tests/test_feedconfigtools.py 2009-01-31 21:36:56 +0000
1116+++ entertainerlib/tests/test_feedconfigtools.py 2009-02-08 07:01:25 +0000
1117@@ -18,7 +18,7 @@
1118 class FeedConfigToolsTest(EntertainerTest):
1119 '''Test for entertainerlib.utils.feed_utils FeedConfigTools'''
1120
1121- def setUp(self, debug=False):
1122+ def setUp(self):
1123 """Sets up everything for the test"""
1124 EntertainerTest.setUp(self)
1125
1126
1127=== modified file 'entertainerlib/tests/test_feedentryparser.py'
1128--- entertainerlib/tests/test_feedentryparser.py 2009-01-31 21:36:56 +0000
1129+++ entertainerlib/tests/test_feedentryparser.py 2009-02-08 07:01:25 +0000
1130@@ -7,18 +7,14 @@
1131
1132 import unittest
1133
1134-from entertainerlib.utils.logger import Logger
1135 from entertainerlib.utils.feed_utils import FeedEntryParser
1136
1137+
1138 class FeedEntryParserTest(unittest.TestCase):
1139 '''Test the FeedEntryParser'''
1140
1141- def setUp(self, debug=False):
1142+ def setUp(self):
1143 """Sets up everything for the test"""
1144- self.debug = debug
1145- if(self.debug):
1146- self.logger = Logger('./tests.log').getLogger(
1147- 'FeedEntryParserTest')
1148
1149 #test strings
1150 self.testString001 = "<body><b>Hello World</body></b>"
1151@@ -33,9 +29,6 @@
1152 tags
1153 """
1154 output = FeedEntryParser().strip_tags(self.testString001)
1155- if(self.debug):
1156- self.logger.debug("EXPECTED: " + self.resultString001)
1157- self.logger.debug("OUTPUT: " + output)
1158 self.assertEqual(output, self.resultString001)
1159
1160 def testStripTags002(self):
1161@@ -43,9 +36,6 @@
1162 non-default tags
1163 """
1164 output = FeedEntryParser().strip_tags(self.testString001, ["body"])
1165- if(self.debug):
1166- self.logger.debug("EXPECTED: " + self.resultString003)
1167- self.logger.debug("OUTPUT: " + output)
1168 self.assertEqual(output, self.resultString003)
1169
1170 def testStripNonPangoTags(self):
1171@@ -53,16 +43,10 @@
1172 non-pango tags from input
1173 """
1174 output = FeedEntryParser().strip_non_pango_tags(self.testString002)
1175- if(self.debug):
1176- self.logger.debug("EXPECTED: " + self.resultString002)
1177- self.logger.debug("OUTPUT: " + output)
1178 self.assertEqual(output, self.resultString002)
1179
1180 def testConvert(self):
1181 """tests if FeedEntryParser converts input to correct output"""
1182 output = FeedEntryParser().convert(self.testString002)
1183- if(self.debug):
1184- self.logger.debug("EXPECTED: " + self.resultString004)
1185- self.logger.debug("OUTPUT: " + output)
1186 self.assertEqual(output, self.resultString004)
1187
1188
1189=== modified file 'entertainerlib/tests/test_music.py'
1190--- entertainerlib/tests/test_music.py 2009-02-07 17:12:21 +0000
1191+++ entertainerlib/tests/test_music.py 2009-02-07 21:43:35 +0000
1192@@ -251,10 +251,7 @@
1193
1194 def setUp(self):
1195 TestMusic.setUp(self)
1196- try:
1197- self.backend_connection = MockBackendConnection()
1198- except:
1199- print "\nbackend_connection failed"
1200+ self.backend_connection = MockBackendConnection()
1201 self.musiclibrary = MusicLibrary(self.backend_connection)
1202
1203 def tearDown(self):
1204
1205=== modified file 'entertainerlib/tests/test_opmlparser.py'
1206--- entertainerlib/tests/test_opmlparser.py 2009-01-31 21:36:56 +0000
1207+++ entertainerlib/tests/test_opmlparser.py 2009-02-08 07:01:25 +0000
1208@@ -9,19 +9,16 @@
1209 import os
1210 import xml.parsers.expat
1211
1212-from entertainerlib.utils.logger import Logger
1213 from entertainerlib.utils.feed_utils import OPMLParser
1214
1215 THIS_DIR = os.path.dirname(__file__)
1216
1217+
1218 class OPMLParserTest(unittest.TestCase):
1219 '''Test OPMLParser'''
1220
1221- def setUp(self, debug=False):
1222+ def setUp(self):
1223 '''See unittest.TestCase'''
1224- self.debug = debug
1225- if(self.debug):
1226- self.logger = Logger('./tests.log').getLogger('OPMLParserTest')
1227
1228 #set up lists and paths
1229 self.testURL = "http://www.scripting.com/feeds/top100.opml"
1230@@ -48,15 +45,10 @@
1231 def testGetRssFeeds001(self):
1232 """Check if OPMLParser can parse a normal file"""
1233 output = OPMLParser().get_rss_feeds(self.okFilePath)
1234- if(self.debug):
1235- self.logger.debug('Expecting the list : ' + str(self.feedList))
1236- self.logger.debug('OUTPUT:' + str(output))
1237 self.assertEqual(output, self.feedList)
1238
1239 def testGetRssFeeds002(self):
1240 """Check if OPMLParser can handle a non-existant file"""
1241- if(self.debug):
1242- self.logger.debug('Expecting an IOError')
1243 self.assertRaises(IOError, OPMLParser().get_rss_feeds,
1244 self.badFilePath)
1245
1246@@ -69,35 +61,23 @@
1247 links
1248 """
1249 output = OPMLParser().get_rss_feeds(self.insideFilePath)
1250- if(self.debug):
1251- self.logger.debug('Expecting the list : ' + str(self.feedList))
1252- self.logger.debug('OUTPUT: ' + str(output))
1253 self.assertEqual(output, self.feedList)
1254
1255 def testGetRssFeeds004(self):
1256 """Check if OPMLParser can handle a file which is not an opml file or
1257 even an xml file
1258 """
1259- if(self.debug):
1260- self.logger.debug('Expecting an ExpatError')
1261 self.assertRaises(xml.parsers.expat.ExpatError,
1262 OPMLParser().get_rss_feeds, self.notXMLFile)
1263
1264 def testGetRssFeeds005(self):
1265 """Check if OPMLParser can handle a URL"""
1266 output = OPMLParser().get_rss_feeds(self.testURL)
1267- if(self.debug):
1268- self.logger.debug('Expecting anything but []')
1269- self.logger.debug('OUTPUT: ' + str(output))
1270 self.assertTrue(output != [])
1271
1272 def testGetLifereaOpml001(self):
1273 """Check if OPMLParser can pick the opml file for liferea"""
1274 output = OPMLParser().get_liferea_opml(self.singleLifereaFolder)
1275- if(self.debug):
1276- self.logger.debug('Expecting the string : ' +
1277- self.singleLifereaFolder+"/.liferea/feedlist.opml")
1278- self.logger.debug('OUTPUT: ' + output)
1279 self.assertEqual(output,
1280 self.singleLifereaFolder+"/.liferea/feedlist.opml")
1281
1282@@ -106,10 +86,6 @@
1283 of liferea out of a selection of folders
1284 """
1285 output = OPMLParser().get_liferea_opml(self.multipleLifereaFolders)
1286- if(self.debug):
1287- self.logger.debug('Expecting the string : ' +
1288- self.multipleLifereaFolders+"/.liferea_1.4/feedlist.opml")
1289- self.logger.debug('OUTPUT: ' + output)
1290 self.assertEqual(output,
1291 self.multipleLifereaFolders+"/.liferea_1.4/feedlist.opml")
1292
1293@@ -118,9 +94,6 @@
1294 liferea opml folder
1295 """
1296 output = OPMLParser().get_liferea_opml(self.noLifereaFolder)
1297- if(self.debug):
1298- self.logger.debug('Expecting an empty string')
1299- self.logger.debug('OUTPUT: ' + output)
1300 self.assertEqual(output, "")
1301
1302 def testGetLifereaOpml004(self):
1303@@ -128,8 +101,5 @@
1304 liferea opml file
1305 """
1306 output = OPMLParser().get_liferea_opml(self.noLifereaFile)
1307- if(self.debug):
1308- self.logger.debug('Expecting an empty string')
1309- self.logger.debug('OUTPUT: ' + output)
1310 self.assertEqual(output, "")
1311
1312
1313=== modified file 'entertainerlib/tests/test_weather.py'
1314--- entertainerlib/tests/test_weather.py 2009-02-07 17:49:58 +0000
1315+++ entertainerlib/tests/test_weather.py 2009-02-07 21:43:35 +0000
1316@@ -30,12 +30,9 @@
1317 self.weather.set_location('Bath,England')
1318 self.weather.refresh()
1319 forecasts = self.weather.get_forecasts()
1320- try:
1321- today = forecasts[0]
1322- day = datetime.utcnow().strftime('%a')
1323- self.assertEqual(str(today["Day"]), day)
1324- except:
1325- self.fail()
1326+ today = forecasts[0]
1327+ day = datetime.utcnow().strftime('%a')
1328+ self.assertEqual(str(today["Day"]), day)
1329
1330 def testWeatherSet(self):
1331 """Tests the setting of a forecast to a given state"""
1332
1333=== modified file 'entertainerlib/utils/albumart_downloader.py'
1334--- entertainerlib/utils/albumart_downloader.py 2009-01-04 23:22:07 +0000
1335+++ entertainerlib/utils/albumart_downloader.py 2009-02-07 21:43:35 +0000
1336@@ -238,8 +238,8 @@
1337 return
1338
1339 try:
1340- xmldoc = minidom.parseString (result_data)
1341- except:
1342+ xmldoc = minidom.parseString(result_data)
1343+ except (TypeError, AttributeError):
1344 self.search_next()
1345 return
1346
1347@@ -269,12 +269,7 @@
1348 if len(image_urls) == 0:
1349 return
1350 image_url = image_urls[0]
1351- # This doesn't check which result is the best match
1352- #image_url = result[0].ImageUrlLarge
1353- try:
1354- image_file = urllib.urlopen(image_url)
1355- except:
1356- return
1357+ image_file = urllib.urlopen(image_url)
1358 # base64 encode artist and album so there can be a '/' in the artist
1359 # or album
1360 artist_album = self.artist + " - " + self.album
1361
1362=== modified file 'entertainerlib/utils/content_management_dialog.py'
1363--- entertainerlib/utils/content_management_dialog.py 2009-02-07 17:12:21 +0000
1364+++ entertainerlib/utils/content_management_dialog.py 2009-02-07 21:43:35 +0000
1365@@ -126,13 +126,10 @@
1366
1367 def on_dialog_closed(self, widget):
1368 """Callback function for dialog's close button"""
1369- try:
1370- proxy = MessageBusProxy(client_name = "Content Management GUI")
1371- proxy.connectToMessageBus()
1372- proxy.sendMessage(Message(MessageType.CONTENT_CFG_UPDATED))
1373- proxy.disconnectFromMessageBus()
1374- except:
1375- pass # This means that backend is not running. Doesn't matter
1376+ proxy = MessageBusProxy(client_name = "Content Management GUI")
1377+ proxy.connectToMessageBus()
1378+ proxy.sendMessage(Message(MessageType.CONTENT_CFG_UPDATED))
1379+ proxy.disconnectFromMessageBus()
1380
1381 if(self.stand_alone):
1382 self.dialog.hide()
1383@@ -144,13 +141,10 @@
1384
1385 def on_close_button_clicked(self, widget):
1386 """Callback function for dialog's close button"""
1387- try:
1388- proxy = MessageBusProxy(client_name = "Content Management GUI")
1389- proxy.connectToMessageBus()
1390- proxy.sendMessage(Message(MessageType.CONTENT_CFG_UPDATED))
1391- proxy.disconnectFromMessageBus()
1392- except:
1393- pass # This means that backend is not running. Doesn't matter
1394+ proxy = MessageBusProxy(client_name = "Content Management GUI")
1395+ proxy.connectToMessageBus()
1396+ proxy.sendMessage(Message(MessageType.CONTENT_CFG_UPDATED))
1397+ proxy.disconnectFromMessageBus()
1398
1399 if(self.stand_alone):
1400 self.dialog.hide()
1401@@ -182,14 +176,11 @@
1402 widget = self.widgets.get_widget("treeview_videos")
1403 model = widget.get_model()
1404 selection = widget.get_selection().get_selected()
1405- try:
1406- rm_folder = model.get_value(selection[1], 0)
1407- self.video_folders.remove(rm_folder)
1408- str_folders = ";".join(self.video_folders)
1409- self.config.write_content_value("Videos", "folders", str_folders)
1410- model.remove(selection[1])
1411- except:
1412- pass
1413+ rm_folder = model.get_value(selection[1], 0)
1414+ self.video_folders.remove(rm_folder)
1415+ str_folders = ";".join(self.video_folders)
1416+ self.config.write_content_value("Videos", "folders", str_folders)
1417+ model.remove(selection[1])
1418
1419 def on_button_edit_videos_clicked(self, widget):
1420 """Edit currently selected folder"""
1421@@ -197,25 +188,21 @@
1422 url_dialog = self.widgets.get_widget("url_dialog")
1423 url_entry = self.widgets.get_widget("url_entry")
1424 model = widget.get_model()
1425- try:
1426- selection = widget.get_selection().get_selected()
1427- folder = model.get_value(selection[1], 0)
1428- url_entry.set_text(folder)
1429- url_dialog.set_title(_("Edit URL"))
1430- status = url_dialog.run()
1431- if status == gtk.RESPONSE_OK and os.path.exists(self.url):
1432- # Update list model
1433- model.set_value(selection[1], 0, self.url)
1434- # Update configure file
1435- pos = self.video_folders.index(folder)
1436- self.video_folders.remove(folder)
1437- self.video_folders.insert(pos, self.url)
1438- str_folders = ";".join(self.video_folders)
1439- self.config.write_content_value("Videos", "folders",
1440- str_folders)
1441- except:
1442- # No need for actions. Item wasn't selected.
1443- pass
1444+ selection = widget.get_selection().get_selected()
1445+ folder = model.get_value(selection[1], 0)
1446+ url_entry.set_text(folder)
1447+ url_dialog.set_title(_("Edit URL"))
1448+ status = url_dialog.run()
1449+ if status == gtk.RESPONSE_OK and os.path.exists(self.url):
1450+ # Update list model
1451+ model.set_value(selection[1], 0, self.url)
1452+ # Update configure file
1453+ pos = self.video_folders.index(folder)
1454+ self.video_folders.remove(folder)
1455+ self.video_folders.insert(pos, self.url)
1456+ str_folders = ";".join(self.video_folders)
1457+ self.config.write_content_value("Videos", "folders",
1458+ str_folders)
1459
1460 def on_checkbutton_video_metadata_toggled(self, widget):
1461 """
1462@@ -250,40 +237,32 @@
1463 widget = self.widgets.get_widget("treeview_music")
1464 model = widget.get_model()
1465 selection = widget.get_selection().get_selected()
1466- try:
1467- rm_folder = model.get_value(selection[1], 0)
1468- self.music_folders.remove(rm_folder)
1469+ rm_folder = model.get_value(selection[1], 0)
1470+ self.music_folders.remove(rm_folder)
1471+ str_folders = ";".join(self.music_folders)
1472+ self.config.write_content_value("Music", "folders", str_folders)
1473+ model.remove(selection[1])
1474+
1475+ def on_button_edit_music_clicked(self, widget):
1476+ """Edit currently selected music folder"""
1477+ widget = self.widgets.get_widget("treeview_music")
1478+ url_dialog = self.widgets.get_widget("url_dialog")
1479+ url_entry = self.widgets.get_widget("url_entry")
1480+ model = widget.get_model()
1481+ selection = widget.get_selection().get_selected()
1482+ folder = model.get_value(selection[1], 0)
1483+ url_entry.set_text(folder)
1484+ url_dialog.set_title(_("Edit URL"))
1485+ status = url_dialog.run()
1486+ if status == gtk.RESPONSE_OK and os.path.exists(self.url):
1487+ # Update list model
1488+ model.set_value(selection[1], 0, self.url)
1489+ # Update configure file
1490+ pos = self.music_folders.index(folder)
1491+ self.music_folders.remove(folder)
1492+ self.music_folders.insert(pos, self.url)
1493 str_folders = ";".join(self.music_folders)
1494 self.config.write_content_value("Music", "folders", str_folders)
1495- model.remove(selection[1])
1496- except:
1497- # No need for actions. Item wasn't selected.
1498- pass
1499-
1500- def on_button_edit_music_clicked(self, widget):
1501- """Edit currently selected music folder"""
1502- widget = self.widgets.get_widget("treeview_music")
1503- url_dialog = self.widgets.get_widget("url_dialog")
1504- url_entry = self.widgets.get_widget("url_entry")
1505- model = widget.get_model()
1506- try:
1507- selection = widget.get_selection().get_selected()
1508- folder = model.get_value(selection[1], 0)
1509- url_entry.set_text(folder)
1510- url_dialog.set_title(_("Edit URL"))
1511- status = url_dialog.run()
1512- if status == gtk.RESPONSE_OK and os.path.exists(self.url):
1513- # Update list model
1514- model.set_value(selection[1], 0, self.url)
1515- # Update configure file
1516- pos = self.music_folders.index(folder)
1517- self.music_folders.remove(folder)
1518- self.music_folders.insert(pos, self.url)
1519- str_folders = ";".join(self.music_folders)
1520- self.config.write_content_value("Music", "folders", str_folders)
1521- except:
1522- # No need for actions. Item wasn't selected.
1523- pass
1524
1525 def on_button_add_images_clicked(self, widget):
1526 """Opens add URL dialog. """
1527@@ -307,41 +286,33 @@
1528 widget = self.widgets.get_widget("treeview_images")
1529 model = widget.get_model()
1530 selection = widget.get_selection().get_selected()
1531- try:
1532- rm_folder = model.get_value(selection[1], 0)
1533- self.image_folders.remove(rm_folder)
1534+ rm_folder = model.get_value(selection[1], 0)
1535+ self.image_folders.remove(rm_folder)
1536+ str_folders = ";".join(self.image_folders)
1537+ self.config.write_content_value("Images", "folders", str_folders)
1538+ model.remove(selection[1])
1539+
1540+ def on_button_edit_images_clicked(self, widget):
1541+ """Edit currently selected music folder"""
1542+ widget = self.widgets.get_widget("treeview_images")
1543+ url_dialog = self.widgets.get_widget("url_dialog")
1544+ url_entry = self.widgets.get_widget("url_entry")
1545+ model = widget.get_model()
1546+ selection = widget.get_selection().get_selected()
1547+ folder = model.get_value(selection[1], 0)
1548+ url_entry.set_text(folder)
1549+ url_dialog.set_title(_("Edit URL"))
1550+ status = url_dialog.run()
1551+ if status == gtk.RESPONSE_OK and os.path.exists(self.url):
1552+ # Update list model
1553+ model.set_value(selection[1], 0, self.url)
1554+ # Update configure file
1555+ pos = self.image_folders.index(folder)
1556+ self.image_folders.remove(folder)
1557+ self.image_folders.insert(pos, self.url)
1558 str_folders = ";".join(self.image_folders)
1559- self.config.write_content_value("Images", "folders", str_folders)
1560- model.remove(selection[1])
1561- except:
1562- # No need for actions. Item wasn't selected.
1563- pass
1564-
1565- def on_button_edit_images_clicked(self, widget):
1566- """Edit currently selected music folder"""
1567- widget = self.widgets.get_widget("treeview_images")
1568- url_dialog = self.widgets.get_widget("url_dialog")
1569- url_entry = self.widgets.get_widget("url_entry")
1570- model = widget.get_model()
1571- try:
1572- selection = widget.get_selection().get_selected()
1573- folder = model.get_value(selection[1], 0)
1574- url_entry.set_text(folder)
1575- url_dialog.set_title(_("Edit URL"))
1576- status = url_dialog.run()
1577- if status == gtk.RESPONSE_OK and os.path.exists(self.url):
1578- # Update list model
1579- model.set_value(selection[1], 0, self.url)
1580- # Update configure file
1581- pos = self.image_folders.index(folder)
1582- self.image_folders.remove(folder)
1583- self.image_folders.insert(pos, self.url)
1584- str_folders = ";".join(self.image_folders)
1585- self.config.write_content_value("Images", "folders",
1586- str_folders)
1587- except:
1588- # No need for actions. Item wasn't selected.
1589- pass
1590+ self.config.write_content_value("Images", "folders",
1591+ str_folders)
1592
1593 def on_button_add_feed_clicked(self, widget):
1594 """Opens add feed dialog. """
1595@@ -363,15 +334,11 @@
1596 widget = self.widgets.get_widget("treeview_feeds")
1597 model = widget.get_model()
1598 selection = widget.get_selection().get_selected()
1599- try:
1600- rm_folder = model.get_value(selection[1], 0)
1601- self.feeds.remove(rm_folder)
1602- str_folders = ";".join(self.feeds)
1603- self.config.write_content_value("RSS", "feeds", str_folders)
1604- model.remove(selection[1])
1605- except:
1606- # No need for actions. Item wasn't selected.
1607- pass
1608+ rm_folder = model.get_value(selection[1], 0)
1609+ self.feeds.remove(rm_folder)
1610+ str_folders = ";".join(self.feeds)
1611+ self.config.write_content_value("RSS", "feeds", str_folders)
1612+ model.remove(selection[1])
1613
1614 def on_button_edit_feed_clicked(self, widget):
1615 """Edit currently selected feed"""
1616@@ -379,24 +346,20 @@
1617 url_dialog = self.widgets.get_widget("url_dialog")
1618 url_entry = self.widgets.get_widget("url_entry")
1619 model = widget.get_model()
1620- try:
1621- selection = widget.get_selection().get_selected()
1622- feed = model.get_value(selection[1], 0)
1623- url_entry.set_text(feed)
1624- url_dialog.set_title(_("Edit feed"))
1625- status = url_dialog.run()
1626- if status == gtk.RESPONSE_OK:
1627- # Update list model
1628- model.set_value(selection[1], 0, self.url)
1629- # Update configure file
1630- pos = self.feeds.index(feed)
1631- self.feeds.remove(feed)
1632- self.feeds.insert(pos, self.url)
1633- str_feeds = ";".join(self.feeds)
1634- self.config.write_content_value("RSS", "feeds", str_feeds)
1635- except:
1636- # No need for actions. Item wasn't selected.
1637- pass
1638+ selection = widget.get_selection().get_selected()
1639+ feed = model.get_value(selection[1], 0)
1640+ url_entry.set_text(feed)
1641+ url_dialog.set_title(_("Edit feed"))
1642+ status = url_dialog.run()
1643+ if status == gtk.RESPONSE_OK:
1644+ # Update list model
1645+ model.set_value(selection[1], 0, self.url)
1646+ # Update configure file
1647+ pos = self.feeds.index(feed)
1648+ self.feeds.remove(feed)
1649+ self.feeds.insert(pos, self.url)
1650+ str_feeds = ";".join(self.feeds)
1651+ self.config.write_content_value("RSS", "feeds", str_feeds)
1652
1653 def on_button_open_list_clicked(self, widget):
1654 """Opens the open feed source dialog"""
1655@@ -563,54 +526,30 @@
1656 Rebuild video cache requested
1657 @param widget: GTK-Widget
1658 """
1659- try:
1660- proxy = MessageBusProxy(client_name = "Content Management GUI")
1661- proxy.connectToMessageBus()
1662- proxy.sendMessage(Message(MessageType.REBUILD_VIDEO_CACHE))
1663- proxy.disconnectFromMessageBus()
1664- except:
1665- # This means that backend is not running. Doesn't matter
1666- error = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
1667- gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
1668- _("Entertainer backend is not running. Cache cannot be rebuilt."))
1669- error.run()
1670- error.destroy()
1671+ proxy = MessageBusProxy(client_name = "Content Management GUI")
1672+ proxy.connectToMessageBus()
1673+ proxy.sendMessage(Message(MessageType.REBUILD_VIDEO_CACHE))
1674+ proxy.disconnectFromMessageBus()
1675
1676 def on_button_music_rebuild_clicked(self, widget):
1677 """
1678 Rebuild music cache requested
1679 @param widget: GTK-Widget
1680 """
1681- try:
1682- proxy = MessageBusProxy(client_name = "Content Management GUI")
1683- proxy.connectToMessageBus()
1684- proxy.sendMessage(Message(MessageType.REBUILD_MUSIC_CACHE))
1685- proxy.disconnectFromMessageBus()
1686- except:
1687- # This means that backend is not running. Doesn't matter
1688- error = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
1689- gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
1690- _("Entertainer backend is not running. Cache cannot be rebuilt."))
1691- error.run()
1692- error.destroy()
1693+ proxy = MessageBusProxy(client_name = "Content Management GUI")
1694+ proxy.connectToMessageBus()
1695+ proxy.sendMessage(Message(MessageType.REBUILD_MUSIC_CACHE))
1696+ proxy.disconnectFromMessageBus()
1697
1698 def on_button_image_rebuild_clicked(self, widget):
1699 """
1700 Rebuild image cache requested
1701 @param widget: GTK-Widget
1702 """
1703- try:
1704- proxy = MessageBusProxy(client_name = "Content Management GUI")
1705- proxy.connectToMessageBus()
1706- proxy.sendMessage(Message(MessageType.REBUILD_IMAGE_CACHE))
1707- proxy.disconnectFromMessageBus()
1708- except:
1709- # This means that backend is not running. Doesn't matter
1710- error = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
1711- gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
1712- _("Entertainer backend is not running. Cache cannot be rebuilt."))
1713- error.run()
1714- error.destroy()
1715+ proxy = MessageBusProxy(client_name = "Content Management GUI")
1716+ proxy.connectToMessageBus()
1717+ proxy.sendMessage(Message(MessageType.REBUILD_IMAGE_CACHE))
1718+ proxy.disconnectFromMessageBus()
1719
1720 def on_button_feed_rebuild_clicked(self, widget):
1721 """
1722@@ -624,18 +563,10 @@
1723 status = dialog.run()
1724 #If user has ok'd the request send the message to the message bus
1725 if(status == gtk.RESPONSE_OK):
1726- try:
1727- proxy = MessageBusProxy(client_name = "Content Management GUI")
1728- proxy.connectToMessageBus()
1729- proxy.sendMessage(Message(MessageType.REBUILD_FEED_CACHE))
1730- proxy.disconnectFromMessageBus()
1731- except:
1732- # This means that backend is not running. Doesn't matter
1733- error = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
1734- gtk.MESSAGE_ERROR, gtk.BUTTONS_OK,
1735- _("Entertainer backend is not running. Cache cannot be rebuilt."))
1736- error.run()
1737- error.destroy()
1738+ proxy = MessageBusProxy(client_name = "Content Management GUI")
1739+ proxy.connectToMessageBus()
1740+ proxy.sendMessage(Message(MessageType.REBUILD_FEED_CACHE))
1741+ proxy.disconnectFromMessageBus()
1742 dialog.destroy()
1743
1744 def init_dialog_values_from_configure_file(self):
1745
1746=== modified file 'entertainerlib/utils/feed_utils.py'
1747--- entertainerlib/utils/feed_utils.py 2009-02-07 17:12:21 +0000
1748+++ entertainerlib/utils/feed_utils.py 2009-02-08 07:43:25 +0000
1749@@ -62,11 +62,8 @@
1750 in_tag = False
1751 parse_list.pop(i)
1752 #check if tag matches
1753- try:
1754- if len(valid_tag_list) > valid_tag_list.index(tag):
1755- output += ("<" + tag + tag_attributes + ">")
1756- except:
1757- pass
1758+ if tag in valid_tag_list:
1759+ output += ("<" + tag + tag_attributes + ">")
1760 tag = ""
1761 tag_attributes = ""
1762 elif in_tag_name:
1763
1764=== modified file 'entertainerlib/utils/lyrics_downloader.py'
1765--- entertainerlib/utils/lyrics_downloader.py 2008-08-07 01:17:29 +0000
1766+++ entertainerlib/utils/lyrics_downloader.py 2009-02-07 21:43:35 +0000
1767@@ -48,12 +48,9 @@
1768 Search lyrics and download if found
1769 """
1770 lyrics = ""
1771- try:
1772- self._clean_up_artist_title()
1773- lyrics_xml = self._get_lyrics_xml()
1774- lyrics = self._parse_lyrics_xml(lyrics_xml)
1775- except:
1776- lyrics = None
1777+ self._clean_up_artist_title()
1778+ lyrics_xml = self._get_lyrics_xml()
1779+ lyrics = self._parse_lyrics_xml(lyrics_xml)
1780 self.callback(lyrics)
1781
1782 def _clean_up_artist_title(self):
1783@@ -95,10 +92,7 @@
1784
1785 def _parse_lyrics_xml(self, lyrics_xml):
1786 """Parse lyrics XML and return lyrics string"""
1787- try:
1788- xmldoc = minidom.parseString(lyrics_xml).documentElement
1789- except:
1790- raise Exception("Can't get lyrics for this track.")
1791+ xmldoc = minidom.parseString(lyrics_xml).documentElement
1792
1793 # Get the lyric from the XML file
1794 lyrics = xmldoc.getElementsByTagName('tx')[0].firstChild.nodeValue
1795
1796=== modified file 'entertainerlib/utils/preferences_dialog.py'
1797--- entertainerlib/utils/preferences_dialog.py 2009-02-07 20:28:47 +0000
1798+++ entertainerlib/utils/preferences_dialog.py 2009-02-07 21:43:35 +0000
1799@@ -88,15 +88,7 @@
1800 # If theme was selected with file chooser
1801 if(status == gtk.RESPONSE_OK):
1802 package = dialog.get_filename()
1803- try:
1804- tar = tarfile.open(package, 'r:gz') # Open tar.gz package
1805- except:
1806- error = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
1807- gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("Invalid theme file!"))
1808- error.run()
1809- error.destroy()
1810- dialog.destroy()
1811- return
1812+ tar = tarfile.open(package, 'r:gz') # Open tar.gz package
1813
1814 # Make sure that package contains configuration file (is theme)
1815 content = tar.getnames()
1816@@ -213,13 +205,10 @@
1817
1818 def close(self):
1819 """Close Dialog"""
1820- try:
1821- proxy = MessageBusProxy(client_name = "Preferences GUI")
1822- proxy.connectToMessageBus()
1823- proxy.sendMessage(Message(MessageType.PREFERENCES_CFG_UPDATED))
1824- proxy.disconnectFromMessageBus()
1825- except:
1826- pass # This means that backend is not running. Doesn't matter
1827+ proxy = MessageBusProxy(client_name = "Preferences GUI")
1828+ proxy.connectToMessageBus()
1829+ proxy.sendMessage(Message(MessageType.PREFERENCES_CFG_UPDATED))
1830+ proxy.disconnectFromMessageBus()
1831
1832 if(self.STAND_ALONE):
1833 self.pref_dialog.hide()
1834@@ -249,19 +238,16 @@
1835 themelist_widget.set_model(model)
1836
1837 # Set current theme selected in theme list
1838- try:
1839- index = model.get_iter_first()
1840- unselected = True
1841- index_counter = 0
1842- while(unselected):
1843- name = model.get_value(iter, 0)
1844- if name == current_theme:
1845- unselected = False
1846- themelist_widget.set_cursor(index_counter)
1847- index = model.iter_next(index)
1848- index_counter += 1
1849- except:
1850- pass # Error in configfile
1851+ index = model.get_iter_first()
1852+ unselected = True
1853+ index_counter = 0
1854+ while(unselected):
1855+ name = model.get_value(iter, 0)
1856+ if name == current_theme:
1857+ unselected = False
1858+ themelist_widget.set_cursor(index_counter)
1859+ index = model.iter_next(index)
1860+ index_counter += 1
1861
1862 # Checkboxes
1863 effect_checkbox = self.widgets.get_widget("effect_checkbox")
1864
1865=== modified file 'entertainerlib/utils/theme.py'
1866--- entertainerlib/utils/theme.py 2009-02-06 08:13:48 +0000
1867+++ entertainerlib/utils/theme.py 2009-02-07 21:43:35 +0000
1868@@ -38,49 +38,45 @@
1869 print "IOError: Couldn't read theme file."
1870 sys.exit(1)
1871
1872- try:
1873- # Get theme information
1874- self.name = theme.get("Theme", "name")
1875- self.comment = theme.get("Theme", "comment")
1876- self.author = theme.get("Theme", "author")
1877- self.licence = theme.get("Theme", "licence")
1878- self.copyright = theme.get("Theme", "copyright")
1879-
1880- #The theme font must be pango compatible font, hence this code
1881- #checks the theme font against the pango list generated from a
1882- #pango context object and then sets self.font if the font is
1883- #compatible. Unfortunately the list can only be generated from a
1884- #gtk object at present.
1885- self._font = ""
1886- tmp_font = theme.get("Theme", "font")
1887-
1888- for font in gtk.TreeView().get_pango_context().list_families():
1889- if font.get_name() == tmp_font:
1890- self._font = tmp_font
1891-
1892- if self.font == "":
1893- self._font = "Arial"
1894-
1895- # Get theme colors
1896- self.color = {}
1897- self.color['background'] = theme.get(
1898- "Colors", "background").split(',')
1899- self.color['title'] = theme.get("Colors", "title").split(',')
1900- self.color['subtitle'] = theme.get("Colors", "subtitle").split(',')
1901- self.color['screentitle'] = theme.get(
1902- "Colors", "screentitle").split(',')
1903- self.color['text'] = theme.get("Colors", "text").split(',')
1904- self.color['menuitem_active'] = theme.get(
1905- "Colors", "menuitem_active").split(',')
1906- self.color['menuitem_inactive'] = theme.get(
1907- "Colors", "menuitem_inactive").split(',')
1908- self.color['arrow_foreground'] = theme.get(
1909- "Colors", "arrow_foreground").split(',')
1910- self.color['arrow_background'] = theme.get(
1911- "Colors", "arrow_background").split(',')
1912- except:
1913- print "Invalid theme.conf file!"
1914- sys.exit(1)
1915+ # Get theme information
1916+ self.name = theme.get("Theme", "name")
1917+ self.comment = theme.get("Theme", "comment")
1918+ self.author = theme.get("Theme", "author")
1919+ self.licence = theme.get("Theme", "licence")
1920+ self.copyright = theme.get("Theme", "copyright")
1921+
1922+ #The theme font must be pango compatible font, hence this code
1923+ #checks the theme font against the pango list generated from a
1924+ #pango context object and then sets self.font if the font is
1925+ #compatible. Unfortunately the list can only be generated from a
1926+ #gtk object at present.
1927+ self._font = ""
1928+ tmp_font = theme.get("Theme", "font")
1929+
1930+ for font in gtk.TreeView().get_pango_context().list_families():
1931+ if font.get_name() == tmp_font:
1932+ self._font = tmp_font
1933+
1934+ if self.font == "":
1935+ self._font = "Arial"
1936+
1937+ # Get theme colors
1938+ self.color = {}
1939+ self.color['background'] = theme.get(
1940+ "Colors", "background").split(',')
1941+ self.color['title'] = theme.get("Colors", "title").split(',')
1942+ self.color['subtitle'] = theme.get("Colors", "subtitle").split(',')
1943+ self.color['screentitle'] = theme.get(
1944+ "Colors", "screentitle").split(',')
1945+ self.color['text'] = theme.get("Colors", "text").split(',')
1946+ self.color['menuitem_active'] = theme.get(
1947+ "Colors", "menuitem_active").split(',')
1948+ self.color['menuitem_inactive'] = theme.get(
1949+ "Colors", "menuitem_inactive").split(',')
1950+ self.color['arrow_foreground'] = theme.get(
1951+ "Colors", "arrow_foreground").split(',')
1952+ self.color['arrow_background'] = theme.get(
1953+ "Colors", "arrow_background").split(',')
1954
1955 # Build the image array : image[name] = filename
1956 self.image = {}
1957@@ -164,12 +160,8 @@
1958 def get_color(self, element):
1959 """Return color for the element as a tuple of (r, b, g, a)."""
1960 if self.color.has_key(element):
1961- try:
1962- color = self.color[element]
1963- return (int(color[0]), int(color[1]), int(color[2]),
1964- int(color[3]))
1965- except:
1966- return (255, 0, 0, 255)
1967+ color = [int(ele) for ele in self.color[element]]
1968+ return (color[0], color[1], color[2], color[3])
1969 else:
1970 # On error we return bright red.
1971 return (255, 0, 0, 255)
1972
1973=== modified file 'entertainerlib/utils/video_thumbnailer.py'
1974--- entertainerlib/utils/video_thumbnailer.py 2009-02-07 21:53:37 +0000
1975+++ entertainerlib/utils/video_thumbnailer.py 2009-02-07 22:12:25 +0000
1976@@ -188,8 +188,7 @@
1977
1978 try:
1979 duration = self._pipeline.query_duration(gst.FORMAT_TIME)[0]
1980- except Exception:
1981- ## FIXME: precise this exception
1982+ except AssertionError:
1983 #Gstreamer cannot determine the media duration using
1984 #playing-thumbnailing for file
1985 self.set_pipeline_state(self._pipeline, gst.STATE_NULL)
1986@@ -225,7 +224,6 @@
1987 '''
1988 Plays the video file to gather information for generating a thumbnail
1989 '''
1990- fileid = None
1991 self._img = None
1992
1993 if duration >= 250000:
1994@@ -280,12 +278,8 @@
1995
1996 frame = self._sink.get_current_frame()
1997
1998- try:
1999- img = Image.frombuffer("RGB", sink_size, frame, "raw", "RGB",
2000- 0, 1)
2001- except:
2002- #Invalid frame
2003- continue
2004+ img = Image.frombuffer(
2005+ "RGB", sink_size, frame, "raw", "RGB", 0, 1)
2006
2007 if self.interesting_image(img):
2008 break
2009
2010=== modified file 'pylintrc'
2011--- pylintrc 2009-02-07 21:53:37 +0000
2012+++ pylintrc 2009-02-08 08:12:04 +0000
2013@@ -56,20 +56,13 @@
2014 # E1101 and E1103 are broken, as it reports non-existing members when the
2015 # member is inherited.
2016 # W0142 checks for * or ** argument magic
2017+# W0232 checks that in __init__ method is always present
2018+# W0613 is a warning about unused arguments.
2019+# W0201 checks for attributes defined outside init
2020
2021-# XXX: rockstar - W0613 is a warning about unused arguments. This can be a
2022-# little misleading, since cluttergst needs a few parameters that pylint
2023-# doesn't see getting used
2024 # XXX: rockstar - C0103 constrains method and function names to a regex
2025-# XXX: rockstar - W0702 constrains calls to except to specific Exceptions
2026-# XXX: rockstar - W0232 ensures that an __init__ method is always present
2027 # XXX: rockstar - W0511 checks for XXX, TODO, and FIXME
2028-# XXX: rockstar - W0201 checks for attributes defined outside init
2029-# XXX: rockstar - W0703 er, I have no idea what it does
2030-# XXX: rockstar - W0704 checks for empty except
2031-# XXX: rockstar - W0221 checks for inherited function signatures for similar
2032-# args
2033-disable-msg=I0011,R0201,R0801,R0901,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0923,W0613,C0103,W0702,W0232,W0511,W0201,E1101,W0703,W0704,E1103,W0221,W0142
2034+disable-msg=I0011,R0201,R0801,R0901,R0902,R0903,R0904,R0911,R0912,R0913,R0914,R0915,R0923,W0613,C0103,W0232,W0201,E1101,E1103,W0142
2035
2036
2037 [REPORTS]
2038@@ -302,7 +295,7 @@
2039 [MISCELLANEOUS]
2040
2041 # List of note tags to take in consideration, separated by a comma.
2042-notes=FIXME,XXX,TODO
2043+notes=FIXME
2044
2045
2046 # checks for similarities and duplicated code. This computation may be

Subscribers

People subscribed via source and target branches