From: Rory Y. <ror...@gm...> - 2014-02-16 06:37:34
|
Hi, This Python script: import gpod db=gpod.Database('/media/rory/IPOD') pc=db.get_podcasts() print '>RORY> gpod version: %s' % gpod.version print '>RORY> FOUND %d podcasts' % len(pc) db.close() produces this output: >RORY> gpod version: 0.8.2 >RORY> FOUND 62 podcasts ** (count_podcasts.py:24009): CRITICAL **: itdb_splr_validate: assertion 'at != ITDB_SPLAT_UNKNOWN' failed libitdbprep: itdb_sqlite_generate_itdbs called with file /media/rory/IPOD/iPod_Control/iTunes/iTunesCDB and uuid 000A2700209D1DD6 itlp directory='/media/rory/IPOD/iPod_Control/iTunes/iTunes Library.itlp' *.itdb files will be stored in '/media/rory/IPOD/iPod_Control/iTunes/iTunes Library.itlp' [mk_Dynamic] Processing '/tmp/fileQyzXqi/Dynamic.itdb' [mk_Dynamic] creating table structure [mk_Dynamic] - processing 1410 tracks [mk_Dynamic] - processing 7 playlists [mk_Dynamic] done. [mk_Extras] Processing '/tmp/fileQyzXqi/Extras.itdb' [mk_Extras] re-building table structure [mk_Extras] done. [mk_Genius] Processing '/tmp/fileQyzXqi/Genius.itdb' [mk_Genius] re-building table structure [mk_Genius] done. library_persistent_id = 0xace01813e3ec0b44 [mk_Library] Processing '/tmp/fileQyzXqi/Library.itdb' [mk_Library] building table structure [mk_Library] compiling SQL statements [mk_Library] - inserting into "version_info" [mk_Library] - inserting into "genre_map" [mk_Library] - inserting songs into "item_to_container" [mk_Library] - inserting playlist 'IPOD' into "container" [mk_Library] - inserting songs into "item_to_container" [mk_Library] - inserting playlist 'Podcasts' into "container" [mk_Library] - inserting songs into "item_to_container" [mk_Library] - inserting playlist 'rutabaga' into "container" [mk_Library] - inserting songs into "item_to_container" [mk_Library] - inserting playlist 'myvids' into "container" [mk_Library] - inserting songs into "item_to_container" [mk_Library] - inserting playlist 'kale' into "container" [mk_Library] - inserting songs into "item_to_container" [mk_Library] - inserting playlist 'New playlist' into "container" [mk_Library] - inserting songs into "item_to_container" [mk_Library] - inserting playlist '2013-07-21' into "container" library_persistent_id = 0xace01813e3ec0b44 device name = IPOD [mk_Library] - inserting into "db_info" [mk_Library] - processing 1410 tracks [mk_Library] done. [mk_Locations] Processing '/tmp/fileQyzXqi/Locations.itdb' [mk_Locations] re-building table structure [mk_Locations] Processing 1410 tracks... [mk_Locations] done. [run_post_process_commands] Getting SQL post process commands [run_post_process_commands] binding functions [run_post_process_commands] Running 88 post process commands now [run_post_process_commands] ERROR when executing 'CreateRentalExpiredColumn': duplicate column name: rental_expired [run_post_process_commands] 87 out of 88 post process commands successfully executed [run_post_process_commands] done. itdbprep: copying 'Dynamic.itdb' itdbprep: copying 'Extras.itdb' itdbprep: copying 'Genius.itdb' itdbprep: copying 'Library.itdb' itdbprep: copying 'Locations.itdb' itdbprep: copying 'Locations.itdb.cbk' (version is 0.8.2 because that's running against the default Ubuntu 13.10 version.) libgpod's output is a little verbose, and there isn't an obvious way to keep it quiet ("2>/dev/null" isn't a great option). So, I've changed all the printf and fprintf calls in src/*.c so that the default is to print nothing: rory@rory-Inspiron-3521:~/hack/gpod$ python count_podcasts.py >RORY> gpod version: 0.8.3 >RORY> FOUND 62 podcasts ** (process:24018): CRITICAL **: itdb_splr_validate: assertion 'at != ITDB_SPLAT_UNKNOWN' failed (this, incidentally, highlights the assertion failure which was rather buried in the noise). One can print error messages by setting ITDB_LOGLEVEL, so for example: rory@rory-Inspiron-3521:~/hack/gpod$ ITDB_LOGLEVEL=1 python count_podcasts.py >RORY> gpod version: 0.8.3 >RORY> FOUND 62 podcasts ** (process:24017): CRITICAL **: itdb_splr_validate: assertion 'at != ITDB_SPLAT_UNKNOWN' failed [mk_Dynamic] creating table structure [mk_Extras] re-building table structure [mk_Genius] re-building table structure [mk_Library] building table structure [mk_Library] compiling SQL statements [mk_Locations] re-building table structure itdbprep: copying 'Dynamic.itdb' itdbprep: copying 'Extras.itdb' itdbprep: copying 'Genius.itdb' itdbprep: copying 'Library.itdb' itdbprep: copying 'Locations.itdb' itdbprep: copying 'Locations.itdb.cbk' ITDB_LOGLEVEL=2 produces the original output. Alternatives to this are to use a logging library, such as log4c or zlog, or, for error messages, to store the error string, report an error condition, and use something similar to the standard library's strerror() to allow the caller to retrieve a detailed error message. This could be useful for GUI messages and constructing Python exceptions. Possible improvements to this patch set: - decide on loglevel once, rather than calling setenv(), strtol(), etc., every call - make the functions internal (G_GNUC_INTERNAL - I forgot about this) Review and comments welcome. Regards, Rory |