summaryrefslogtreecommitdiffhomepage
path: root/demos
diff options
context:
space:
mode:
authorScott Maxwell <scott@codecobblers.com>2013-11-02 20:18:18 -0700
committerScott Maxwell <scott@codecobblers.com>2013-11-02 20:19:04 -0700
commit7444a999931cddc1e61bb35270468aa45da2687e (patch)
tree1ac60cc2d3a949285e3a4917c05c19a6d03c775d /demos
parent45e65b6e1eb47944a26e4349d41998844c155df5 (diff)
Fix some deprecation and resource warnings
Diffstat (limited to 'demos')
-rw-r--r--demos/demo_server.py4
-rwxr-xr-xdemos/demo_sftp.py8
2 files changed, 8 insertions, 4 deletions
diff --git a/demos/demo_server.py b/demos/demo_server.py
index deb21387..5a41a714 100644
--- a/demos/demo_server.py
+++ b/demos/demo_server.py
@@ -27,7 +27,7 @@ import threading
import traceback
import paramiko
-from paramiko.py3compat import b, u
+from paramiko.py3compat import b, u, decodebytes
# setup logging
@@ -46,7 +46,7 @@ class Server (paramiko.ServerInterface):
'fAu7jJ2d7eothvfeuoRFtJwhUmZDluRdFyhFY/hFAh76PJKGAusIqIQKlkJxMC' + \
'KDqIexkgHAfID/6mqvmnSJf0b5W8v5h2pI/stOSwTQ+pxVhwJ9ctYDhRSlF0iT' + \
'UWT10hcuO4Ks8=')
- good_pub_key = paramiko.RSAKey(data=base64.decodestring(data))
+ good_pub_key = paramiko.RSAKey(data=decodebytes(data))
def __init__(self):
self.event = threading.Event()
diff --git a/demos/demo_sftp.py b/demos/demo_sftp.py
index 2dba1722..d7f28084 100755
--- a/demos/demo_sftp.py
+++ b/demos/demo_sftp.py
@@ -20,6 +20,8 @@
# based on code provided by raymond mosteller (thanks!)
+from __future__ import with_statement
+
import base64
import getpass
import os
@@ -95,13 +97,15 @@ try:
except IOError:
print('(assuming demo_sftp_folder/ already exists)')
sftp.open('demo_sftp_folder/README', 'w').write('This was created by demo_sftp.py.\n')
- data = open('demo_sftp.py', 'r').read()
+ with open('demo_sftp.py', 'r') as f:
+ data = f.read()
sftp.open('demo_sftp_folder/demo_sftp.py', 'w').write(data)
print('created demo_sftp_folder/ on the server')
# copy the README back here
data = sftp.open('demo_sftp_folder/README', 'r').read()
- open('README_demo_sftp', 'w').write(data)
+ with open('README_demo_sftp', 'w') as f:
+ f.write(data)
print('copied README back here')
# BETTER: use the get() and put() methods