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