Skip to content

Commit

Permalink
Merge 13b21b9 into 1ac5fc1
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaszsocha2 committed Dec 14, 2021
2 parents 1ac5fc1 + 13b21b9 commit 28296de
Show file tree
Hide file tree
Showing 83 changed files with 205 additions and 305 deletions.
6 changes: 2 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@ before_cache:

matrix:
include:
- python: 2.7
- python: 3.5
env: TOX_ENV=pycodestyle
- python: 2.7
- python: 3.5
env: TOX_ENV=pylint
- python: 2.7
env: TOX_ENV=py27
- python: 3.5
env: TOX_ENV=py35
- python: 3.6
Expand Down
30 changes: 5 additions & 25 deletions .travis/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,6 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
fi

case "${TOX_ENV}" in
py26)
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py --user
;;
py27)
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py --user
;;
py33)
pyenv install 3.3.6
pyenv global 3.3.6
;;
py34)
pyenv install 3.4.2
pyenv global 3.4.2
;;
py35)
pyenv install 3.5.0
pyenv global 3.5.0
Expand All @@ -45,10 +29,15 @@ if [[ "$(uname -s)" == 'Darwin' ]]; then
pyenv install 3.6.0
pyenv global 3.6.0
;;
py37)
pyenv install 3.7.0
pyenv global 3.7.0
;;
pypy)
pyenv install "pypy${PYPY_VERSION}"
pyenv global "pypy${PYPY_VERSION}"
;;

esac
pyenv rehash
python -m pip install -U --user virtualenv
Expand All @@ -65,15 +54,6 @@ else
pip install -U virtualenv
pip install --upgrade pip
python -m venv $PWD/.venv
elif [[ "${TOX_ENV}" == "py27" ]] || [[ "${TOX_ENV}" == "pycodestyle" ]] || [[ "${TOX_ENV}" == "pylint" ]]; then
git clone https://github.com/yyuu/pyenv.git $PWD/.pyenv
export PYENV_ROOT="$PWD/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
pyenv install 2.7.14
pyenv global 2.7.14
pip install -U virtualenv
python -m virtualenv $PWD/.venv
else
python -m virtualenv $PWD/.venv
fi
Expand Down
2 changes: 1 addition & 1 deletion .travis/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set -o pipefail
if [[ "$(uname -s)" == "Darwin" ]]; then
eval "$(pyenv init -)"
else
if [[ "${TOX_ENV}" == "pypy" ]] || [[ "${TOX_ENV}" == "py27" ]] || [[ "${TOX_ENV}" == "pycodestyle" ]] || [[ "${TOX_ENV}" == "pylint" ]]; then
if [[ "${TOX_ENV}" == "pypy" ]]; then
export PYENV_ROOT="$PWD/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
Expand Down
23 changes: 12 additions & 11 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Release History
---------------

2.14.0 (2021-12-08)
++++++++
++++++++++++++++++++

**New Features and Enhancements:**

Expand All @@ -14,11 +14,12 @@ Release History
- Support base item operations for WebLink class (`#639 <https://github.com/box/box-python-sdk/pull/639>`_)

**Bug Fixes:**

- Limit cryptography to version <3.5.0 (`#636 <https://github.com/box/box-python-sdk/pull/636>`_)
- Avoid raising 404 when a thumbnail cannot be generated for a file (`#642 <https://github.com/box/box-python-sdk/pull/642>`_)

2.13.0 (2021-09-30)
++++++++
++++++++++++++++++++

**New Features and Enhancements:**

Expand All @@ -30,14 +31,14 @@ Release History
- Upgrade cryptography to version 3 (`#620 <https://github.com/box/box-python-sdk/pull/620>`_)

2.12.1 (2021-06-16)
++++++++
++++++++++++++++++++

**Bug Fixes:**

- Fix bug when thumbnail representations are not found (`#597 <https://github.com/box/box-python-sdk/pull/597>`_)

2.12.0 (2021-04-16)
++++++++
++++++++++++++++++++

**New Features and Enhancements:**

Expand All @@ -47,14 +48,14 @@ Release History
- Update `get_groups()` to use documented parameter to filter by name (`#586 <https://github.com/box/box-python-sdk/pull/586>`_)

2.11.0 (2021-01-11)
++++++++
++++++++++++++++++++

**New Features and Enhancements:**

- Deprecate and add method for getting a thumbnail (`#572 <https://github.com/box/box-python-sdk/pull/572>`_)

2.10.0 (2020-10-02)
++++++++
++++++++++++++++++++

**New Features and Enhancements:**

Expand All @@ -68,21 +69,21 @@ Release History
- Allow ints to be passed in as item IDs (`#530 <https://github.com/box/box-python-sdk/pull/530>`_)

2.9.0 (2020-06-23)
++++++++
++++++++++++++++++++
- Fix exception handling for OAuth
- Fix path parameter sanitization

2.8.0 (2020-04-24)
++++++++
++++++++++++++++++++
- Added support for token exchange using shared links
- Added the ability to pass in a SHA1 value for file uploads

2.7.1 (2020-01-21)
++++++++
++++++++++++++++++++
- Fixed bug in `_get_retry_request_callable` introduced in release 2.7.0 which caused chunked uploads to fail

2.7.0 (2020-01-16)
++++++++
++++++++++++++++++++
- Fixed bug in `get_admin_events` function which caused errors when the optional `event_types` parameter was omitted.
- Add marker based pagination for listing users.
- Added support for more attribute parameters when uploading new files and new versions of existing files.
Expand All @@ -93,7 +94,7 @@ Release History

2.6.1 (2019-10-24)
++++++++++++++++++
- Added api_ call decorator for copy method.
- Added `api_call` decorator for copy method.

2.6.0 (2019-08-29)
++++++++++++++++++
Expand Down
3 changes: 1 addition & 2 deletions boxsdk/auth/cooperatively_managed_oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def __init__(self, retrieve_tokens=None, *args, **kwargs):
"""
# pylint:disable=keyword-arg-before-vararg
self._retrieve_tokens = retrieve_tokens
super(CooperativelyManagedOAuth2Mixin, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def _get_tokens(self):
"""
Expand All @@ -33,4 +33,3 @@ class CooperativelyManagedOAuth2(CooperativelyManagedOAuth2Mixin):
Allows for sharing auth tokens between multiple clients. The retrieve_tokens callback should
return the current access/refresh token pair.
"""
pass
2 changes: 1 addition & 1 deletion boxsdk/auth/developer_token_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class DeveloperTokenAuth(OAuth2):

def __init__(self, get_new_token_callback=None, **kwargs):
self._get_new_token = get_new_token_callback
super(DeveloperTokenAuth, self).__init__(
super().__init__(
client_id=None,
client_secret=None,
access_token=self._refresh_developer_token(),
Expand Down
2 changes: 1 addition & 1 deletion boxsdk/auth/jwt_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def __init__(
)
del rsa_private_key_data
del rsa_private_key_file_sys_path
super(JWTAuth, self).__init__(
super().__init__(
client_id,
client_secret,
store_tokens=store_tokens,
Expand Down
17 changes: 9 additions & 8 deletions boxsdk/auth/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
import sys
from threading import Lock

# pylint:disable=import-error,no-name-in-module,relative-import
# pylint:disable=import-error,no-name-in-module
from six.moves.urllib.parse import urlencode, urlunsplit
# pylint:enable=import-error,no-name-in-module,relative-import
# pylint:enable=import-error,no-name-in-module
import six

from ..config import API
Expand All @@ -38,10 +38,9 @@ class TokenScope(TextEnum):

class TokenResponse(BaseAPIJSONObject):
""" Represents the response for a token request. """
pass


class OAuth2(object):
class OAuth2:
"""
Responsible for handling OAuth2 for the Box API. Can authenticate and refresh tokens.
Expand Down Expand Up @@ -344,13 +343,14 @@ def _execute_token_request(self, data, access_token, expect_refresh_token=True):
access_token=access_token,
)
except BoxAPIException as box_api_exception:
six.raise_from(self._oauth_exception(box_api_exception.network_response, url), box_api_exception)
raise self._oauth_exception(box_api_exception.network_response, url) from box_api_exception

if not network_response.ok:
raise self._oauth_exception(network_response, url)
try:
token_response = TokenResponse(network_response.json())
except ValueError:
raise self._oauth_exception(network_response, url)
except ValueError as value_exception:
raise self._oauth_exception(network_response, url) from value_exception

if ('access_token' not in token_response) or (expect_refresh_token and 'refresh_token' not in token_response):
raise self._oauth_exception(network_response, url)
Expand Down Expand Up @@ -426,7 +426,8 @@ def revoke(self):
access_token=access_token,
)
except BoxAPIException as box_api_exception:
six.raise_from(self._oauth_exception(box_api_exception.network_response, url), box_api_exception)
raise self._oauth_exception(box_api_exception.network_response, url) from box_api_exception

if not network_response.ok:
raise BoxOAuthException(
network_response.status_code,
Expand Down
2 changes: 1 addition & 1 deletion boxsdk/auth/redis_managed_jwt_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ def _auth_with_jwt(self, sub, sub_type):
"""
Base class override. Returns the access token in a tuple to match the OAuth2 interface.
"""
return super(RedisManagedJWTAuth, self)._auth_with_jwt(sub, sub_type), None
return super()._auth_with_jwt(sub, sub_type), None
5 changes: 2 additions & 3 deletions boxsdk/auth/redis_managed_oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self, unique_id=uuid4(), redis_server=None, *args, **kwargs):
self._unique_id = unique_id
self._redis_server = redis_server or StrictRedis()
refresh_lock = Lock(redis=self._redis_server, name='{0}_lock'.format(self._unique_id))
super(RedisManagedOAuth2Mixin, self).__init__(*args, refresh_lock=refresh_lock, **kwargs)
super().__init__(*args, refresh_lock=refresh_lock, **kwargs)
if self._access_token is None:
self._get_and_update_current_tokens()

Expand All @@ -54,12 +54,11 @@ def _store_tokens(self, access_token, refresh_token):
Base class override.
Saves the refreshed tokens in redis.
"""
super(RedisManagedOAuth2Mixin, self)._store_tokens(access_token, refresh_token)
super()._store_tokens(access_token, refresh_token)
self._redis_server.hmset(self._unique_id, {'access': access_token, 'refresh': refresh_token})


class RedisManagedOAuth2(RedisManagedOAuth2Mixin):
"""
OAuth2 subclass which uses Redis to manage tokens.
"""
pass
3 changes: 1 addition & 2 deletions boxsdk/auth/remote_managed_oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self, retrieve_access_token=None, *args, **kwargs):
"""
# pylint:disable=keyword-arg-before-vararg
self._retrieve_access_token = retrieve_access_token
super(RemoteOAuth2Mixin, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)

def _refresh(self, access_token):
"""
Expand All @@ -35,4 +35,3 @@ class RemoteOAuth2(RemoteOAuth2Mixin):
Allows for storing auth tokens remotely. The retrieve_access_token callback should
return an access token, presumably acquired from a remote server on which your auth credentials are available.
"""
pass
2 changes: 1 addition & 1 deletion boxsdk/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(
:type session:
:class:`BoxSession`
"""
super(Client, self).__init__()
super().__init__()
self._oauth = oauth
if session is not None:
self._session = session
Expand Down
5 changes: 1 addition & 4 deletions boxsdk/client/developer_token_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,4 @@ class DeveloperTokenClient(Client):
Box client subclass which authorizes with a developer token.
"""
def __init__(self, oauth=None, session=None):
super(DeveloperTokenClient, self).__init__(
oauth=oauth or DeveloperTokenAuth(),
session=session,
)
super().__init__(oauth=oauth or DeveloperTokenAuth(), session=session)
2 changes: 1 addition & 1 deletion boxsdk/client/logging_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ class LoggingClient(Client):
"""
def __init__(self, *args, **kwargs):
setup_logging(None)
super(LoggingClient, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
6 changes: 3 additions & 3 deletions boxsdk/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from . import version


class API(object):
class API:
"""Configuration object containing the URLs for the Box API."""
BASE_API_URL = 'https://api.box.com/2.0'
UPLOAD_URL = 'https://upload.box.com/api/2.0'
Expand All @@ -16,7 +16,7 @@ class API(object):
MAX_RETRY_ATTEMPTS = 5


class Client(object):
class Client:
"""Configuration object containing the user agent string."""
VERSION = version.__version__
USER_AGENT_STRING = 'box-python-sdk-{0}'.format(VERSION)
Expand All @@ -28,6 +28,6 @@ class Client(object):
)


class Proxy(object):
class Proxy:
URL = None
AUTH = None
1 change: 0 additions & 1 deletion boxsdk/exception.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ class BoxNetworkException(BoxException):
"""
Exception raised from the network layer.
"""
pass


@attr.s(repr=True, slots=True, frozen=True)
Expand Down
2 changes: 1 addition & 1 deletion boxsdk/network/default_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class DefaultNetwork(Network):
EXCEPTION_FORMAT = '\x1b[31mRequest "%(method)s %(url)s" failed with %(exc_type_name)s exception: %(exc_value)r\x1b[0m'

def __init__(self):
super(DefaultNetwork, self).__init__()
super().__init__()
self._session = requests.Session()
self._logger = getLogger(__name__)

Expand Down
Loading

0 comments on commit 28296de

Please sign in to comment.