Last active
May 23, 2019 17:02
-
-
Save cowlinator/1bc874dc1afb48fac86b69f4e6f8efc8 to your computer and use it in GitHub Desktop.
Patch paramiko to remove cryptography warnings ( https://github.com/paramiko/paramiko/issues/1369 )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import distutils.version | |
import os | |
import subprocess | |
import sys | |
import paramiko | |
import requests | |
if __name__ == "__main__": | |
print(paramiko.__version__) | |
if distutils.version.StrictVersion(paramiko.__version__) > distutils.version.StrictVersion('2.4.2'): | |
print("Paramiko patch (supposedly) not required. Not patching.") | |
sys.exit(0) | |
response = requests.get( | |
"https://gist.githubusercontent.com/vkobel/52d795920aacd74afb4db15a89c39b8b/raw/3a75d984fb703413307f240c6c1cacd4d6036a8a/patchfile.diff", | |
stream=True | |
) | |
if response.status_code != 200 and response.status_code != 203 and response.status_code != 226: | |
raise Exception("Cannot get paramiko patch. Status code {sc}".format(sc=response.status_code)) | |
patchfile_path = os.path.expanduser(os.path.join("~", "tmp", "paramiko-patchfile.diff")) | |
try: | |
os.makedirs(os.path.dirname(patchfile_path)) | |
except Exception: | |
pass | |
with open(patchfile_path, 'wb') as file: | |
for chunk in response.iter_content(10 * 1024): | |
file.write(chunk) | |
os.chdir(paramiko.__path__[0]) | |
subprocess.check_call("patch -p1 <{pp}".format(pp=patchfile_path), shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This script will patch whichever
paramiko
package is currently installed. (To patch a virtualenv, first activate the virtualenv).This script should work on Linux and OS X. (untested)
This script will also work on Windows if you have added
C:\Program Files\Git\usr\bin
to your systemPath
environment variable. (tested)