Ejemplo n.º 1
0
 def update_item(self, item, status=ItemRecordStatuses.OK):
     """
     :param onedrive_d.api.items.OneDriveItem item:
     :param str status:
     :return:
     """
     if item.is_folder:
         crc32_hash = None
         sha1_hash = None
     else:
         file_facet = item.file_props
         crc32_hash = file_facet.hashes.crc32
         sha1_hash = file_facet.hashes.sha1
     parent_ref = item.parent_reference
     created_time_str = datetime_to_str(item.created_time)
     modified_time_str = datetime_to_str(item.modified_time)
     self.lock.writer_acquire()
     self._cursor.execute(
         'INSERT OR REPLACE INTO items (item_id, type, item_name, parent_id, parent_path, etag, '
         'ctag, size, created_time, modified_time, status, crc32_hash, sha1_hash)'
         ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
         (item.id, item.type, item.name, parent_ref.id, parent_ref.path, item.e_tag, item.c_tag,
          item.size, created_time_str, modified_time_str, status, crc32_hash, sha1_hash))
     self._conn.commit()
     self.lock.writer_release()
Ejemplo n.º 2
0
 def update_item(self, item, status=ItemRecordStatuses.OK):
     """
     :param onedrive_d.api.items.OneDriveItem item:
     :param str status:
     :return:
     """
     if item.is_folder:
         crc32_hash = None
         sha1_hash = None
     else:
         file_facet = item.file_props
         crc32_hash = file_facet.hashes.crc32
         sha1_hash = file_facet.hashes.sha1
     parent_ref = item.parent_reference
     created_time_str = datetime_to_str(item.created_time)
     modified_time_str = datetime_to_str(item.modified_time)
     self.lock.writer_acquire()
     self._cursor.execute(
         'INSERT OR REPLACE INTO items (item_id, type, item_name, parent_id, parent_path, etag, '
         'ctag, size, created_time, modified_time, status, crc32_hash, sha1_hash)'
         ' VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)',
         (item.id, item.type, item.name, parent_ref.id, parent_ref.path, item.e_tag, item.c_tag,
          item.size, created_time_str, modified_time_str, status, crc32_hash, sha1_hash))
     self._conn.commit()
     self.lock.writer_release()
Ejemplo n.º 3
0
 def set_datetime(self, prop, key, value):
     """
     Used internally to set a datetime property.
     :param str prop: Object property name.
     :param str key: Dictionary key name.
     :param datetime.datetime value: A UTC datetime object denoting when the file was created on a client.
     """
     setattr(self, prop, value)
     self.data[key] = datetime_to_str(value)
Ejemplo n.º 4
0
 def set_datetime(self, prop, key, value):
     """
     Used internally to set a datetime property.
     :param str prop: Object property name.
     :param str key: Dictionary key name.
     :param datetime.datetime value: A UTC datetime object denoting when the file was created on a client.
     """
     setattr(self, prop, value)
     self.data[key] = datetime_to_str(value)
Ejemplo n.º 5
0
 def test_convert(self):
     self.assertEqual(self.d, onedrive_d.str_to_datetime(self.s))
     self.assertEqual(self.s, onedrive_d.datetime_to_str(self.d))
     self.assertEqual(self.t, onedrive_d.datetime_to_timestamp(self.d))
Ejemplo n.º 6
0
 def test_convert(self):
     self.assertEqual(self.d, onedrive_d.str_to_datetime(self.s))
     self.assertEqual(self.s, onedrive_d.datetime_to_str(self.d))
     self.assertEqual(self.t, onedrive_d.datetime_to_timestamp(self.d))