← Back to team overview

duplicity-team team mailing list archive

[Merge] lp:~mterry/duplicity/encode-for-print into lp:duplicity

 

Michael Terry has proposed merging lp:~mterry/duplicity/encode-for-print into lp:duplicity.

Requested reviews:
  duplicity-team (duplicity-team)
Related bugs:
  Bug #1286845 in Duplicity: "Duplicity crashes with UnicodeEncode error"
  https://bugs.launchpad.net/duplicity/+bug/1286845

For more details, see:
https://code.launchpad.net/~mterry/duplicity/encode-for-print/+merge/214825

Encode translated strings before passing them to 'print'.

The print command can only apparently handle bytes.  So when we pass it unicode, it freaks out.  There were only four instances I saw where we used print, so I figured it was easiest to just convert them to use the log framework too.

That way all user-visible strings go through that framework and are subject to the same encoding rules.
-- 
https://code.launchpad.net/~mterry/duplicity/encode-for-print/+merge/214825
Your team duplicity-team is requested to review the proposed merge of lp:~mterry/duplicity/encode-for-print into lp:duplicity.
=== modified file 'bin/duplicity'
--- bin/duplicity	2014-03-10 14:17:08 +0000
+++ bin/duplicity	2014-04-08 19:12:59 +0000
@@ -179,12 +179,12 @@
                 pass2 = getpass_safe(_("Retype passphrase to confirm: "))
 
             if not pass1 == pass2:
-                print _("First and second passphrases do not match!  Please try again.")
+                log.Log(_("First and second passphrases do not match!  Please try again."), log.WARNING, force_print=True)
                 use_cache = False
                 continue
 
             if not pass1 and not (globals.gpg_profile.recipients or globals.gpg_profile.hidden_recipients) and not for_signing:
-                print _("Cannot use empty passphrase with symmetric encryption!  Please try again.")
+                log.Log(_("Cannot use empty passphrase with symmetric encryption!  Please try again."), log.WARNING, force_print=True)
                 use_cache = False
                 continue
 
@@ -591,7 +591,8 @@
     """
     if globals.print_statistics:
         diffdir.stats.TotalDestinationSizeChange = bytes_written
-        print diffdir.stats.get_stats_logstring(_("Backup Statistics"))
+        logstring = diffdir.stats.get_stats_logstring(_("Backup Statistics"))
+        log.Log(logstring, log.NOTICE, force_print=True)
 
 
 def incremental_backup(sig_chain):

=== modified file 'duplicity/commandline.py'
--- duplicity/commandline.py	2014-03-09 20:37:24 +0000
+++ duplicity/commandline.py	2014-04-08 19:12:59 +0000
@@ -65,9 +65,10 @@
             ]
 
 def old_fn_deprecation(opt):
-    print >> sys.stderr, _("Warning: Option %s is pending deprecation "
-                          "and will be removed in a future release.\n"
-                          "Use of default filenames is strongly suggested.") % opt
+    log.Log(_("Warning: Option %s is pending deprecation "
+              "and will be removed in a future release.\n"
+              "Use of default filenames is strongly suggested.") % opt,
+            log.ERROR, force_print=True)
 
 def expand_fn(filename):
     return os.path.expanduser(os.path.expandvars(filename))


Follow ups