ayon-core/openpype/modules/sync_server/utils.py
Jakub Trllo a31b2d9d77
SyncServer: Existence of module is optional (#5413)
* 'get_repre_icons' have optional sync server

* local settings have optional sync server

* sync server is optional in sceneinventory

* sync server is optional in loader tool

* sync server is optional in library loader

* sync server is optional in host dirmap

* sync server is optional in nuke cache

* sync server is optional in integrate plugin

* added "sync_server" back to ignored modules for openpype package

* fix missing variable

* mark syncserver command as deprecated

* define 'SYNC_SERVER_ROOT'

* added method to receive icon paths

* use sync server module to receive icons

* fix scene inventory
2023-08-07 18:48:27 +02:00

50 lines
1.1 KiB
Python

import os
import time
from openpype.lib import Logger
log = Logger.get_logger("SyncServer")
SYNC_SERVER_ROOT = os.path.dirname(os.path.abspath(__file__))
class ResumableError(Exception):
"""Error which could be temporary, skip current loop, try next time"""
pass
class SiteAlreadyPresentError(Exception):
"""Representation has already site skeleton present."""
pass
class SyncStatus:
DO_NOTHING = 0
DO_UPLOAD = 1
DO_DOWNLOAD = 2
def time_function(method):
""" Decorator to print how much time function took.
For debugging.
Depends on presence of 'log' object
"""
def timed(*args, **kw):
ts = time.time()
result = method(*args, **kw)
te = time.time()
if 'log_time' in kw:
name = kw.get('log_name', method.__name__.upper())
kw['log_time'][name] = int((te - ts) * 1000)
else:
log.debug('%r %2.2f ms' % (method.__name__, (te - ts) * 1000))
return result
return timed
class EditableScopes:
SYSTEM = 0
PROJECT = 1
LOCAL = 2