mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 16:34:53 +01:00
Better import - added missed file
Fix - changed metaclass of AbstractProvider Fix - added missed implementation of abstract method
This commit is contained in:
parent
574dc150a3
commit
4a232eded3
3 changed files with 51 additions and 2 deletions
44
pype/modules/sync_server/providers/abstract_provider.py
Normal file
44
pype/modules/sync_server/providers/abstract_provider.py
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
|
|
||||||
|
class AbstractProvider(metaclass=ABCMeta):
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def upload_file(self, source_path, target_path, overwrite=True):
|
||||||
|
"""
|
||||||
|
Copy file from 'source_path' to 'target_path' on provider.
|
||||||
|
Use 'overwrite' boolean to rewrite existing file on provider
|
||||||
|
:param source_path: absolute path on local system
|
||||||
|
:param target_path: absolute path on provider (GDrive etc.)
|
||||||
|
:param overwrite: <boolean> True if overwite existing
|
||||||
|
:return: <string> file_id of created file, raises exception
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def download_file(self, source_path, local_path):
|
||||||
|
"""
|
||||||
|
Download file from provider into local system
|
||||||
|
:param source_path: absolute path on provider
|
||||||
|
:param local_path: absolute path on local
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def delete_file(self, path):
|
||||||
|
"""
|
||||||
|
Deletes file from 'path'. Expects path to specific file.
|
||||||
|
:param path: absolute path to particular file
|
||||||
|
:return: None
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
||||||
|
@abstractmethod
|
||||||
|
def list_folder(self, folder_path):
|
||||||
|
"""
|
||||||
|
List all files and subfolders of particular path non-recursively.
|
||||||
|
:param folder_path: absolut path on provider
|
||||||
|
:return: <list>
|
||||||
|
"""
|
||||||
|
pass
|
||||||
|
|
@ -192,6 +192,9 @@ class GDriveHandler(AbstractProvider):
|
||||||
|
|
||||||
return file["id"]
|
return file["id"]
|
||||||
|
|
||||||
|
def download_file(self, source_path, local_path):
|
||||||
|
pass
|
||||||
|
|
||||||
def delete_folder(self, path, force=False):
|
def delete_folder(self, path, force=False):
|
||||||
"""
|
"""
|
||||||
Deletes folder on GDrive. Checks if folder contains any files or
|
Deletes folder on GDrive. Checks if folder contains any files or
|
||||||
|
|
|
||||||
|
|
@ -214,7 +214,8 @@ class SynchServerThread(threading.Thread):
|
||||||
while self.is_running:
|
while self.is_running:
|
||||||
|
|
||||||
sync_representations = self.module.get_sync_representations()
|
sync_representations = self.module.get_sync_representations()
|
||||||
|
import time
|
||||||
|
start_time = time.time()
|
||||||
for provider in lib.factory.providers: # TODO clumsy
|
for provider in lib.factory.providers: # TODO clumsy
|
||||||
for sync in sync_representations:
|
for sync in sync_representations:
|
||||||
files = sync.get("files") or {}
|
files = sync.get("files") or {}
|
||||||
|
|
@ -227,7 +228,8 @@ class SynchServerThread(threading.Thread):
|
||||||
await self.module.upload(file, sync, provider)
|
await self.module.upload(file, sync, provider)
|
||||||
if status == SyncStatus.DO_DOWNLOAD:
|
if status == SyncStatus.DO_DOWNLOAD:
|
||||||
await self.module.download(file, sync, provider)
|
await self.module.download(file, sync, provider)
|
||||||
|
duration = time.time() - start_time
|
||||||
|
log.info("One loop took {}".format(duration))
|
||||||
await asyncio.sleep(60)
|
await asyncio.sleep(60)
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue