add the repository name when connecting
Otherwise, it might be impossible to know which account is connecting when more than one is syncing. Code style. Signed-off-by: Nicolas Sebrecht <nicolas.s-dev@laposte.net>
This commit is contained in:
		| @@ -342,7 +342,8 @@ class SyncableAccount(Account): | |||||||
|             # Iterate through all folders on the remote repo and sync. |             # Iterate through all folders on the remote repo and sync. | ||||||
|             for remotefolder in remoterepos.getfolders(): |             for remotefolder in remoterepos.getfolders(): | ||||||
|                 # Check for CTRL-C or SIGTERM. |                 # Check for CTRL-C or SIGTERM. | ||||||
|                 if Account.abort_NOW_signal.is_set(): break |                 if Account.abort_NOW_signal.is_set(): | ||||||
|  |                     break | ||||||
|  |  | ||||||
|                 if not remotefolder.sync_this: |                 if not remotefolder.sync_this: | ||||||
|                     self.ui.debug('', "Not syncing filtered folder '%s'" |                     self.ui.debug('', "Not syncing filtered folder '%s'" | ||||||
| @@ -605,7 +606,7 @@ def syncfolder(account, remotefolder, quick): | |||||||
|             ui.error(e, exc_info()[2], msg="Aborting sync, folder '%s' " |             ui.error(e, exc_info()[2], msg="Aborting sync, folder '%s' " | ||||||
|                      "[acc: '%s']"% (localfolder, account)) |                      "[acc: '%s']"% (localfolder, account)) | ||||||
|     except Exception as e: |     except Exception as e: | ||||||
|         ui.error(e, msg = "ERROR in syncfolder for %s folder %s: %s"% |         ui.error(e, msg="ERROR in syncfolder for %s folder %s: %s"% | ||||||
|             (account, remotefolder.getvisiblename(), traceback.format_exc())) |             (account, remotefolder.getvisiblename(), traceback.format_exc())) | ||||||
|     finally: |     finally: | ||||||
|         for folder in ["statusfolder", "localfolder", "remotefolder"]: |         for folder in ["statusfolder", "localfolder", "remotefolder"]: | ||||||
|   | |||||||
| @@ -484,7 +484,8 @@ class IMAPServer(object): | |||||||
|             while success is not True: |             while success is not True: | ||||||
|                 # Generate a new connection. |                 # Generate a new connection. | ||||||
|                 if self.tunnel: |                 if self.tunnel: | ||||||
|                     self.ui.connecting('tunnel', self.tunnel) |                     self.ui.connecting( | ||||||
|  |                         self.repos.getname(), 'tunnel', self.tunnel) | ||||||
|                     imapobj = imaplibutil.IMAP4_Tunnel( |                     imapobj = imaplibutil.IMAP4_Tunnel( | ||||||
|                         self.tunnel, |                         self.tunnel, | ||||||
|                         timeout=socket.getdefaulttimeout(), |                         timeout=socket.getdefaulttimeout(), | ||||||
| @@ -492,7 +493,8 @@ class IMAPServer(object): | |||||||
|                         ) |                         ) | ||||||
|                     success = True |                     success = True | ||||||
|                 elif self.usessl: |                 elif self.usessl: | ||||||
|                     self.ui.connecting(self.hostname, self.port) |                     self.ui.connecting( | ||||||
|  |                         self.repos.getname(), self.hostname, self.port) | ||||||
|                     imapobj = imaplibutil.WrappedIMAP4_SSL( |                     imapobj = imaplibutil.WrappedIMAP4_SSL( | ||||||
|                         host=self.hostname, |                         host=self.hostname, | ||||||
|                         port=self.port, |                         port=self.port, | ||||||
| @@ -508,7 +510,8 @@ class IMAPServer(object): | |||||||
|                         af=self.af, |                         af=self.af, | ||||||
|                         ) |                         ) | ||||||
|                 else: |                 else: | ||||||
|                     self.ui.connecting(self.hostname, self.port) |                     self.ui.connecting( | ||||||
|  |                         self.repos.getname(), self.hostname, self.port) | ||||||
|                     imapobj = imaplibutil.WrappedIMAP4( |                     imapobj = imaplibutil.WrappedIMAP4( | ||||||
|                         self.hostname, self.port, |                         self.hostname, self.port, | ||||||
|                         timeout=socket.getdefaulttimeout(), |                         timeout=socket.getdefaulttimeout(), | ||||||
|   | |||||||
| @@ -25,15 +25,16 @@ from threading import currentThread | |||||||
| import offlineimap | import offlineimap | ||||||
| from offlineimap.ui.UIBase import UIBase | from offlineimap.ui.UIBase import UIBase | ||||||
|  |  | ||||||
| protocol = '7.1.0' | protocol = '7.2.0' | ||||||
|  |  | ||||||
| class MachineLogFormatter(logging.Formatter): | class MachineLogFormatter(logging.Formatter): | ||||||
|     """urlencodes any outputted line, to avoid multi-line output""" |     """urlencodes any outputted line, to avoid multi-line output""" | ||||||
|  |  | ||||||
|     def format(s, record): |     def format(s, record): | ||||||
|         # Mapping of log levels to historic tag names |         # Mapping of log levels to historic tag names | ||||||
|         severity_map = { |         severity_map = { | ||||||
|          'info': 'msg', |             'info': 'msg', | ||||||
|          'warning': 'warn', |             'warning': 'warn', | ||||||
|         } |         } | ||||||
|         line = super(MachineLogFormatter, s).format(record) |         line = super(MachineLogFormatter, s).format(record) | ||||||
|         severity = record.levelname.lower() |         severity = record.levelname.lower() | ||||||
| @@ -101,8 +102,9 @@ class MachineUI(UIBase): | |||||||
|                 (folder.getname(), folder.getrepository().getname(), |                 (folder.getname(), folder.getrepository().getname(), | ||||||
|                  folder.get_saveduidvalidity(), folder.get_uidvalidity())) |                  folder.get_saveduidvalidity(), folder.get_uidvalidity())) | ||||||
|  |  | ||||||
|     def connecting(s, hostname, port): |     def connecting(s, reposname, hostname, port): | ||||||
|         s._printData(s.logger.info, 'connecting', "%s\n%s"% (hostname, str(port))) |         s._printData(s.logger.info, 'connecting', "%s\n%s\nMs"% (hostname, | ||||||
|  |             str(port), reposname)) | ||||||
|  |  | ||||||
|     def syncfolders(s, srcrepos, destrepos): |     def syncfolders(s, srcrepos, destrepos): | ||||||
|         s._printData(s.logger.info, 'syncfolders', "%s\n%s"% (s.getnicename(srcrepos), |         s._printData(s.logger.info, 'syncfolders', "%s\n%s"% (s.getnicename(srcrepos), | ||||||
|   | |||||||
| @@ -19,9 +19,11 @@ import logging | |||||||
| import sys | import sys | ||||||
| import time | import time | ||||||
| from getpass import getpass | from getpass import getpass | ||||||
|  |  | ||||||
| from offlineimap import banner | from offlineimap import banner | ||||||
| from offlineimap.ui.UIBase import UIBase | from offlineimap.ui.UIBase import UIBase | ||||||
|  |  | ||||||
|  |  | ||||||
| class TTYFormatter(logging.Formatter): | class TTYFormatter(logging.Formatter): | ||||||
|     """Specific Formatter that adds thread information to the log output.""" |     """Specific Formatter that adds thread information to the log output.""" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -161,9 +161,9 @@ class UIBase(object): | |||||||
|                "repo %s") |                "repo %s") | ||||||
|         """ |         """ | ||||||
|         if msg: |         if msg: | ||||||
|             self.logger.error("ERROR: %s\n  %s" % (msg, exc)) |             self.logger.error("ERROR: %s\n  %s"% (msg, exc)) | ||||||
|         else: |         else: | ||||||
|             self.logger.error("ERROR: %s" % (exc)) |             self.logger.error("ERROR: %s"% (exc)) | ||||||
|  |  | ||||||
|         instant_traceback = exc_traceback |         instant_traceback = exc_traceback | ||||||
|         if not self.debuglist: |         if not self.debuglist: | ||||||
| @@ -181,8 +181,8 @@ class UIBase(object): | |||||||
|         if cur_thread in self.threadaccounts: |         if cur_thread in self.threadaccounts: | ||||||
|             # was already associated with an old account, update info |             # was already associated with an old account, update info | ||||||
|             self.debug('thread', "Register thread '%s' (previously '%s', now " |             self.debug('thread', "Register thread '%s' (previously '%s', now " | ||||||
|                     "'%s')" % (cur_thread.getName(), |                     "'%s')"% (cur_thread.getName(), | ||||||
|                                self.getthreadaccount(cur_thread), account)) |                               self.getthreadaccount(cur_thread), account)) | ||||||
|         else: |         else: | ||||||
|             self.debug('thread', "Register new thread '%s' (account '%s')"% |             self.debug('thread', "Register new thread '%s' (account '%s')"% | ||||||
|                 (cur_thread.getName(), account)) |                 (cur_thread.getName(), account)) | ||||||
| @@ -193,7 +193,7 @@ class UIBase(object): | |||||||
|  |  | ||||||
|         if thr in self.threadaccounts: |         if thr in self.threadaccounts: | ||||||
|             del self.threadaccounts[thr] |             del self.threadaccounts[thr] | ||||||
|         self.debug('thread', "Unregister thread '%s'" % thr.getName()) |         self.debug('thread', "Unregister thread '%s'"% thr.getName()) | ||||||
|  |  | ||||||
|     def getthreadaccount(self, thr=None): |     def getthreadaccount(self, thr=None): | ||||||
|         """Get Account() for a thread (current if None) |         """Get Account() for a thread (current if None) | ||||||
| @@ -311,7 +311,7 @@ class UIBase(object): | |||||||
|         create the application window here.""" |         create the application window here.""" | ||||||
|         pass |         pass | ||||||
|  |  | ||||||
|     def connecting(self, hostname, port): |     def connecting(self, reposname, hostname, port): | ||||||
|         """Log 'Establishing connection to'.""" |         """Log 'Establishing connection to'.""" | ||||||
|  |  | ||||||
|         if not self.logger.isEnabledFor(logging.INFO): return |         if not self.logger.isEnabledFor(logging.INFO): return | ||||||
| @@ -320,13 +320,14 @@ class UIBase(object): | |||||||
|         port = "%s"% port if port else '' |         port = "%s"% port if port else '' | ||||||
|         if hostname: |         if hostname: | ||||||
|             displaystr = ' to %s:%s' % (hostname, port) |             displaystr = ' to %s:%s' % (hostname, port) | ||||||
|         self.logger.info("Establishing connection%s" % displaystr) |         self.logger.info("Establishing connection%s (%s)"% | ||||||
|  |             (displaystr, reposname)) | ||||||
|  |  | ||||||
|     def acct(self, account): |     def acct(self, account): | ||||||
|         """Output that we start syncing an account (and start counting).""" |         """Output that we start syncing an account (and start counting).""" | ||||||
|  |  | ||||||
|         self.acct_startimes[account] = time.time() |         self.acct_startimes[account] = time.time() | ||||||
|         self.logger.info("*** Processing account %s" % account) |         self.logger.info("*** Processing account %s"% account) | ||||||
|  |  | ||||||
|     def acctdone(self, account): |     def acctdone(self, account): | ||||||
|         """Output that we finished syncing an account (in which time).""" |         """Output that we finished syncing an account (in which time).""" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Nicolas Sebrecht
					Nicolas Sebrecht