diff options
author | Lucas Hoffmann <l-m-h@web.de> | 2016-07-14 13:30:52 +0200 |
---|---|---|
committer | Lucas Hoffmann <l-m-h@web.de> | 2016-12-09 11:26:15 +0100 |
commit | d89bbe11537abfceb3d0c7b62b9325fceaf51e32 (patch) | |
tree | 7bb9697a7a2aac29da8f529cdca44ee050023dc2 /alot | |
parent | e2de9282a33a8906077a3d223d025367071bce6b (diff) |
Use logging's native string interpolation
Diffstat (limited to 'alot')
-rw-r--r-- | alot/account.py | 4 | ||||
-rw-r--r-- | alot/buffers.py | 2 | ||||
-rw-r--r-- | alot/commands/__init__.py | 6 | ||||
-rw-r--r-- | alot/commands/envelope.py | 9 | ||||
-rw-r--r-- | alot/commands/globals.py | 24 | ||||
-rw-r--r-- | alot/commands/search.py | 8 | ||||
-rw-r--r-- | alot/commands/thread.py | 18 | ||||
-rw-r--r-- | alot/completion.py | 2 | ||||
-rw-r--r-- | alot/db/envelope.py | 14 | ||||
-rw-r--r-- | alot/db/manager.py | 10 | ||||
-rw-r--r-- | alot/db/utils.py | 4 | ||||
-rw-r--r-- | alot/helper.py | 4 | ||||
-rw-r--r-- | alot/settings/manager.py | 4 | ||||
-rw-r--r-- | alot/ui.py | 19 | ||||
-rw-r--r-- | alot/widgets/thread.py | 14 |
15 files changed, 70 insertions, 72 deletions
diff --git a/alot/account.py b/alot/account.py index 017fa31e..9e83b54c 100644 --- a/alot/account.py +++ b/alot/account.py @@ -119,7 +119,7 @@ class Account(object): message_id = mbx.add(msg) mbx.flush() mbx.unlock() - logging.debug('got mailbox msg id : %s' % message_id) + logging.debug('got mailbox msg id : %s', message_id) except Exception as e: raise StoreMailError(e) @@ -132,7 +132,7 @@ class Account(object): message_id + '*') if plist: path = os.path.join(mbx._path, 'new', plist[0]) - logging.debug('path of saved msg: %s' % path) + logging.debug('path of saved msg: %s', path) return path def store_sent_mail(self, mail): diff --git a/alot/buffers.py b/alot/buffers.py index 4cb3d50a..ba782f35 100644 --- a/alot/buffers.py +++ b/alot/buffers.py @@ -445,7 +445,7 @@ class ThreadBuffer(Buffer): return self.body.get_focus() def set_focus(self, pos): - logging.debug('setting focus to %s ' % str(pos)) + logging.debug('setting focus to %s ', pos) self.body.set_focus(pos) def focus_first(self): diff --git a/alot/commands/__init__.py b/alot/commands/__init__.py index 095c068d..d19508ab 100644 --- a/alot/commands/__init__.py +++ b/alot/commands/__init__.py @@ -168,7 +168,7 @@ def commandfactory(cmdline, mode='global'): # split commandname and parameters if not cmdline: return None - logging.debug('mode:%s got commandline "%s"' % (mode, cmdline)) + logging.debug('mode:%s got commandline "%s"', mode, cmdline) # allow to shellescape without a space after '!' if cmdline.startswith('!'): cmdline = 'shellescape \'%s\'' % cmdline[1:] @@ -178,7 +178,7 @@ def commandfactory(cmdline, mode='global'): except ValueError as e: raise CommandParseError(e.message) args = map(lambda x: alot.helper.string_decode(x, 'utf-8'), args) - logging.debug('ARGS: %s' % args) + logging.debug('ARGS: %s', args) cmdname = args[0] args = args[1:] @@ -195,7 +195,7 @@ def commandfactory(cmdline, mode='global'): parms = vars(parser.parse_args(args)) parms.update(forcedparms) - logging.debug('cmd parms %s' % parms) + logging.debug('cmd parms %s', parms) # create Command cmd = cmdclass(**parms) diff --git a/alot/commands/envelope.py b/alot/commands/envelope.py index e14d2f55..712c2c76 100644 --- a/alot/commands/envelope.py +++ b/alot/commands/envelope.py @@ -56,7 +56,7 @@ class AttachCommand(Command): ui.notify('no files specified, abort') return - logging.info("attaching: %s" % files) + logging.info("attaching: %s", files) for path in files: envelope.attach(path) ui.current_buffer.rebuild() @@ -193,8 +193,7 @@ class SendCommand(Command): # don't do anything if another SendCommand is in the middle of # sending the message and we were triggered accidentally if self.envelope.sending: - msg = 'sending this message already!' - logging.debug(msg) + logging.debug('sending this message already!') return clearme = ui.notify(u'constructing mail (GPG, attachments)\u2026', @@ -314,7 +313,7 @@ class EditCommand(Command): if '*' in blacklist: blacklist = set(self.envelope.headers.keys()) edit_headers = edit_headers - blacklist - logging.info('editable headers: %s' % edit_headers) + logging.info('editable headers: %s', edit_headers) def openEnvelopeFromTmpfile(): # This parses the input from the tempfile. @@ -565,7 +564,7 @@ class EncryptCommand(Command): recipient = match.group(1) self.encrypt_keys.append(recipient) - logging.debug("encryption keys: " + str(self.encrypt_keys)) + logging.debug("encryption keys: %s", self.encrypt_keys) keys = yield get_keys(ui, self.encrypt_keys, signed_only=self.trusted) if self.trusted: diff --git a/alot/commands/globals.py b/alot/commands/globals.py index af3500ca..6e4ac673 100644 --- a/alot/commands/globals.py +++ b/alot/commands/globals.py @@ -125,7 +125,7 @@ class PromptCommand(Command): completer=cmpl, history=ui.commandprompthistory, ) - logging.debug('CMDLINE: %s' % cmdline) + logging.debug('CMDLINE: %s', cmdline) # interpret and apply commandline if cmdline: @@ -193,13 +193,13 @@ class ExternalCommand(Command): if touchhook is not None: logging.debug('calling hook: touch_external_cmdlist') res = touchhook(cmd, shell=shell, spawn=spawn, thread=thread) - logging.debug('got: %s' % res) + logging.debug('got: %s', res) cmd, shell, self.in_thread = res # otherwise if spawn requested and X11 is running elif spawn: if 'DISPLAY' in os.environ: term_cmd = settings.get('terminal_cmd', '') - logging.info('spawn in terminal: %s' % term_cmd) + logging.info('spawn in terminal: %s', term_cmd) termcmdlist = split_commandstring(term_cmd) cmd = termcmdlist + cmd else: @@ -214,7 +214,7 @@ class ExternalCommand(Command): Command.__init__(self, **kwargs) def apply(self, ui): - logging.debug('cmdlist: %s' % self.cmdlist) + logging.debug('cmdlist: %s', self.cmdlist) callerbuffer = ui.current_buffer # set standard input for subcommand @@ -236,7 +236,7 @@ class ExternalCommand(Command): logging.info('refocussing') ui.buffer_focus(callerbuffer) - logging.info('calling external command: %s' % self.cmdlist) + logging.info('calling external command: %s', self.cmdlist) def thread_code(*args): try: @@ -297,7 +297,7 @@ class EditCommand(ExternalCommand): editor_cmdstring = '/usr/bin/editor' editor_cmdstring = os.environ.get('EDITOR', editor_cmdstring) editor_cmdstring = settings.get('editor_cmd') or editor_cmdstring - logging.debug('using editor_cmd: %s' % editor_cmdstring) + logging.debug('using editor_cmd: %s', editor_cmdstring) self.cmdlist = None if '%s' in editor_cmdstring: @@ -549,8 +549,8 @@ class FlushCommand(Command): ui.mainloop.set_alarm_in(timeout, f) if not ui.db_was_locked: if not self.silent: - ui.notify( - 'index locked, will try again in %d secs' % timeout) + ui.notify('index locked, will try again in %d secs' + % timeout) ui.db_was_locked = True ui.update() return @@ -620,7 +620,7 @@ class HelpCommand(Command): ('relative', 70)) ui.show_as_root_until_keypress(overlay, 'esc') else: - logging.debug('HELP %s' % self.commandname) + logging.debug('HELP %s', self.commandname) parser = commands.lookup_parser(self.commandname, ui.mode) if parser: ui.notify(parser.format_help(), block=True) @@ -828,7 +828,7 @@ class ComposeCommand(Command): if settings.get('ask_subject') and \ 'Subject' not in self.envelope.headers: subject = yield ui.prompt('Subject') - logging.debug('SUBJECT: "%s"' % subject) + logging.debug('SUBJECT: "%s"', subject) if subject is None: raise CommandCanceled() @@ -847,7 +847,7 @@ class ComposeCommand(Command): for gpath in self.attach: for a in glob.glob(gpath): self.envelope.attach(a) - logging.debug('attaching: ' + a) + logging.debug('attaching: %s', a) # set encryption if needed if self.encrypt or account.encrypt_by_default == u"all": @@ -893,7 +893,7 @@ class ComposeCommand(Command): recipient = match.group(1) encrypt_keys.append(recipient) - logging.debug("encryption keys: " + str(encrypt_keys)) + logging.debug("encryption keys: %s", encrypt_keys) keys = yield get_keys(ui, encrypt_keys, block_error=self.encrypt, signed_only=trusted_only) if keys: diff --git a/alot/commands/search.py b/alot/commands/search.py index 0001a0bd..7a2184ae 100644 --- a/alot/commands/search.py +++ b/alot/commands/search.py @@ -33,7 +33,7 @@ class OpenThreadCommand(Command): self.thread = ui.current_buffer.get_selected_thread() if self.thread: query = ui.current_buffer.querystring - logging.info('open thread view for %s' % self.thread) + logging.info('open thread view for %s', self.thread) sb = buffers.ThreadBuffer(ui, self.thread) ui.buffer_open(sb) @@ -185,13 +185,13 @@ class TagCommand(Command): if not self.allm: testquery = "(%s) AND thread:%s" % (testquery, thread.get_thread_id()) - logging.debug('all? %s' % self.allm) - logging.debug('q: %s' % testquery) + logging.debug('all? %s', self.allm) + logging.debug('q: %s', testquery) hitcount_before = ui.dbman.count_messages(testquery) def remove_thread(): - logging.debug('remove thread from result list: %s' % thread) + logging.debug('remove thread from result list: %s', thread) if threadline_widget in searchbuffer.threadlist: # remove this thread from result list searchbuffer.threadlist.remove(threadline_widget) diff --git a/alot/commands/thread.py b/alot/commands/thread.py index 1cdd6b38..f5c6141d 100644 --- a/alot/commands/thread.py +++ b/alot/commands/thread.py @@ -70,7 +70,7 @@ def determine_sender(mail, action='reply'): break candidate_addresses = getaddresses(mail.get_all(candidate_header, [])) - logging.debug('candidate addresses: %s' % candidate_addresses) + logging.debug('candidate addresses: %s', candidate_addresses) # pick the most important account that has an address in candidates # and use that accounts realname and the address found here for account in my_accounts: @@ -99,8 +99,8 @@ def determine_sender(mail, action='reply'): account = my_accounts[0] realname = account.realname address = account.address - logging.debug('using realname: "%s"' % realname) - logging.debug('using address: %s' % address) + logging.debug('using realname: "%s"', realname) + logging.debug('using address: %s', address) from_value = address if realname == '' else '%s <%s>' % (realname, address) return from_value, account @@ -232,7 +232,7 @@ class ReplyCommand(Command): envelope.add('Cc', decode_header(cc)) to = ', '.join(recipients) - logging.debug('reply to: %s' % to) + logging.debug('reply to: %s', to) if self.listreply: # To choose the target of the reply --list @@ -244,7 +244,7 @@ class ReplyCommand(Command): # to deal with the one in sent if to is None: to = mail['To'] - logging.debug('mail list reply to: %s' % to) + logging.debug('mail list reply to: %s', to) # Cleaning the 'To' in this case if envelope.get('To') is not None: envelope.__delitem__('To') @@ -261,7 +261,7 @@ class ReplyCommand(Command): # check if any recipient address matches a known mailing list if any([addr in lists for n, addr in getaddresses(allrecipients)]): followupto = ', '.join(allrecipients) - logging.debug('mail followup to: %s' % followupto) + logging.debug('mail followup to: %s', followupto) envelope.add('Mail-Followup-To', decode_header(followupto)) # set In-Reply-To header @@ -540,7 +540,7 @@ class ChangeDisplaymodeCommand(Command): def apply(self, ui): tbuffer = ui.current_buffer - logging.debug('matching lines %s...' % (self.query)) + logging.debug('matching lines %s...', self.query) if self.query is None: messagetrees = [tbuffer.get_selected_messagetree()] else: @@ -715,7 +715,7 @@ class PipeCommand(Command): # do teh monkey for mail in pipestrings: if self.background: - logging.debug('call in background: %s' % str(self.cmd)) + logging.debug('call in background: %s', self.cmd) proc = subprocess.Popen(self.cmd, shell=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, @@ -726,7 +726,7 @@ class PipeCommand(Command): else: logging.debug('stop urwid screen') ui.mainloop.screen.stop() - logging.debug('call: %s' % str(self.cmd)) + logging.debug('call: %s', self.cmd) # if proc.stdout is defined later calls to communicate # seem to be non-blocking! proc = subprocess.Popen(self.cmd, shell=True, diff --git a/alot/completion.py b/alot/completion.py index 300592b3..d4f0cf13 100644 --- a/alot/completion.py +++ b/alot/completion.py @@ -289,7 +289,7 @@ class CommandNameCompleter(Completer): def complete(self, original, pos): # TODO refine <tab> should get current querystring commandprefix = original[:pos] - logging.debug('original="%s" prefix="%s"' % (original, commandprefix)) + logging.debug('original="%s" prefix="%s"', original, commandprefix) cmdlist = commands.COMMANDS['global'].copy() cmdlist.update(commands.COMMANDS[self.mode]) matching = [t for t in cmdlist if t.startswith(commandprefix)] diff --git a/alot/db/envelope.py b/alot/db/envelope.py index c31eef33..5de09967 100644 --- a/alot/db/envelope.py +++ b/alot/db/envelope.py @@ -64,11 +64,11 @@ class Envelope(object): :param tags: tags to add after successful sendout and saving this msg :type tags: list of str """ - logging.debug('TEMPLATE: %s' % template) + logging.debug('TEMPLATE: %s', template) if template: self.parse_template(template) - logging.debug('PARSED TEMPLATE: %s' % template) - logging.debug('BODY: %s' % self.body) + logging.debug('PARSED TEMPLATE: %s', template) + logging.debug('BODY: %s', self.body) self.body = bodytext or u'' self.headers = headers or {} self.attachments = list(attachments) @@ -185,7 +185,7 @@ class Envelope(object): if self.sign: plaintext = helper.email_as_string(inner_msg) - logging.debug('signing plaintext: ' + plaintext) + logging.debug('signing plaintext: %s', plaintext) try: signatures, signature_str = crypto.detached_signature_for( @@ -229,7 +229,7 @@ class Envelope(object): if self.encrypt: plaintext = helper.email_as_string(unencrypted_msg) - logging.debug('encrypting plaintext: ' + plaintext) + logging.debug('encrypting plaintext: %s', plaintext) try: encrypted_str = crypto.encrypt(plaintext, @@ -284,7 +284,7 @@ class Envelope(object): :param reset: remove previous envelope content :type reset: bool """ - logging.debug('GoT: """\n%s\n"""' % tmp) + logging.debug('GoT: """\n%s\n"""', tmp) if self.sent_time: self.modified_since_sent = True @@ -327,7 +327,7 @@ class Envelope(object): for line in self.get_all('Attach'): gpath = os.path.expanduser(line.strip()) to_attach += filter(os.path.isfile, glob.glob(gpath)) - logging.debug('Attaching: %s' % to_attach) + logging.debug('Attaching: %s', to_attach) for path in to_attach: self.attach(path) del self['Attach'] diff --git a/alot/db/manager.py b/alot/db/manager.py index be80b4dc..6dce8c44 100644 --- a/alot/db/manager.py +++ b/alot/db/manager.py @@ -114,7 +114,7 @@ class DBManager(object): # go through writequeue entries while self.writequeue: current_item = self.writequeue.popleft() - logging.debug('write-out item: %s' % str(current_item)) + logging.debug('write-out item: %s', str(current_item)) # watch out for notmuch errors to re-insert current_item # to the queue on errors @@ -329,7 +329,7 @@ class DBManager(object): process = FillPipeProcess(cbl(), stdout[1], stderr[1], pipe, fun) process.start() self.processes.append(process) - logging.debug('Worker process {0} spawned'.format(process.pid)) + logging.debug('Worker process %s spawned', process.pid) def threaded_wait(): # wait(2) for the process to die @@ -342,7 +342,7 @@ class DBManager(object): else: msg = 'exited successfully' - logging.debug('Worker process {0} {1}'.format(process.pid, msg)) + logging.debug('Worker process %s %s', process.pid, msg) self.processes.remove(process) # spawn a thread to collect the worker process once it dies @@ -352,8 +352,8 @@ class DBManager(object): def threaded_reader(prefix, fd): with os.fdopen(fd) as handle: for line in handle: - logging.debug('Worker process {0} said on {1}: {2}'.format( - process.pid, prefix, line.rstrip())) + logging.debug('Worker process %s said on %s: %s', + process.pid, prefix, line.rstrip()) # spawn two threads that read from the stdout and stderr pipes # and write anything that appears there to the log diff --git a/alot/db/utils.py b/alot/db/utils.py index 664aca5d..eb5d4d2d 100644 --- a/alot/db/utils.py +++ b/alot/db/utils.py @@ -329,8 +329,8 @@ def extract_body(mail, types=None, field_key='copiousoutput'): # create and call external command cmd = mailcap.subst(entry['view'], ctype, filename=tempfile_name, plist=parms) - logging.debug('command: %s' % cmd) - logging.debug('parms: %s' % str(parms)) + logging.debug('command: %s', cmd) + logging.debug('parms: %s', str(parms)) cmdlist = split_commandstring(cmd) # call handler rendered_payload, errmsg, retval = helper.call_cmd( diff --git a/alot/helper.py b/alot/helper.py index de57b564..1d114187 100644 --- a/alot/helper.py +++ b/alot/helper.py @@ -359,8 +359,8 @@ def call_cmd_async(cmdlist, stdin=None, env=None): environment = os.environ if env is not None: environment.update(env) - logging.debug('ENV = %s' % environment) - logging.debug('CMD = %s' % cmdlist) + logging.debug('ENV = %s', environment) + logging.debug('CMD = %s', cmdlist) proc = reactor.spawnProcess(_EverythingGetter(d), executable=cmdlist[0], env=environment, args=cmdlist) diff --git a/alot/settings/manager.py b/alot/settings/manager.py index 1d6ad913..bd810514 100644 --- a/alot/settings/manager.py +++ b/alot/settings/manager.py @@ -70,7 +70,7 @@ class SettingsManager(object): try: self.hooks = imp.load_source('hooks', hooks_path) except: - logging.debug('unable to load hooks file:%s' % hooks_path) + logging.debug('unable to load hooks file:%s', hooks_path) if 'bindings' in newconfig: newbindings = newconfig['bindings'] if isinstance(newbindings, Section): @@ -123,7 +123,7 @@ class SettingsManager(object): # create abook for this account abook = accsec['abook'] - logging.debug('abook defined: %s' % abook) + logging.debug('abook defined: %s', abook) if abook['type'] == 'shellcommand': cmd = abook['command'] regexp = abook['regexp'] @@ -82,7 +82,7 @@ class UI(object): # set up colours colourmode = int(settings.get('colourmode')) - logging.info('setup gui in %d colours' % colourmode) + logging.info('setup gui in %d colours', colourmode) self.mainloop.screen.set_terminal_properties(colors=colourmode) logging.debug('fire first command') @@ -99,7 +99,7 @@ class UI(object): to let the root widget handle keys. We intercept the input here to trigger custom commands as defined in our keybindings. """ - logging.debug("Got key (%s, %s)" % (keys, raw)) + logging.debug("Got key (%s, %s)", keys, raw) # work around: escape triggers this twice, with keys = raw = [] # the first time.. if not keys: @@ -124,7 +124,7 @@ class UI(object): def fire(ignored, cmdline): clear() - logging.debug("cmdline: '%s'" % cmdline) + logging.debug("cmdline: '%s'", cmdline) if not self._locked: try: self.apply_commandline(cmdline) @@ -190,8 +190,7 @@ class UI(object): # of the next callback (and thus Command-application) def apply_this_command(ignored, cmdstring): - logging.debug('%s command string: "%s"' % (self.mode, - str(cmdstring))) + logging.debug('%s command string: "%s"', self.mode, str(cmdstring)) # translate cmdstring into :class:`Command` cmd = commandfactory(cmdstring, self.mode) # store cmdline for use with 'repeat' command @@ -228,7 +227,7 @@ class UI(object): widget by `self._input_filter` but is not handled in any widget. We keep it for debuging purposes. """ - logging.debug('unhandled input: %s' % key) + logging.debug('unhandled input: %s', key) def show_as_root_until_keypress(self, w, key, afterwards=None): """ @@ -317,7 +316,7 @@ class UI(object): reactor.stop() except Exception as e: exit_msg = 'Could not stop reactor: {}.'.format(e) - logging.error(exit_msg + '\nShutting down anyway..') + logging.error('%s\nShutting down anyway..', exit_msg) def buffer_open(self, buf): """register and focus new :class:`~alot.buffers.Buffer`.""" @@ -355,10 +354,10 @@ class UI(object): buffers = self.buffers success = False if buf not in buffers: - string = 'tried to close unknown buffer: %s. \n\ni have:%s' - logging.error(string % (buf, self.buffers)) + logging.error('tried to close unknown buffer: %s. \n\ni have:%s', + buf, self.buffers) elif self.current_buffer == buf: - logging.info('closing current buffer %s' % buf) + logging.info('closing current buffer %s', buf) index = buffers.index(buf) buffers.remove(buf) offset = settings.get('bufferclose_focus_offset') diff --git a/alot/widgets/thread.py b/alot/widgets/thread.py index e0d739b8..44424992 100644 --- a/alot/widgets/thread.py +++ b/alot/widgets/thread.py @@ -180,13 +180,13 @@ class MessageTree(CollapsibleTree): self.reassemble() def debug(self): - logging.debug('collapsed %s' % self.is_collapsed(self.root)) - logging.debug('display_source %s' % self.display_source) - logging.debug('display_all_headers %s' % self.display_all_headers) - logging.debug('display_attachements %s' % self.display_attachments) - logging.debug('AHT %s' % str(self._all_headers_tree)) - logging.debug('DHT %s' % str(self._default_headers_tree)) - logging.debug('MAINTREE %s' % str(self._maintree._treelist)) + logging.debug('collapsed %s', self.is_collapsed(self.root)) + logging.debug('display_source %s', self.display_source) + logging.debug('display_all_headers %s', self.display_all_headers) + logging.debug('display_attachements %s', self.display_attachments) + logging.debug('AHT %s', str(self._all_headers_tree)) + logging.debug('DHT %s', str(self._default_headers_tree)) + logging.debug('MAINTREE %s', str(self._maintree._treelist)) def _assemble_structure(self): mainstruct = [] |