View Single Post
Old 12-17-2019, 05:57 PM   #19
thiago.eec
Wizard
thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.thiago.eec ought to be getting tired of karma fortunes by now.
 
Posts: 1,234
Karma: 1419583
Join Date: Dec 2016
Location: Goiânia - Brazil
Device: iPad, Kindle Paperwhite, Kindle Oasis
Quote:
Originally Posted by eschwartz View Post
@thiago.eec

You can get a debug log by using:

Preferences -> Restart in debug mode

It will create a text file containing the debug log, IIRC.
I did the porting using modernize now. Got better results:

1) ACE ported almost flawlessly. It works fine but for one error in the config dialog:
a) OPEN FOLDER. This gives the same error reported by @JimmXinu.
Spoiler:

calibre, version 4.99.0
ERRO: Exceção sem tratamento: <b>TypeError</b>:%b requires a bytes-like object, or an object that implements __bytes__, not 'int'

calibre 4.99 Portable embedded-python: True is64bit: False
Windows-10-10.0.18362-SP0 Windows ('32bit', 'WindowsPE')
32bit process running on 64bit windows
('Windows', '10', '10.0.18362')
Python 3.8.0
Windows: ('10', '10.0.18362', 'SP0', '')
Interface language: pt_BR
Successfully initialized third party plugins: ACE (1, 1, 0) && Skoob Sync (0, 3, 0)
Traceback (most recent call last):
File "calibre_plugins.ACE.config", line 158, in get_directory
File "win_file_dialogs.py", line 238, in choose_dir
File "win_file_dialogs.py", line 161, in run_file_dialog
File "win_file_dialogs.py", line 59, in serialize_binary
TypeError: %b requires a bytes-like object, or an object that implements __bytes__, not 'int'

2) Skoob Sync had more problems. First I had a problem with encoding a password with base64 (which I ended up giving up). There were a lot of other errors about encode/decode of strings/bytes with urllib requests.
Right now, it is working partially. Some functions work, others make calibre hang. Trying to debug now...

______________________________
EDIT: Looks like the problem is on my multi-threading code. Until now (4.6), sometimes I got an error like this:
Code:
QObject::setParent: Cannot set parent, new parent is in a different thread
But it did not prevent the plugin to run. Now, every time this error shows up, calibre hangs. Apparently, python 3 is more error intolerant ....

This is my code for multi-threading:
Spoiler:
Code:
    def run_parallel_in_threads(self, target, args_list):
        ''' Utility - spawn a thread to execute target for each args '''

        result = six.moves.queue.Queue()

        # Wrapper to collect return value in a Queue
        def task_wrapper(*args):
            result.put(target(*args))

        threads = [threading.Thread(target=task_wrapper, args=args) for args in args_list]

        count = 0

        for t in threads:
            count += 1
            t.start()
            # Don't send all requests at once
            list_size = len(args_list)
            if (list_size - 20) > 10:
                if count == 20:
                    time.sleep(1)
                elif count == 30:
                    time.sleep(1)
                elif count == 40:
                    time.sleep(2)
            elif (list_size - 20) > 0:
                if count == 20:
                    time.sleep(1)
            time.sleep(0.1)
            QApplication.processEvents(QtCore.QEventLoop.ExcludeUserInputEvents)
        for t in threads:
            t.join()
        return result

Anyway... I will keep digging.

Last edited by thiago.eec; 12-17-2019 at 06:41 PM.
thiago.eec is offline   Reply With Quote