Skip to content

Commit 06f566a

Browse files
eduardoChaucaGallegosjulien-lang
authored andcommitted
future, super funtion updated python 2 wording deleted
1 parent 413afc6 commit 06f566a

File tree

3 files changed

+18
-42
lines changed

3 files changed

+18
-42
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Integration and unit tests are provided.
4343
- (Note: Running `pip install -r tests/ci_requirements.txt` will install this package)
4444
- A `tests/config` file (you can copy an example from `tests/example_config`).
4545
- Tests can be run individually like this: `nosetests --config="nose.cfg" tests/test_client.py`
46-
- Make sure to not forget the `--config="nose.cfg"` option. This option tells nose to use our config file. This will exclude python 2- and 3-specific files in the `/lib` directory, preventing a failure from being reported by nose for compilation due to incompatible syntax in those files.
46+
- Make sure to not forget the `--config="nose.cfg"` option. This option tells nose to use our config file. This will exclude python 3-specific files in the `/lib` directory, preventing a failure from being reported by nose for compilation due to incompatible syntax in those files.
4747
- `test_client` and `tests_unit` use mock server interaction and do not require a Flow Production Tracking instance to be available (no modifications to `tests/config` are necessary).
4848
- `test_api` and `test_api_long` *do* require a Flow Production Tracking instance, with a script key available for the tests. The server and script user values must be supplied in the `tests/config` file. The tests will add test data to your server based on information in your config. This data will be manipulated by the tests, and should not be used for other purposes.
4949
- To run all of the tests, use the shell script `run-tests`.

azure-pipelines-templates/run-tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ parameters:
3333

3434
jobs:
3535
# The job will be named after the OS and Azure will suffix the strategy to make it unique
36-
# so we'll have a job name "Windows Python 2.7" for example. What's a strategy? Strategies are the
37-
# name of the keys under the strategy.matrix scope. So for each OS we'll have "<OS> Python 2.7" and
38-
# "<OS> Python 3.7".
36+
# so we'll have a job name "Windows Python 3.9" for example. What's a strategy? Strategies are the
37+
# name of the keys under the strategy.matrix scope. So for each OS we'll have "<OS> Python 3.9" and
38+
# "<OS> Python 3.10".
3939
- job: ${{ parameters.name }}
4040
pool:
4141
vmImage: ${{ parameters.vm_image }}
@@ -69,7 +69,7 @@ jobs:
6969
addToPath: True
7070

7171
# Install all dependencies needed for running the tests. This command is good for
72-
# Python 2 and 3, but also for all OSes
72+
# Python 3, but also for all OSes
7373
- script: |
7474
python -m pip install --upgrade pip setuptools wheel
7575
python -m pip install -r tests/ci_requirements.txt

shotgun_api3/shotgun.py

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -317,10 +317,8 @@ class ClientCapabilities(object):
317317
``windows``, or ``None`` (if the current platform couldn't be determined).
318318
:ivar str local_path_field: The PTR field used for local file paths. This is calculated using
319319
the value of ``platform``. Ex. ``local_path_mac``.
320-
:ivar str py_version: Simple version of Python executable as a string. Eg. ``2.7``.
321-
:ivar str ssl_version: Version of OpenSSL installed. Eg. ``OpenSSL 1.0.2g 1 Mar 2016``. This
322-
info is only available in Python 2.7+ if the ssl module was imported successfully.
323-
Defaults to ``unknown``
320+
:ivar str py_version: Simple version of Python executable as a string. Eg. ``3.9``.
321+
:ivar str ssl_version: Version of ssl module.
324322
"""
325323

326324
def __init__(self):
@@ -341,13 +339,7 @@ def __init__(self):
341339
self.local_path_field = None
342340

343341
self.py_version = ".".join(str(x) for x in sys.version_info[:2])
344-
345-
# extract the OpenSSL version if we can.
346-
self.ssl_version = "unknown"
347-
try:
348-
self.ssl_version = ssl.OPENSSL_VERSION
349-
except AttributeError:
350-
pass
342+
self.ssl_version = ssl.OPENSSL_VERSION
351343

352344
def __str__(self):
353345
return (
@@ -552,18 +544,6 @@ def __init__(
552544
:class:`~shotgun_api3.MissingTwoFactorAuthenticationFault` will be raised if the
553545
``auth_token`` is invalid.
554546
.. todo: Add this info to the Authentication section of the docs
555-
556-
.. note:: A note about proxy connections: If you are using Python <= v2.6.2, HTTPS
557-
connections through a proxy server will not work due to a bug in the :mod:`urllib2`
558-
library (see http://bugs.python.org/issue1424152). This will affect upload and
559-
download-related methods in the Shotgun API (eg. :meth:`~shotgun_api3.Shotgun.upload`,
560-
:meth:`~shotgun_api3.Shotgun.upload_thumbnail`,
561-
:meth:`~shotgun_api3.Shotgun.upload_filmstrip_thumbnail`,
562-
:meth:`~shotgun_api3.Shotgun.download_attachment`. Normal CRUD methods for passing JSON
563-
data should still work fine. If you cannot upgrade your Python installation, you can see
564-
the patch merged into Python v2.6.3 (http://hg.python.org/cpython/rev/0f57b30a152f/) and
565-
try and hack it into your installation but YMMV. For older versions of Python there
566-
are other patches that were proposed in the bug report that may help you as well.
567547
"""
568548

569549
# verify authentication arguments
@@ -602,13 +582,7 @@ def __init__(
602582
if script_name is not None or api_key is not None:
603583
raise ValueError("cannot provide an auth_code with script_name/api_key")
604584

605-
# Can't use 'all' with python 2.4
606-
if (
607-
len(
608-
[x for x in [session_token, script_name, api_key, login, password] if x]
609-
)
610-
== 0
611-
):
585+
if not any([session_token, script_name, api_key, login, password]):
612586
if connect:
613587
raise ValueError(
614588
"must provide login/password, session_token or script_name/api_key"
@@ -2856,9 +2830,9 @@ def download_attachment(self, attachment=False, file_path=None, attachment_id=No
28562830
This parameter exists only for backwards compatibility for scripts specifying
28572831
the parameter with keywords.
28582832
:returns: If ``file_path`` is provided, returns the path to the file on disk. If
2859-
``file_path`` is ``None``, returns the actual data of the file, as str in Python 2 or
2833+
``file_path`` is ``None``, returns the actual data of the file, as
28602834
bytes in Python 3.
2861-
:rtype: str | bytes
2835+
:rtype: bytes
28622836
"""
28632837
# backwards compatibility when passed via keyword argument
28642838
if attachment is False:
@@ -2919,11 +2893,13 @@ def download_attachment(self, attachment=False, file_path=None, attachment_id=No
29192893

29202894
if body:
29212895
xml = "".join(body)
2922-
# Once python 2.4 support is not needed we can think about using
2923-
# elementtree. The doc is pretty small so this shouldn't be an issue.
2924-
match = re.search("<Message>(.*)</Message>", xml)
2925-
if match:
2926-
err += " - %s" % (match.group(1))
2896+
try:
2897+
root = ET.fromstring(xml)
2898+
message_elem = root.find(".//Message")
2899+
if message_elem is not None and message_elem.text:
2900+
err += f" - {message_elem.text}"
2901+
except ET.ParseError:
2902+
pass
29272903
elif e.code == 409 or e.code == 410:
29282904
# we may be dealing with a file that is pending/failed a malware scan, e.g:
29292905
# 409: This file is undergoing a malware scan, please try again in a few minutes

0 commit comments

Comments
 (0)