diff --git a/bin/crypt.py b/bin/crypt.py index a5405f18..38d1a2b4 100644 --- a/bin/crypt.py +++ b/bin/crypt.py @@ -74,8 +74,8 @@ def aes_decrypt(self, key, chunksize=64 * 1024): args = ap.parse_args() crypt = Crypt(args.infile, args.outfile) if args.decrypt: - crypt.aes_decrypt(args.key) + crypt.aes_decrypt(args.key.encode()) else: nk = crypt.aes_encrypt(args.key) if args.key is None: - print("Key: %s" % nk) + print("Key: %s" % nk.decode()) diff --git a/bin/curl.py b/bin/curl.py index e896b1f9..f10d7b17 100644 --- a/bin/curl.py +++ b/bin/curl.py @@ -6,15 +6,12 @@ import argparse import requests -try: - from urllib.parse import urlparse -except ImportError: - from urlparse import urlparse +from six.moves.urllib.parse import urlparse try: import clipboard except ImportError: - pass + clipboard = None def main(args): @@ -27,6 +24,12 @@ def main(args): action='store_true', help='write output to a local file named like the remote file we get' ) + ap.add_argument( + '-L', + '--location', + action='store_true', + help='follow redirects to other web pages (if the URL has a 3XX response code)' + ) ap.add_argument( '-X', '--request-method', @@ -49,11 +52,24 @@ def main(args): headers[name.strip()] = value.strip() if ns.request_method == 'GET': - r = requests.get(url, headers=headers) + r = requests.get( + url, + headers=headers, + allow_redirects=ns.location + ) elif ns.request_method == 'POST': - r = requests.post(url, data=ns.data, headers=headers) + r = requests.post( + url, + data=ns.data, + headers=headers, + allow_redirects=ns.location + ) elif ns.request_method == 'HEAD': - r = requests.head(url, headers=headers) + r = requests.head( + url, + headers=headers, + allow_redirects=ns.location + ) else: print('unknown request method: {}'.format(ns.request_method)) return diff --git a/bin/pip.py b/bin/pip.py index d80be93a..7031ae5b 100644 --- a/bin/pip.py +++ b/bin/pip.py @@ -783,9 +783,12 @@ def _get_cooked_ast(filename): """ # with codecs.open(filename, mode="r", encoding="UTF-8") as ins: # s = ins.read() - with open(filename, "r") as ins: - s = ins.read() - tree = ast.parse(s, filename=filename, mode='exec') + with open(filename, "rb") as ins: + tree = ast.parse( + ins.read(), + filename=filename, + mode='exec' + ) ArchiveFileInstaller.SetupTransformer().visit(tree) return tree