def test_chunked_operations(self, api_iterator, rest_request): api_iterator.side_effect = self.api_iterator_side_effect storage = FilesStorage(self.UUIDS) storage.chunk_size = 1 storage.store() storage.delete() for uuid in self.UUIDS: rest_request.assert_any_call('PUT', storage.storage_url, [uuid]) rest_request.assert_any_call('DELETE', storage.storage_url, [uuid])
def test_chunked_operations(self, api_iterator, rest_request): api_iterator.side_effect = self.api_iterator_side_effect storage = FilesStorage(self.UUIDS) storage.chunk_size = 1 storage.store() storage.delete() for uuid in self.UUIDS: rest_request.assert_any_call("PUT", storage.storage_url, [uuid]) rest_request.assert_any_call("DELETE", storage.storage_url, [uuid])
def test_operations(self, api_iterator, rest_request): api_iterator.side_effect = self.api_iterator_side_effect storage = FilesStorage(self.UUIDS) storage.store() rest_request.assert_called_with("PUT", storage.storage_url, self.UUIDS) rest_request.reset_mock() storage.delete() rest_request.assert_called_with("DELETE", storage.storage_url, self.UUIDS)
def test_operations(self, api_iterator, rest_request): api_iterator.side_effect = self.api_iterator_side_effect storage = FilesStorage(self.UUIDS) storage.store() rest_request.assert_called_with('PUT', storage.storage_url, self.UUIDS) rest_request.reset_mock() storage.delete() rest_request.assert_called_with('DELETE', storage.storage_url, self.UUIDS)
# installation: # pip install pytz pyuploadcare~=2.1.0 import pytz from datetime import timedelta, datetime import time from pyuploadcare import conf from pyuploadcare.api_resources import FileList, FilesStorage MAX_LIFETIME = 30 # days conf.pub_key = 'demopublickey' conf.secret = 'demoprivatekey' dt_cutoff = datetime.now(pytz.utc) - timedelta(days=MAX_LIFETIME) if __name__ == '__main__': print 'Selecting files to be deleted...' uuid_list = [ f.uuid for f in FileList(starting_point=dt_cutoff, ordering='-datetime_uploaded', stored=True, request_limit=500) ] print 'Batch delete of selected files' ts1 = time.time() fs = FilesStorage(uuid_list) fs.delete() ts2 = time.time() print 'Operation completed in %f seconds' % (ts2 - ts1)
# pip install pytz pyuploadcare~=2.1.0 import pytz from datetime import timedelta, datetime import time from pyuploadcare import conf from pyuploadcare.api_resources import FileList, FilesStorage MAX_LIFETIME = 30 # days conf.pub_key = 'demopublickey' conf.secret = 'demoprivatekey' dt_cutoff = datetime.now(pytz.utc) - timedelta(days=MAX_LIFETIME) if __name__ == '__main__': print 'Selecting files to be deleted...' uuid_list = [f.uuid for f in FileList(starting_point=dt_cutoff, ordering='-datetime_uploaded', stored=True, request_limit=500)] print 'Batch delete of selected files' ts1 = time.time() fs = FilesStorage(uuid_list) fs.delete() ts2 = time.time() print 'Operation completed in %f seconds' % (ts2 - ts1)