]> git.parisson.com Git - telemeta-data.git/commitdiff
fix migrator output when lines are longer than the term width
authorolivier <olivier@3bf09e05-f825-4182-b9bc-eedd7160adf0>
Wed, 10 Feb 2010 12:57:49 +0000 (12:57 +0000)
committerolivier <olivier@3bf09e05-f825-4182-b9bc-eedd7160adf0>
Wed, 10 Feb 2010 12:57:49 +0000 (12:57 +0000)
git-svn-id: http://svn.parisson.org/svn/crem@150 3bf09e05-f825-4182-b9bc-eedd7160adf0

trunk/import/migration/tasks/core.py

index 521d4860b20f1a490533f899ebc49780c03b6354..b138d2a67ac0b0ca9a16309cb52aeb8fb6d7cfef 100644 (file)
@@ -235,7 +235,9 @@ class Logger(object):
     CBLUE     = CESC + "34m"
     CCYAN     = CESC + "36m"
     CDEFAULT  = CESC + "0m"
-    CRESET    = CDEFAULT + CCURSOR
+    CWRAP     = CESC + "?7h"
+    CNOWRAP   = CESC + "?7l"
+    CRESET    = CDEFAULT + CCURSOR + CWRAP
     CUP       = CESC + "1A" 
     CREVERSENL= "\r" + CUP
 
@@ -294,6 +296,7 @@ class Logger(object):
         for i in range(r, barwidth):
             p += ' '
 
+        stdout.write(self.CNOWRAP)
         self.color1("\r" + msg)
         self.color1(" [%s] %d%%" % (p, ratio * 100))
         if end:
@@ -312,28 +315,10 @@ class Logger(object):
             if stats:
                 stdout.write(self.CREVERSENL)
 
+        stdout.write(self.CWRAP)
         sys.stdout.flush()
         self.need_newline = True
         
-    def _print_progress(self, ratio, end = False):
-        self.color3("\r[%d%%]" % (ratio * 100))
-        #if end:
-        #    self.color2(" (%.2fs)" % (time.time() - self.start_time))
-            
-        #self.color("\n%s" % self.task.__doc__)
-        #self.color3(" warnings: %d" % len(self.warnings))
-        stats = self.task.get_stats()
-        if len(self.warnings):
-            stats['warnings'] = len(self.warnings)
-        if stats:    
-            stdout.write(" %s" % self.fmt_stats(stats))
-
-        if end:
-            stdout.write("\n")
-        sys.stdout.flush()
-        self.need_newline = True
-        
-
     def start(self, task, count = 1):
         self.start_time = time.time()
         self.task   = task
@@ -390,7 +375,6 @@ class Logger(object):
     def interrupt(self):
         self.color3("Interrupted\n")
         stdout.write(self.CRESET)
-        
 
     def terminate(self):
         self.color3(self.sep + "\n")