Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions owncloud/owncloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,13 @@
import os
import math
import six
import logging
from six.moves.urllib import parse


LOGGER = logging.getLogger(__name__)


class ResponseError(Exception):
def __init__(self, res, errorType):
if type(res) is int:
Expand Down Expand Up @@ -322,7 +326,7 @@ def __init__(self, url, **kwargs):
:param verify_certs: True (default) to verify SSL certificates, False otherwise
:param dav_endpoint_version: None (default) to force using a specific endpoint version
instead of relying on capabilities
:param debug: set to True to print debugging messages to stdout, defaults to False
:param debug: set to True to log debugging messages with python logging, defaults to False
"""
if not url.endswith('/'):
url += '/'
Expand Down Expand Up @@ -1265,7 +1269,7 @@ def share_file_with_user(self, path, user, **kwargs):
)

if self._debug:
print('OCS share_file request for file %s with permissions %i '
LOGGER.debug('OCS share_file request for file %s with permissions %i '
'returned: %i' % (path, perms, res.status_code))
if res.status_code == 200:
tree = ET.fromstring(res.content)
Expand Down Expand Up @@ -1713,7 +1717,7 @@ def _make_ocs_request(self, method, service, action, **kwargs):
attributes['headers']['OCS-APIREQUEST'] = 'true'

if self._debug:
print('OCS request: %s %s %s' % (method, self.url + path,
LOGGER.debug('OCS request: %s %s %s' % (method, self.url + path,
attributes))

res = self._session.request(method, self.url + path, **attributes)
Expand All @@ -1730,9 +1734,9 @@ def _make_dav_request(self, method, path, **kwargs):
if it didn't
"""
if self._debug:
print('DAV request: %s %s' % (method, path))
LOGGER.debug('DAV request: %s %s' % (method, path))
if kwargs.get('headers'):
print('Headers: ', kwargs.get('headers'))
LOGGER.debug('Headers: ', kwargs.get('headers'))

path = self._normalize_path(path)
res = self._session.request(
Expand All @@ -1741,7 +1745,7 @@ def _make_dav_request(self, method, path, **kwargs):
**kwargs
)
if self._debug:
print('DAV status: %i' % res.status_code)
LOGGER.debug('DAV status: %i' % res.status_code)
if res.status_code in [200, 207]:
return self._parse_dav_response(res)
if res.status_code in [204, 201]:
Expand Down