11-07-2021, 05:35 PM | #1 |
Junior Member
Posts: 6
Karma: 10
Join Date: Jun 2014
Device: several
|
trying to debug, print not printing!
Hello,
I am playing around with syncing to calibre; I have an issue whereby updates on my device are not being picked up by calibre. Obviously I have stuffed something up. So, I am trying to trace through the code. The current function of interest is set_books_in_library in src/calibre/gui2/device.py Down in there, I have added some print statements: Code:
with BusyCursor(): current_book_count = 0 for booklist in booklists: print ('booklist: ', booklist) for book in booklist: print ('processing book: ', book.uuid) Code:
booklist: [<calibre.devices.smart_device_app.driver.SDBook object at 0x7ff152f45ac0>, <calibre.devices.smart_device_app.driver.SDBook object at 0x7ff151ce78b0>, <calibre.devices.smart_device_app.driver.SDBook object at 0x7ff151ce79a0>, <calibre.devices.smart_device_app.driver.SDBook object at 0x7ff151ce7850>, <calibre.devices.smart_device_app.driver.SDBook object at 0x7ff1500762e0>, <calibre.devices.smart_device_app.driver.SDBook object at 0x7ff150076070>, <calibre.devices.smart_device_app.driver.SDBook object at 0x7ff151ce76d0>] Code:
processing book: 8ed92285-8d1c-45c3-b756-f5f39fca4b52 DeviceJob: 2 Get list of books on device callback returned Cheers, David |
11-07-2021, 09:23 PM | #2 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
print will print, assuming you are running as calibre-debug -g, the problem is most likely the loop being aborted somewhere lower down.
|
Advert | |
|
11-08-2021, 04:50 PM | #3 |
Junior Member
Posts: 6
Karma: 10
Join Date: Jun 2014
Device: several
|
Yes, I am running as calibre-debug -g; but how do I tell where it is bombing out?
I have added more debug statements: Code:
current_book_count += 1 book.in_library = None print('checking for uuid ', book.uuid, getattr(book, 'uuid', None)) if book.uuid in self.db_book_uuid_cache: print('getattr(book, uuid, None) succeeded: ', uuid) id_ = db_book_uuid_cache[book.uuid] if updateq(id_, book): update_book(id_, book) book.in_library = 'UUID' # ensure that the correct application_id is set book.application_id = id_ continue print('getattr(book, uuid, None) failed: ', uuid) Code:
booklist: [<calibre.devices.smart_device_app.driver.SDBook object at 0x7f88b07d9070>, <calibre.devices.smart_device_app.driver.SDBook object at 0x7f88b07ca4f0>, <calibre.devices.smart_device_app.driver.SDBook object at 0x7f88b07cad00>, <calibre.devices.smart_device_app.driver.SDBook object at 0x7f88c3d6e340>, <calibre.devices.smart_device_app.driver.SDBook object at 0x7f88c3d6e520>, <calibre.devices.smart_device_app.driver.SDBook object at 0x7f88c3d6e430>, <calibre.devices.smart_device_app.driver.SDBook object at 0x7f88c3d5edc0>] processing book: The Color of Magic 8ed92285-8d1c-45c3-b756-f5f39fca4b52 checking for uuid 8ed92285-8d1c-45c3-b756-f5f39fca4b52 8ed92285-8d1c-45c3-b756-f5f39fca4b52 |
11-08-2021, 06:17 PM | #4 |
Grand Sorcerer
Posts: 6,496
Karma: 84420419
Join Date: Nov 2011
Location: Tampa Bay, Florida
Device: Kindles
|
Looking at that my best guess would be that an exception is occurring that is being caught elsewhere. Candidates for the cause of that might be self.db_book_uuid_cache or uuid (as opposed to book.uuid) being undefined.
|
11-08-2021, 08:58 PM | #5 |
creator of calibre
Posts: 43,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Wrap the whole function contents in a try: except: and add a print to print out the exception in the except: block
|
Advert | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Python newbie, need help about print statement debug | TonyAn | Calibre | 3 | 05-17-2017 03:46 PM |
Ctrl-Shft-R Debug vs calibre-debug -g | JimmXinu | Development | 3 | 11-20-2014 09:57 AM |
Print Not Working (nor print to PDF) | foxglove | Calibre | 5 | 03-02-2012 10:05 AM |
Print vs Pixel: retailers experiment with print/ebook bundles | DMcCunney | General Discussions | 42 | 09-15-2010 11:29 AM |