Skip to content

Commit

Permalink
rerun test, style
Browse files Browse the repository at this point in the history
  • Loading branch information
calvinhzy committed Jul 4, 2024
1 parent da5a2c8 commit b0d3006
Show file tree
Hide file tree
Showing 10 changed files with 203 additions and 216 deletions.
5 changes: 3 additions & 2 deletions src/storage-preview/azext_storage_preview/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ def register_content_settings_argument(self, settings_class, update, arg_group=N
self.extra('clear_content_settings',
help='If this flag is set, then if any one or more of the '
'following properties (--content-cache-control, --content-disposition, --content-encoding, '
'--content-language, --content-md5, --content-type) is set, then all of these properties are '
'set together. If a value is not provided for a given property when at least one of the '
'--content-language, --content-md5, --content-type) is set, '
'then all of these properties are set together. '
'If a value is not provided for a given property when at least one of the '
'properties listed below is set, then that property will be cleared.',
arg_type=get_three_state_flag())

Expand Down
2 changes: 0 additions & 2 deletions src/storage-preview/azext_storage_preview/_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

from azure.cli.core.profiles import get_sdk
from .profiles import CUSTOM_DATA_STORAGE


def build_table_output(result, projection):
Expand Down
5 changes: 2 additions & 3 deletions src/storage-preview/azext_storage_preview/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------

# pylint: disable=protected-access, logging-format-interpolation
# pylint: disable=protected-access, logging-format-interpolation, too-many-branches
import os
import argparse

Expand Down Expand Up @@ -888,8 +888,7 @@ def process_file_batch_source_parameters(cmd, namespace):


def validate_source_uri(cmd, namespace): # pylint: disable=too-many-statements
from .util import create_short_lived_blob_sas, create_short_lived_blob_sas_v2, \
create_short_lived_file_sas, create_short_lived_file_sas_v2
from .util import create_short_lived_blob_sas_v2, create_short_lived_file_sas_v2
usage_string = \
'Invalid usage: {}. Supply only one of the following argument sets to specify source:' \
'\n\t --source-uri [--source-sas]' \
Expand Down
10 changes: 5 additions & 5 deletions src/storage-preview/azext_storage_preview/azcopy/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
AZCOPY_VERSION = '10.5.0'


class AzCopy(object):
class AzCopy:
system_executable_path = {
'Darwin': ['azcopy_darwin_amd64_{}'.format(AZCOPY_VERSION), 'azcopy'],
'Linux': ['azcopy_linux_amd64_{}'.format(AZCOPY_VERSION), 'azcopy'],
Expand Down Expand Up @@ -55,7 +55,7 @@ def sync(self, source, destination, flags=None):
self.run_command(['sync', source, destination] + flags)


class AzCopyCredentials(object): # pylint: disable=too-few-public-methods
class AzCopyCredentials: # pylint: disable=too-few-public-methods
def __init__(self, sas_token=None, token_info=None):
self.sas_token = sas_token
self.token_info = token_info
Expand All @@ -66,7 +66,7 @@ def login_auth_for_azcopy(cmd):
try:
token_info = _unserialize_non_msi_token_payload(token_info)
except KeyError: # unserialized MSI token payload
raise Exception('MSI auth not yet supported.')
raise RuntimeError('MSI auth not yet supported.')
return AzCopyCredentials(token_info=token_info)


Expand All @@ -80,13 +80,13 @@ def blob_client_auth_for_azcopy(cmd, blob_client):
try:
token_info = _unserialize_non_msi_token_payload(token_info)
except KeyError: # unserialized MSI token payload
raise Exception('MSI auth not yet supported.')
raise RuntimeError('MSI auth not yet supported.')
return AzCopyCredentials(token_info=token_info)


def storage_client_auth_for_azcopy(cmd, client, service):
if service not in SERVICES:
raise Exception('{} not one of: {}'.format(service, str(SERVICES)))
raise KeyError('{} not one of: {}'.format(service, str(SERVICES)))

if client.sas_token:
return AzCopyCredentials(sas_token=client.sas_token)
Expand Down
2 changes: 1 addition & 1 deletion src/storage-preview/azext_storage_preview/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from azure.cli.core.commands import CliCommandType
from azure.cli.core.commands.arm import show_exception_handler
from ._client_factory import (cf_sa, blob_data_service_factory, adls_blob_data_service_factory,
cf_share_client, cf_share_service, cf_share_file_client, cf_share_directory_client)
cf_share_client, cf_share_file_client, cf_share_directory_client)
from .profiles import (CUSTOM_DATA_STORAGE, CUSTOM_DATA_STORAGE_ADLS, CUSTOM_MGMT_STORAGE,
CUSTOM_DATA_STORAGE_FILESHARE)

Expand Down
4 changes: 2 additions & 2 deletions src/storage-preview/azext_storage_preview/oauth_token_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import threading


class TokenUpdater(object):
class TokenUpdater:
"""
This class updates a given token_credential periodically using the provided callback function.
It shows one way of making sure the credential does not become expired.
Expand Down Expand Up @@ -34,7 +34,7 @@ def timer_callback(self):
seconds_left = (datetime.fromtimestamp(int(token['expires_on'])) - datetime.now()).seconds
if seconds_left < 240:
# acquired token expires in less than 4 mins
raise Exception("Acquired a token expiring in less than 4 minutes")
raise RuntimeError("Acquired a token expiring in less than 4 minutes")

with self.lock:
self.timer = threading.Timer(seconds_left - 240, self.timer_callback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from .profiles import CUSTOM_DATA_STORAGE


class ServiceProperties(object):
class ServiceProperties:
def __init__(self, cli_ctx, name, service, account_name=None, account_key=None, connection_string=None,
sas_token=None):
self.cli_ctx = cli_ctx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


# pylint: disable=too-few-public-methods, too-many-instance-attributes
class StorageResourceIdentifier(object):
class StorageResourceIdentifier:
def __init__(self, cloud, moniker):
self.is_valid = False
self.account_name = None
Expand Down
Loading

0 comments on commit b0d3006

Please sign in to comment.