Merge lp:~rockstar/entertainer/more-pylint-fun into lp:entertainer

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

This branch enables more pylint warnings, mostly concerning how exceptions are
handled. The big thing is that catchall exceptions like...

try:
    do_stuff()
except:
    pass

...is no longer allowed. Also, doing a flat "pass" right after an exception is
also not allowed. And just doing "except Exception" is also not good (it's the
same as not specifying an exception at all).

The other pylint error fixed is cases where the inherited class doesn't
implement the same method signature as its parent class.

Other pylint warnings were made permanent. For instance, methods and functions
that have unused arguments aren't really a huge concern, especially in cases
where a method is overridden, or it's a clutter function we have no control
over. __init__ methods don't always have to be present, and sometimes instance
attributes shoould be initialized in a method other than __init__ (although is
almost always called from __init__ only).

I'm really concerned that removing some of these exceptions mean that we're
going to have to do some MASSIVE QA. It means that we'll have a more stable
codebase in the long run, but since we're not suppressing errors anymore, we're
going to get a lot of exceptions bubbling up and an in-flux of bugs is likely.
I found, however, that when I tried to find a way to catch an exception and
just move on, there was a better way to approach the code itself, like checking
for a non-empty list before even considering operating on it.

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

Looks good. Let the breakage begin.

One comment: I think you fix a bunch of tech-debt bugs with this branch, but you haven't linked to any of them.

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

Hi Paul,

branch description : ok
make test : ok
make lint :
************* Module entertainerlib.frontend.frontend_client
W0612: 50:FrontendClient.__init__: Unused variable 'system_tray_icon'
=> This one is not linked to your branch because it's also there in trunk so it's ok

> This branch enables more pylint warnings, mostly concerning how exceptions are
> handled. The big thing is that catchall exceptions like...
>
> try:
> do_stuff()
> except:
> pass
>
> ...is no longer allowed. Also, doing a flat "pass" right after an exception is
> also not allowed. And just doing "except Exception" is also not good (it's the
> same as not specifying an exception at all).

Okay, no problem with that. It will help to get the code more robust. Need to catch exception from file IO and from network tough.

> The other pylint error fixed is cases where the inherited class doesn't
> implement the same method signature as its parent class.
>
> Other pylint warnings were made permanent. For instance, methods and functions
> that have unused arguments aren't really a huge concern, especially in cases
> where a method is overridden, or it's a clutter function we have no control
> over.

Agreed it's good for the code.

> __init__ methods don't always have to be present, and sometimes instance
> attributes shoould be initialized in a method other than __init__ (although is
> almost always called from __init__ only).

Sure __init__ is not mandatory when there's no needed argument initialization. But what's the interest not to do them in the __init__ method ?

content-manager broken on my box.
Here is what I have when I try to close it:

Traceback (most recent call last):
  File "/mnt/raid/Programmes/branches_entertainer/more-pylint-fun/entertainerlib/utils/content_management_dialog.py", line 145, in on_close_button_clicked
    proxy.connectToMessageBus()
  File "/mnt/raid/Programmes/branches_entertainer/more-pylint-fun/entertainerlib/backend/core/message_bus_proxy.py", line 63, in connectToMessageBus
    self.socket_to_server.connect(('localhost', self.config.get_port()))
  File "<string>", line 1, in connect

entertainer-preferences broken on my desktop.
Here is what I have trying to run it :

Traceback (most recent call last):
  File "./entertainer-preferences", line 12, in <module>
    PreferencesDialog(True)
  File "/mnt/raid/Programmes/branches_entertainer/more-pylint-fun/entertainerlib/utils/preferences_dialog.py", line 62, in __init__
    self.init_dialog_values_from_configure_file()
  File "/mnt/raid/Programmes/branches_entertainer/more-pylint-fun/entertainerlib/utils/preferences_dialog.py", line 245, in init_dialog_values_from_configure_file
    name = model.get_value(iter, 0)
TypeError: iter must be a GtkTreeIter

=== modified file 'entertainerlib/backend/components/mediacache/image_cache.py'
--- entertainerlib/backend/components/mediacache/image_cache.py 2009-02-06 08:13:48 +0000
+++ entertainerlib/backend/components/mediacache/image_cache.py 2009-02-08 19:09:10 +0000
@@ -57,37 +57,26 @@
             thumb_file = os.path.join(self.config.IMAGE_THUMB_DIR, element)
             try:
                 os.remove(thumb_file)
- excep...

350. By Paul Hummer

Handled exceptions when the backend isn't running

351. By Paul Hummer

Fixed exceptions in Preferences dialog

352. By Paul Hummer

Fixed a small test issue and a small lint issue

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

Subscribers

People subscribed via source and target branches