Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Development

Notices

Reply
 
Thread Tools Search this Thread
Old 11-07-2021, 05:35 PM   #1
hobleyd
Junior Member
hobleyd began at the beginning.
 
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)
but while the print of booklist shows:

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>]
the processing book line only outputs a single book and then appears to just stop outputting anything.

Code:
processing book: 8ed92285-8d1c-45c3-b756-f5f39fca4b52
DeviceJob: 2 Get list of books on device callback returned
Can anyone point me in the right direction as to why the output stops; calibre keeps running; everything looks normal except for the fact that the updates I pushed through are ignored and it is difficult to work out why without debug statements!

Cheers,
David
hobleyd is offline   Reply With Quote
Old 11-07-2021, 09:23 PM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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.
kovidgoyal is offline   Reply With Quote
Advert
Old 11-08-2021, 04:50 PM   #3
hobleyd
Junior Member
hobleyd began at the beginning.
 
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
while I see my initial print statement, I should get a succeeded or failed from the subsequent 2 print statements, but see nothing.
hobleyd is offline   Reply With Quote
Old 11-08-2021, 06:17 PM   #4
jhowell
Grand Sorcerer
jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.jhowell ought to be getting tired of karma fortunes by now.
 
jhowell's Avatar
 
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.
jhowell is offline   Reply With Quote
Old 11-08-2021, 08:58 PM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
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
kovidgoyal is offline   Reply With Quote
Advert
Reply


Forum Jump

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


All times are GMT -4. The time now is 02:52 AM.


MobileRead.com is a privately owned, operated and funded community.