Output progress indication when copying files

Output (2 of 500) when logging message copying. This required moving of
self.ui.copyingmessage into a different function where we actually have
the information about the progress handy.

Signed-off-by: Sebastian Spaeth <Sebastian@SSpaeth.de>
This commit is contained in:
Sebastian Spaeth 2011-09-29 16:51:48 +02:00
parent 642880b404
commit eb0b546927
5 changed files with 13 additions and 17 deletions

View File

@ -266,7 +266,6 @@ class BaseFolder(object):
statusfolder.savemessage(uid, None, flags, rtime) statusfolder.savemessage(uid, None, flags, rtime)
return return
self.ui.copyingmessage(uid, self, dstfolder)
# If any of the destinations actually stores the message body, # If any of the destinations actually stores the message body,
# load it up. # load it up.
if dstfolder.storesmessages(): if dstfolder.storesmessages():
@ -331,15 +330,16 @@ class BaseFolder(object):
copylist = filter(lambda uid: not \ copylist = filter(lambda uid: not \
statusfolder.uidexists(uid), statusfolder.uidexists(uid),
self.getmessageuidlist()) self.getmessageuidlist())
for uid in copylist: num_to_copy = len(copylist)
for num, uid in enumerate(copylist):
self.ui.copyingmessage(uid, num+1, num_to_copy, self, dstfolder)
# exceptions are caught in copymessageto() # exceptions are caught in copymessageto()
if self.suggeststhreads(): if self.suggeststhreads():
self.waitforthread() self.waitforthread()
thread = threadutil.InstanceLimitedThread(\ thread = threadutil.InstanceLimitedThread(\
self.getcopyinstancelimit(), self.getcopyinstancelimit(),
target = self.copymessageto, target = self.copymessageto,
name = "Copy message %d from %s" % (uid, name = "Copy message from %s:%s" % (self.repository, self),
self.getvisiblename()),
args = (uid, dstfolder, statusfolder)) args = (uid, dstfolder, statusfolder))
thread.setDaemon(1) thread.setDaemon(1)
thread.start() thread.start()

View File

@ -54,9 +54,10 @@ class BlinkenBase:
s.gettf().setcolor('blue') s.gettf().setcolor('blue')
s.__class__.__bases__[-1].syncingmessages(s, sr, sf, dr, df) s.__class__.__bases__[-1].syncingmessages(s, sr, sf, dr, df)
def copyingmessage(s, uid, src, destfolder): def copyingmessage(s, uid, num, num_to_copy, src, destfolder):
s.gettf().setcolor('orange') s.gettf().setcolor('orange')
s.__class__.__bases__[-1].copyingmessage(s, uid, src, destfolder) s.__class__.__bases__[-1].copyingmessage(s, uid, num, num_to_copy, src,
destfolder)
def deletingmessages(s, uidlist, destlist): def deletingmessages(s, uidlist, destlist):
s.gettf().setcolor('red') s.gettf().setcolor('red')

View File

@ -108,7 +108,7 @@ class MachineUI(UIBase):
(s.getnicename(sr), sf.getname(), s.getnicename(dr), (s.getnicename(sr), sf.getname(), s.getnicename(dr),
df.getname())) df.getname()))
def copyingmessage(self, uid, srcfolder, destfolder): def copyingmessage(self, uid, num, num_to_copy, srcfolder, destfolder):
self._printData('copyingmessage', "%d\n%s\n%s\n%s[%s]" % \ self._printData('copyingmessage', "%d\n%s\n%s\n%s[%s]" % \
(uid, self.getnicename(srcfolder), srcfolder.getname(), (uid, self.getnicename(srcfolder), srcfolder.getname(),
self.getnicename(destfolder), destfolder)) self.getnicename(destfolder), destfolder))

View File

@ -15,7 +15,6 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
from UIBase import UIBase from UIBase import UIBase
from getpass import getpass from getpass import getpass
import sys import sys
@ -37,9 +36,6 @@ class TTYUI(UIBase):
#if the next output comes from a different thread than our last one #if the next output comes from a different thread than our last one
#add the info. #add the info.
#Most look like 'account sync foo' or 'Folder sync foo'. #Most look like 'account sync foo' or 'Folder sync foo'.
try:
threadname = currentThread().name
except AttributeError:
threadname = currentThread().getName() threadname = currentThread().getName()
if (threadname == s._lastThreaddisplay \ if (threadname == s._lastThreaddisplay \
or threadname == 'MainThread'): or threadname == 'MainThread'):

View File

@ -288,12 +288,11 @@ class UIBase:
s.getnicename(dr), s.getnicename(dr),
df.getname())) df.getname()))
def copyingmessage(self, uid, src, destfolder): def copyingmessage(self, uid, num, num_to_copy, src, destfolder):
"""Output a log line stating which message we copy""" """Output a log line stating which message we copy"""
if self.verbose >= 0: if self.verbose < 0: return
self._msg("Copy message %d %s[%s] -> %s[%s]" % \ self._msg("Copy message %s (%d of %d) %s:%s -> %s" % (uid, num,
(uid, self.getnicename(src), src, num_to_copy, src.repository, src, destfolder.repository))
self.getnicename(destfolder), destfolder))
def deletingmessage(s, uid, destlist): def deletingmessage(s, uid, destlist):
if s.verbose >= 0: if s.verbose >= 0: