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

Proposed by edso
Status: Merged
Merged at revision: 942
Proposed branch: lp:~ed.so/duplicity/debian.paramiko.log
Merge into: lp:duplicity/0.6
Diff against target: 42 lines (+25/-0)
1 file modified
duplicity/backends/_ssh_paramiko.py (+25/-0)
To merge this branch: bzr merge lp:~ed.so/duplicity/debian.paramiko.log
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+200134@code.launchpad.net

Description of the change

tested and working

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'duplicity/backends/_ssh_paramiko.py'
2--- duplicity/backends/_ssh_paramiko.py 2013-04-27 13:52:49 +0000
3+++ duplicity/backends/_ssh_paramiko.py 2013-12-28 16:44:06 +0000
4@@ -30,6 +30,7 @@
5 import sys
6 import time
7 import getpass
8+import logging
9 from binascii import hexlify
10
11 import duplicity.backend
12@@ -104,6 +105,30 @@
13
14 self.client = paramiko.SSHClient()
15 self.client.set_missing_host_key_policy(AgreedAddPolicy())
16+
17+ # paramiko uses logging with the normal python severity levels,
18+ # but duplicity uses both custom levels and inverted logic...*sigh*
19+ self.client.set_log_channel("sshbackend")
20+ ours=paramiko.util.get_logger("sshbackend")
21+ dest=logging.StreamHandler(sys.stderr)
22+ dest.setFormatter(logging.Formatter('ssh: %(message)s'))
23+ ours.addHandler(dest)
24+
25+ # ..and the duplicity levels are neither linear,
26+ # nor are the names compatible with python logging, eg. 'NOTICE'...WAAAAAH!
27+ plevel=logging.getLogger("duplicity").getEffectiveLevel()
28+ if plevel <= 1:
29+ wanted=logging.DEBUG
30+ elif plevel <= 5:
31+ wanted=logging.INFO
32+ elif plevel <= 7:
33+ wanted=logging.WARNING
34+ elif plevel <= 9:
35+ wanted=logging.ERROR
36+ else:
37+ wanted=logging.CRITICAL
38+ ours.setLevel(wanted)
39+
40 # load known_hosts files
41 # paramiko is very picky wrt format and bails out on any problem...
42 try:

Subscribers

People subscribed via source and target branches

to all changes: