|
29 | 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | 30 | """ |
31 | 31 |
|
| 32 | +import base64 |
32 | 33 | import copy |
33 | 34 | import datetime |
34 | 35 | import json |
| 36 | +import http.client # Used for secure file upload |
| 37 | +import http.cookiejar # used for attachment upload |
| 38 | +import io # used for attachment upload |
35 | 39 | import logging |
36 | 40 | import os |
37 | 41 | import re |
|
40 | 44 | import stat # used for attachment upload |
41 | 45 | import sys |
42 | 46 | import time |
| 47 | +import urllib.error |
| 48 | +import urllib.parse |
| 49 | +import urllib.request |
43 | 50 | import uuid # used for attachment upload |
44 | 51 |
|
| 52 | +# Import Error and ResponseError (even though they're unused in this file) since they need |
| 53 | +# to be exposed as part of the API. |
| 54 | +from xmlrpc.client import Error, ProtocolError, ResponseError # noqa |
| 55 | + |
45 | 56 | # Python 2/3 compatibility |
46 | 57 | from .lib import six |
47 | 58 | from .lib import sgsix |
48 | 59 | from .lib import sgutils |
49 | | -from .lib.six import BytesIO # used for attachment upload |
50 | | -from .lib.six.moves import map |
51 | | -from .lib.six.moves import http_cookiejar # used for attachment upload |
52 | | -from .lib.six.moves import urllib |
53 | | -from .lib.six.moves import http_client # Used for secure file upload. |
54 | 60 | from .lib.httplib2 import Http, ProxyInfo, socks, ssl_error_classes |
55 | 61 | from .lib.sgtimezone import SgTimezone |
56 | 62 |
|
57 | | -# Import Error and ResponseError (even though they're unused in this file) since they need |
58 | | -# to be exposed as part of the API. |
59 | | -from .lib.six.moves.xmlrpc_client import Error, ProtocolError, ResponseError # noqa |
60 | | - |
61 | | -if six.PY3: |
62 | | - from base64 import encodebytes as base64encode |
63 | | -else: |
64 | | - from base64 import encodestring as base64encode |
65 | | - |
66 | 63 |
|
67 | 64 | LOG = logging.getLogger("shotgun_api3") |
68 | 65 | """ |
@@ -708,13 +705,13 @@ def __init__( |
708 | 705 | # and auth header |
709 | 706 |
|
710 | 707 | # Do NOT self._split_url(self.base_url) here, as it contains the lower |
711 | | - # case version of the base_url argument. Doing so would base64encode |
| 708 | + # case version of the base_url argument. Doing so would base64.encodebytes |
712 | 709 | # the lowercase version of the credentials. |
713 | 710 | auth, self.config.server = self._split_url(base_url) |
714 | 711 | if auth: |
715 | | - auth = base64encode(urllib.parse.unquote(auth).encode("utf-8")).decode( |
716 | | - "utf-8" |
717 | | - ) |
| 712 | + auth = base64.encodebytes( |
| 713 | + urllib.parse.unquote(auth).encode("utf-8") |
| 714 | + ).decode("utf-8") |
718 | 715 | self.config.authorization = "Basic " + auth.strip() |
719 | 716 |
|
720 | 717 | |
@@ -3003,8 +3000,8 @@ def get_auth_cookie_handler(self): |
3003 | 3000 | This is used internally for downloading attachments from FPTR. |
3004 | 3001 | """ |
3005 | 3002 | sid = self.get_session_token() |
3006 | | - cj = http_cookiejar.LWPCookieJar() |
3007 | | - c = http_cookiejar.Cookie( |
| 3003 | + cj = http.cookiejar.LWPCookieJar() |
| 3004 | + c = http.cookiejar.Cookie( |
3008 | 3005 | "0", |
3009 | 3006 | "_session_id", |
3010 | 3007 | sid, |
@@ -4432,7 +4429,7 @@ def _multipart_upload_file_to_storage(self, path, upload_info): |
4432 | 4429 | data_size = len(data) |
4433 | 4430 | # keep data as a stream so that we don't need to worry how it was |
4434 | 4431 | # encoded. |
4435 | | - data = BytesIO(data) |
| 4432 | + data = io.BytesIO(data) |
4436 | 4433 | bytes_read += data_size |
4437 | 4434 | part_url = self._get_upload_part_link( |
4438 | 4435 | upload_info, filename, part_number |
@@ -4662,13 +4659,13 @@ def _send_form(self, url, params): |
4662 | 4659 | raise ShotgunError("Max attemps limit reached.") |
4663 | 4660 |
|
4664 | 4661 |
|
4665 | | -class CACertsHTTPSConnection(http_client.HTTPConnection): |
| 4662 | +class CACertsHTTPSConnection(http.client.HTTPConnection): |
4666 | 4663 | """ " |
4667 | 4664 | This class allows to create an HTTPS connection that uses the custom certificates |
4668 | 4665 | passed in. |
4669 | 4666 | """ |
4670 | 4667 |
|
4671 | | - default_port = http_client.HTTPS_PORT |
| 4668 | + default_port = http.client.HTTPS_PORT |
4672 | 4669 |
|
4673 | 4670 | def __init__(self, *args, **kwargs): |
4674 | 4671 | """ |
@@ -4760,7 +4757,7 @@ def encode(self, params, files, boundary=None, buffer=None): |
4760 | 4757 | # We'll do this across both python 2/3 rather than add more branching. |
4761 | 4758 | boundary = uuid.uuid4() |
4762 | 4759 | if buffer is None: |
4763 | | - buffer = BytesIO() |
| 4760 | + buffer = io.BytesIO() |
4764 | 4761 | for key, value in params: |
4765 | 4762 | if isinstance(key, bytes): |
4766 | 4763 | key = key.decode("utf-8") |
|
0 commit comments