Skip to content

Commit

Permalink
[misc] Some minor changes.
Browse files Browse the repository at this point in the history
Signed-off-by: Xiangyu Bu <[email protected]>
  • Loading branch information
xybu committed Feb 3, 2017
1 parent 6b21078 commit c7d9225
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
5 changes: 3 additions & 2 deletions onedrived/od_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from requests.utils import getproxies
import onedrivesdk
import onedrivesdk.error
import onedrivesdk.helpers.http_provider_with_proxy


from . import od_api_session
from .od_models import account_profile
Expand Down Expand Up @@ -48,7 +48,8 @@ def __init__(self):
if len(proxies) == 0:
http_provider = onedrivesdk.HttpProvider()
else:
http_provider = onedrivesdk.helpers.http_provider_with_proxy.HttpProviderWithProxy(proxies, verify_ssl=True)
from onedrivesdk.helpers.http_provider_with_proxy import HttpProviderWithProxy
http_provider = HttpProviderWithProxy(proxies, verify_ssl=True)
auth_provider = onedrivesdk.AuthProvider(http_provider=http_provider,
client_id=self.APP_CLIENT_ID,
session_type=od_api_session.OneDriveAPISession,
Expand Down
10 changes: 6 additions & 4 deletions onedrived/od_models/webhook_notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ def context(self):
:return str | None:
An optional string value that is passed back in the notification message for this subscription.
"""
if 'context' in self._prop_dict:
try:
return self._prop_dict['context']
return None
except KeyError:
return None

@property
def expiration_datetime(self):
Expand Down Expand Up @@ -56,9 +57,10 @@ def tenant_id(self):
Unique identifier for the tenant which generated this notification.
This is only returned for OneDrive for Business and SharePoint.
"""
if 'tenantId' in self._prop_dict:
try:
return self._prop_dict['tenantId']
return None
except KeyError:
return None

@property
def user_id(self):
Expand Down
2 changes: 1 addition & 1 deletion onedrived/od_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def __init__(self, context, authenticator, drive, drive_config):

@property
def _item_store_path(self):
return self.context.config_dir + '/items_' + self.drive.id + '.sqlite3'
return ''.join((self.context.config_dir, '/items_', self.drive.id, '.sqlite3'))

def _init_path_filter(self, ignore_file):
try:
Expand Down
4 changes: 4 additions & 0 deletions onedrived/od_tasks/upload_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ def handle(self):
if item_stat.st_size < self.PUT_FILE_SIZE_THRESHOLD_BYTES:
item_request = self.parent_dir_request.children[self.item_name]
returned_item = item_request_call(self.repo, item_request.upload, self.local_abspath)
if returned_item is None:
logging.warning('Upload API did not return metadata of remote item for "%s". '
'Make an explicit request.', self.local_abspath)
returned_item = item_request_call(self.repo, item_request.get)
else:
logging.info('Uploading large file "%s" in chunks of 10MB.', self.local_abspath)
item_request = self.repo.authenticator.client.item(drive=self.repo.drive.id, path=self.rel_path)
Expand Down

0 comments on commit c7d9225

Please sign in to comment.