Esempio n. 1
0
    def get_files_index(self, path=''):
        index = {}

        abspath = self.get_abspath(path, asFolder=True)
        response = self.wc.propfind(uri=abspath,
                                    names=True,
                                    depth='1')
        # We can t use infinite depth some owncloud version
        # didn t support it

        if response.real == 207:
            for res in response:
                if len(res.get('resourcetype').getchildren()) == 0:
                    index[requests.utils.unquote(self.get_relpath(res.href))] \
                        = round(time.mktime(rfc822.parsedate(
                            res.get('getlastmodified').text)))
                else:
                    # Workarround for infinite depth
                    if res.href != abspath:
                        index.update(
                            self.get_files_index(
                                path=self.get_relpath(res.href)))

        elif response.real == 200:
            raise NetworkError('Wrong answer from server')

        else:
            raise NetworkError('Can\'t list file on webdav host')

        return index
Esempio n. 2
0
    def connect(self,):

        urlparsed = requests.utils.urlparse(self.url)

        self.wc = tinydav.WebDAVClient(host=urlparsed.netloc,
                                       protocol=urlparsed.scheme,
                                       nosslcheck=self.nosslcheck)

        self.wc.setbasicauth(self.login.encode('utf-8'),
                             self.passwd.encode('utf-8'))
        self.time_delta = None

        local_time = datetime.datetime.utcnow()

        response = self.wc.options('/').headers.get('date')
        if response is None:
            response = self.wc.options('/').headers.get('Date')

        remote_datetime = \
            rfc822.parsedate(response)

        self.time_delta = time.mktime(local_time.utctimetuple()) \
            - time.mktime(remote_datetime)

        self._check_notes_folder()

        self.logger.logger.debug('Response :  %s',
                                 response)

        self.logger.logger.info('Connected to %s : Time delta %s',
                                urlparsed.netloc, str(self.time_delta))

        return self.time_delta
Esempio n. 3
0
    def get_files_index(self, path=''):
        index = {}

        abspath = self.get_abspath(path, asFolder=True)
        response = self.wc.propfind(uri=abspath,
                                    names=True,
                                    depth='1')
        # We can t use infinite depth some owncloud version
        # didn t support it

        if response.real == 207:
            for res in response:
                if len(res.get('resourcetype').getchildren()) == 0:
                    index[requests.utils.unquote(self.get_relpath(res.href))] \
                        = round(time.mktime(rfc822.parsedate(
                            res.get('getlastmodified').text)))
                else:
                    # Workarround for infinite depth
                    if res.href != abspath:
                        index.update(
                            self.get_files_index(
                                path=self.get_relpath(res.href)))

        elif response.real == 200:
            raise NetworkError('Wrong answer from server')

        else:
            raise NetworkError('Can\'t list file on webdav host')

        return index
Esempio n. 4
0
    def connect(self,):

        urlparsed = requests.utils.urlparse(self.url)

        self.wc = tinydav.WebDAVClient(host=urlparsed.netloc,
                                       protocol=urlparsed.scheme,
                                       nosslcheck=self.nosslcheck)

        self.wc.setbasicauth(self.login.encode('utf-8'),
                             self.passwd.encode('utf-8'))
        self.time_delta = None

        local_time = datetime.datetime.utcnow()

        response = self.wc.options(self.basepath).headers.get('date')
        if response is None:
            response = self.wc.options(self.basepath).headers.get('Date')

        remote_datetime = \
            rfc822.parsedate(response)

        self.time_delta = time.mktime(local_time.utctimetuple()) \
            - time.mktime(remote_datetime)

        self._check_notes_folder()

        self.logger.logger.debug('Response :  %s',
                                 response)

        self.logger.logger.info('Connected to %s : Time delta %s',
                                urlparsed.netloc, str(self.time_delta))

        return self.time_delta
Esempio n. 5
0
 def get_mtime(self, relpath):
     response = self.wc.propfind(uri=self.get_abspath(relpath))
     if response.real != 207:
         raise NetworkError('Can\'t get mtime file on webdav host')
     else:
         for res in response:
             return round(time.mktime(rfc822.parsedate(
                 res.get('getlastmodified').text)))
Esempio n. 6
0
 def get_mtime(self, relpath):
     response = self.wc.propfind(uri=self.get_abspath(relpath))
     if response.real != 207:
         raise NetworkError('Can\'t get mtime file on webdav host')
     else:
         for res in response:
             return round(time.mktime(rfc822.parsedate(
                 res.get('getlastmodified').text)))