-
Notifications
You must be signed in to change notification settings - Fork 205
SG-38306 Python2 Removal - Part 3 - Cleanup imports #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
julien-lang
wants to merge
7
commits into
ticket/SG-38306-python2-removal-future-wording
Choose a base branch
from
ticket/SG-38306-python2-removal-cleanup-imports
base: ticket/SG-38306-python2-removal-future-wording
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
473b811
six.moves imports
julien-lang f68f1ae
Cleanup BytesIO import from six
julien-lang 0b956cc
simple json
julien-lang b94da1a
Cleanup Py2-3 compat with ImportError
julien-lang 6e89b98
Simplify Base64
julien-lang 439d0b3
fixup! six.moves imports
julien-lang adbc0da
fixup! six.moves imports
julien-lang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,9 +29,13 @@ | |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
""" | ||
|
||
import base64 | ||
import copy | ||
import datetime | ||
import json | ||
import http.client # Used for secure file upload | ||
import http.cookiejar # used for attachment upload | ||
import io # used for attachment upload | ||
import logging | ||
import os | ||
import re | ||
|
@@ -40,29 +44,22 @@ | |
import stat # used for attachment upload | ||
import sys | ||
import time | ||
import urllib.error | ||
import urllib.parse | ||
import urllib.request | ||
import uuid # used for attachment upload | ||
|
||
# Import Error and ResponseError (even though they're unused in this file) since they need | ||
# to be exposed as part of the API. | ||
from xmlrpc.client import Error, ProtocolError, ResponseError # noqa | ||
Check failure on line 54 in shotgun_api3/shotgun.py
|
||
|
||
# Python 2/3 compatibility | ||
from .lib import six | ||
from .lib import sgsix | ||
from .lib import sgutils | ||
from .lib.six import BytesIO # used for attachment upload | ||
from .lib.six.moves import map | ||
from .lib.six.moves import http_cookiejar # used for attachment upload | ||
from .lib.six.moves import urllib | ||
from .lib.six.moves import http_client # Used for secure file upload. | ||
from .lib.httplib2 import Http, ProxyInfo, socks, ssl_error_classes | ||
from .lib.sgtimezone import SgTimezone | ||
|
||
# Import Error and ResponseError (even though they're unused in this file) since they need | ||
# to be exposed as part of the API. | ||
from .lib.six.moves.xmlrpc_client import Error, ProtocolError, ResponseError # noqa | ||
|
||
if six.PY3: | ||
from base64 import encodebytes as base64encode | ||
else: | ||
from base64 import encodestring as base64encode | ||
|
||
|
||
LOG = logging.getLogger("shotgun_api3") | ||
""" | ||
|
@@ -708,13 +705,13 @@ | |
# and auth header | ||
|
||
# Do NOT self._split_url(self.base_url) here, as it contains the lower | ||
# case version of the base_url argument. Doing so would base64encode | ||
# case version of the base_url argument. Doing so would base64.encodebytes | ||
# the lowercase version of the credentials. | ||
auth, self.config.server = self._split_url(base_url) | ||
if auth: | ||
auth = base64encode(urllib.parse.unquote(auth).encode("utf-8")).decode( | ||
"utf-8" | ||
) | ||
auth = base64.encodebytes( | ||
urllib.parse.unquote(auth).encode("utf-8") | ||
).decode("utf-8") | ||
self.config.authorization = "Basic " + auth.strip() | ||
|
||
# foo:[email protected]:3456 | ||
|
@@ -3003,8 +3000,8 @@ | |
This is used internally for downloading attachments from FPTR. | ||
""" | ||
sid = self.get_session_token() | ||
cj = http_cookiejar.LWPCookieJar() | ||
c = http_cookiejar.Cookie( | ||
cj = http.cookiejar.LWPCookieJar() | ||
c = http.cookiejar.Cookie( | ||
"0", | ||
"_session_id", | ||
sid, | ||
|
@@ -4433,7 +4430,7 @@ | |
data_size = len(data) | ||
# keep data as a stream so that we don't need to worry how it was | ||
# encoded. | ||
data = BytesIO(data) | ||
data = io.BytesIO(data) | ||
bytes_read += data_size | ||
part_url = self._get_upload_part_link( | ||
upload_info, filename, part_number | ||
|
@@ -4663,13 +4660,13 @@ | |
raise ShotgunError("Max attemps limit reached.") | ||
|
||
|
||
class CACertsHTTPSConnection(http_client.HTTPConnection): | ||
class CACertsHTTPSConnection(http.client.HTTPConnection): | ||
""" " | ||
This class allows to create an HTTPS connection that uses the custom certificates | ||
passed in. | ||
""" | ||
|
||
default_port = http_client.HTTPS_PORT | ||
default_port = http.client.HTTPS_PORT | ||
|
||
def __init__(self, *args, **kwargs): | ||
""" | ||
|
@@ -4761,7 +4758,7 @@ | |
# We'll do this across both python 2/3 rather than add more branching. | ||
boundary = uuid.uuid4() | ||
if buffer is None: | ||
buffer = BytesIO() | ||
buffer = io.BytesIO() | ||
for key, value in params: | ||
if isinstance(key, bytes): | ||
key = key.decode("utf-8") | ||
|
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.