A new UI: Noninteractive.Summary [patch]
[Top] [All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
I've been using offlineimap a fair bit, and I found that I wanted
a UI that was less verbose than Noninteractive.Basic or TTY.TTYUI
(I have a lot of folders, so I would get many screens of chatter about
each message that was being updated, and the couple of lines of warnings
or errors were lost forever) but more verbose than Noninteractive.Quiet
(I do like seeing a summary of what's going on).
Really, what I wanted was something like a one line summary per folder,
plus any errors postponed until the end to be sure I see them. (I seem
to hit the UID validity problem quite often, which requires manually
removing local files and folders, so if I don't see the error messages,
I'll go offline without realizing until too late that I have some
folders that didn't get synchronized.)
So anyway, I derived a new UI, called Noninteractive.Summary. It didn't
seem like there was any way to collect the actual messages as python
objects -- by the time they get to the UI they've already been turned
into strings. So I wrote some lines to do some simple parsing of some
of the most common strings. It's not complete (I'm sure I'll be
tweaking it a bit more), but it handles a lot of the cases I encounter;
maybe others will find it useful too. The patch to Noninteractive.py is
attached; and it also needs to be added to detector.py in order to be
able to use it from .offlineimaprc.
...Akkana
-- Attached file included as plaintext by Ecartis --
7c7,8
< # the Free Software Foundation; version 2 of the License.
---
> # the Free Software Foundation; either version 2 of the License, or
> # (at your option) any later version.
18c19
< import sys, time
---
> import sys, time, string
43a45,90
>
> # Summary collects statistics, and saves errors until the end
> class Summary(Basic):
> def __init__(s, config, verbose = 0):
> Basic.__init__(s, config, verbose)
> s.errlist = ""
> s.newmessages = 0
> s.deleted = 0
> s.flagschanged = 0
>
> def _msg(s, msg):
> # "Syncing" line starts new mailbox
> if string.find(msg, "Syncing ") == 0 :
> print
> print msg, ":",
> # Only one "Deleting" line per mailbox, have to parse:
> elif string.find(msg, "Deleting ") == 0 :
> print "-",
> space = string.find(msg, " ", 9)
> s.deleted = s.deleted + int(msg[9:space])
> # We get one "Copy" line for each new message:
> elif string.find(msg, "Copy message ") == 0 :
> print "+",
> s.newmessages = s.newmessages + 1
> # Flags -- message went from new to read, or something.
> # Could ignore these.
> elif string.find(msg, "Adding flags ") == 0 :
> s.flagschanged = s.flagschanged + 1
> # The end -- print collected stats.
> elif string.find(msg, "Finished processing account") >= 0 :
> print "\n"
> print s.newmessages, "new messages,", s.deleted, "deleted."
> print s.flagschanged, "message flags changed."
> if s.errlist != "" :
> print "\nERRORS AND WARNINGS:"
> print s.errlist
> s.errlist = ""
> else :
> print
> print msg
> sys.stdout.flush()
>
> def warn(s, msg, minor = 0):
> #print
> #Basic.warn(s, msg, minor)
> s.errlist = s.errlist + msg + "\n"
- A new UI: Noninteractive.Summary [patch],
Akkana Peck <=
|
|