← Back to team overview

duplicity-team team mailing list archive

[Merge] lp:~ed.so/duplicity/debian.paramiko.log into lp:duplicity

 

edso has proposed merging lp:~ed.so/duplicity/debian.paramiko.log into lp:duplicity.

Requested reviews:
  duplicity-team (duplicity-team)

For more details, see:
https://code.launchpad.net/~ed.so/duplicity/debian.paramiko.log/+merge/200134

tested and working
-- 
https://code.launchpad.net/~ed.so/duplicity/debian.paramiko.log/+merge/200134
Your team duplicity-team is requested to review the proposed merge of lp:~ed.so/duplicity/debian.paramiko.log into lp:duplicity.
=== modified file 'duplicity/backends/_ssh_paramiko.py'
--- duplicity/backends/_ssh_paramiko.py	2013-04-27 13:52:49 +0000
+++ duplicity/backends/_ssh_paramiko.py	2013-12-28 16:44:06 +0000
@@ -30,6 +30,7 @@
 import sys
 import time
 import getpass
+import logging
 from binascii import hexlify
 
 import duplicity.backend
@@ -104,6 +105,30 @@
 
         self.client = paramiko.SSHClient()
         self.client.set_missing_host_key_policy(AgreedAddPolicy())
+        
+        # paramiko uses logging with the normal python severity levels,
+        # but duplicity uses both custom levels and inverted logic...*sigh*
+        self.client.set_log_channel("sshbackend")
+        ours=paramiko.util.get_logger("sshbackend")
+        dest=logging.StreamHandler(sys.stderr)
+        dest.setFormatter(logging.Formatter('ssh: %(message)s'))
+        ours.addHandler(dest)
+
+        # ..and the duplicity levels are neither linear, 
+        # nor are the names compatible with python logging, eg. 'NOTICE'...WAAAAAH!
+        plevel=logging.getLogger("duplicity").getEffectiveLevel()
+        if plevel <= 1:
+            wanted=logging.DEBUG
+        elif plevel <= 5:
+            wanted=logging.INFO
+        elif plevel <= 7:
+            wanted=logging.WARNING
+        elif plevel <= 9:
+            wanted=logging.ERROR
+        else:
+            wanted=logging.CRITICAL
+        ours.setLevel(wanted)
+        
         # load known_hosts files
         # paramiko is very picky wrt format and bails out on any problem...
         try:


Follow ups