Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

logging issue #439

Open
CamielBouchier opened this issue Apr 16, 2021 · 0 comments
Open

logging issue #439

CamielBouchier opened this issue Apr 16, 2021 · 0 comments
Assignees
Labels
Milestone

Comments

@CamielBouchier
Copy link

Hi there, thanks for a great lib!

When starting to play with it I encountered an issue: when intentionally introducing an error (here absence of starttls on an account that needs it), he logging of your module flips. Generating long and iterated logs about logging errors, such as:

TypeError: not all arguments converted during string formatting
Call stack:
  File "cb_mail.py", line 333, in <module>
    rv = QApplication.instance().exec_()
  File "cb_mail.py", line 259, in cb_on_account_login
    self.an_account.cb_login()
  File "D:\Software_MyDevelopment\Active\cb_mail\cb_account.py", line 162, in cb_login
    login_function()
  File "D:\Software_MyDevelopment\Active\cb_mail\cb_account.py", line 159, in login_function
    self.settings["password"])
  File "C:\Python37\lib\site-packages\imapclient\imapclient.py", line 379, in login
    unpack=True,
  File "C:\Python37\lib\site-packages\imapclient\imapclient.py", line 1707, in _command_and_check
    typ, data = meth(*args)
  File "C:\Python37\lib\imaplib.py", line 596, in login
    typ, dat = self._simple_command('LOGIN', user, self._quote(password))
  File "C:\Python37\lib\imaplib.py", line 1196, in _simple_command
    return self._command_complete(name, self._command(name, *args))
  File "C:\Python37\lib\imaplib.py", line 1019, in _command_complete
    typ, data = self._get_tagged_response(tag)
  File "C:\Python37\lib\imaplib.py", line 1143, in _get_tagged_response
    self.print_log()
  File "C:\Python37\lib\imaplib.py", line 1240, in print_log
    self._mesg(*self._cmd_log[i])

I don't think it matters, but this was the code:

def cb_login(self) :

        logger.info(f"cb_account.cb_login")

        def login_function() :

            self.server = IMAPClient(host    = self.settings["imap_server"],
                                     port    = self.settings["imap_port"],
                                     use_uid = True,
                                     ssl     = self.settings["imap_ssl"],
                                     timeout = self.settings["timeout"])

            #if self.settings["imap_starttls"] :
            #    rv = self.server.starttls()
            #    logger.info(f"{self.account_identifier} {rv}")

            rv = self.server.login(self.settings["username"],
                                   self.settings["password"])
            logger.info(f"{self.account_identifier} {rv}")

        login_function()
        #worker = cb_account_worker(login_function)
        #worker.signals.signal_error.connect(self.cb_on_login_error)
        #worker.signals.signal_result.connect(self.cb_on_login_completed)
        #self.threadpool.start(worker)

My current workaround is selectively disabling logging:

imapclient_log = logging.getLogger("imapclient")
imapclient_log.setLevel(logging.INFO)

You might want to review,

Camiel B.

@mjs mjs added the bug label Apr 19, 2021
@mjs mjs self-assigned this Jul 9, 2022
@mjs mjs added this to the 3.0.0 milestone Jul 9, 2022
@mjs mjs modified the milestones: 3.0.0, 3.1.0 Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants