示例#1
0
    def __init__(self,
                 api,
                 db_config_path=None,
                 transports_json="",
                 transmitter_exe="",
                 automatic_line=False,
                 internet_provider="",
                 logger=None,
                 log_folder=None,
                 log_name=None,
                 log_level="DEBUG"):
        """Initialize instance.

        Args:
            api (object): rayvision api object.
            db_config_path (string): Customize db_config.ini absolute path.
            transports_json (string): Customize the absolute path of the transfer configuration file.
            transmitter_exe (string): Customize the absolute path of the transfer execution file.
            automatic_line (bool): Whether to automatically obtain the transmission line, the default is "False"
            internet_provider (string): Network provider.
            logger (object): Customize log object.
            log_folder (string): Customize the absolute path of the folder where logs are stored.
            log_name (string): Custom log file name, the system user name will be searched by default.
            log_level (string):  Set log level, example: "DEBUG","INFO","WARNING","ERROR"
        """
        self.logger = logger
        if not self.logger:
            init_logger(PACKAGE_NAME, log_folder, log_name)
            self.logger = logging.getLogger(__name__)
            self.logger.setLevel(level=log_level.upper())

        params = create_transfer_params(api)
        params["transports_json"] = transports_json
        params["transmitter_exe"] = transmitter_exe
        params["automatic_line"] = automatic_line
        params["internet_provider"] = internet_provider
        self.api = api
        self.trans = RayvisionTransfer(api, **params)

        # load db config ini
        self.transfer_log_path, self.redis_config, self.sqlite_config, self.database_config = \
            self.load_db_config(db_config_path)

        custom_db_path = self.database_config.get("db_path")
        db_dir = self._check_and_mk(custom_db_path)
        self.check_transfer_log_path(self.transfer_log_path)
        self.db_ini = os.path.join(db_dir, 'db_ini')
        self._db = os.path.join(db_dir, 'db')
示例#2
0
    def __init__(
        self,
        api,
        transports_json="",
        transmitter_exe="",
        automatic_line=False,
        internet_provider="",
        logger=None,
        log_folder=None,
        log_name=None,
        log_level="DEBUG",
    ):
        """Initialize instance.

        Args:
            api (object): rayvision api object.
            transports_json (string): Customize the absolute path of the transfer configuration file.
            transmitter_exe (string): Customize the absolute path of the transfer execution file.
            automatic_line (bool): Whether to automatically obtain the transmission line, the default is "False"
            internet_provider (string): Network provider.
            logger (object): Customize log object.
            log_folder (string): Customize the absolute path of the folder where logs are stored.
            log_name (string): Custom log file name, the system user name will be searched by default.
            log_level (string):  Set log level, example: "DEBUG","INFO","WARNING","ERROR"
        """
        params = create_transfer_params(api)
        params["transports_json"] = transports_json
        params["transmitter_exe"] = transmitter_exe
        params["automatic_line"] = automatic_line
        params["internet_provider"] = internet_provider
        self.api = api
        self.trans = RayvisionTransfer(api, **params)
        self.manage_task = self.trans.manage_task or RayvisionManageTask(
            api.query)
        self.logger = logger
        if not self.logger:
            init_logger(PACKAGE_NAME, log_folder, log_name)
            self.logger = logging.getLogger(__name__)
            self.logger.setLevel(level=log_level.upper())
示例#3
0
    def __init__(self,
                 access_id=None,
                 access_key=None,
                 domain='task.renderbus.com',
                 render_platform='4',
                 protocol='https',
                 logger=None,
                 hooks=None):
        """Initialize the Rayvision API instance.

        Args:
            access_id (str, optional): The access id of API.
            access_key (str, optional): The access key of the API.
            domain (str, optional): The domain address of the API.
            render_platform (str, optional): The platform of renderFarm.
            protocol (str, optional): The requests protocol.
            logger (logging.Logger, optional): The logging logger instance.
            hooks (dict, optional): Advanced features that allow us to add
                custom hooks for post requests.
                e.g:
                    def print_resp_url(resp, *args, **kwargs):
                        print(resp.url)

                    def check_for_errors(resp, *args, **kwargs):
                        resp.raise_for_status()

                    hooks = {'response': [print_resp_url, check_for_errors]}

        References:
            https://alexwlchan.net/2017/10/requests-hooks/

        """
        self.logger = logger

        if not self.logger:
            init_logger(PACKAGE_NAME)
            self.logger = logging.getLogger(__name__)

        access_id = access_id or os.getenv("RAYVISION_API_ACCESS_ID")
        if not access_id:
            raise TypeError(
                'Required "access_id" not specified. Pass as argument or set '
                'in environment variable RAYVISION_API_ACCESS_ID.')
        access_key = access_key or os.getenv("RAYVISION_API_KEY")
        if not access_id:
            raise TypeError(
                'Required "access_key" not specified. Pass as argument or set '
                'in environment variable RAYVISION_API_KEY.')

        # Initialize the session instance.
        self._request = requests.Session()

        # Create a connection.
        self._connect = Connect(access_id,
                                access_key,
                                protocol,
                                domain,
                                render_platform,
                                session=self._request,
                                hooks=hooks)

        # Initialize all instances of api operators.
        self.user_profile = UserProfile(self._connect)
        self.render_jobs = RenderJobs(self._connect)
        self.project = ProjectSettings(self._connect)
        self.render_config = RenderConfig(self._connect)
示例#4
0
"""A Python-based API for Using Renderbus cloud rendering service."""

# pylint: disable=import-error
# Import third-party modules
from pkg_resources import DistributionNotFound, get_distribution
from rayvision_log import init_logger

# Import local modules
from rayvision_sync.constants import PACKAGE_NAME
from rayvision_sync.transfer import RayvisionTransfer

# Initialize the logger.
init_logger(PACKAGE_NAME)

# All API of the public.
__all__ = ['RayvisionTransfer']

try:
    __version__ = get_distribution(__name__).version
except DistributionNotFound:
    # Package is not installed.
    __version__ = '0.0.0-dev.1'
示例#5
0
    def __init__(self,
                 access_id=None,
                 access_key=None,
                 domain='task.renderbus.com',
                 platform='4',
                 protocol='https',
                 logger=None,
                 log_folder=None,
                 log_name=None,
                 log_level="DEBUG",
                 ):
        """Please note that this is API parameter initialization.

        Args:
            access_id (str, optional): The access id of API.
            access_key (str, optional): The access key of the API.
            domain (str, optional): The domain address of the API.
            platform (str, optional): The platform of renderFarm.
            protocol (str, optional): The requests protocol.
            logger (logging.Logger, optional): The logging logger instance.
            log_folder (str, optional): Custom log save location.
            log_name (str): Custom log file name.
            log_level (str, optional): Custom log level, default "DEBUG".
        """
        self.logger = logger
        if not self.logger:
            init_logger(PACKAGE_NAME, log_folder, log_name)
            self.logger = logging.getLogger(__name__)
            self.logger.setLevel(level=log_level.upper())

        access_id = access_id or os.getenv("RAYVISION_API_ACCESS_ID")
        if not access_id:
            raise TypeError(
                'Required "access_id" not specified. Pass as argument or set '
                'in environment variable RAYVISION_API_ACCESS_ID.'
            )
        access_key = access_key or os.getenv("RAYVISION_API_KEY")
        if not access_id:
            raise TypeError(
                'Required "access_key" not specified. Pass as argument or set '
                'in environment variable RAYVISION_API_KEY.'
            )

        self._connect = Connect(access_id,
                                access_key,
                                protocol,
                                domain,
                                platform,
                                logger=self.logger)

        # Initial all api instance.
        self.user = UserOperator(self._connect)
        self.task = TaskOperator(self._connect)
        self.query = QueryOperator(self._connect)
        self.tag = TagOperator(self._connect)
        self.env = RenderEnvOperator(self._connect)
        self.transmit = TransmitOperator(self._connect)

        try:
            self._login()
        except HTTPError:
            raise RayvisionError(20020, 'Login failed.')
示例#6
0
    def __init__(self,
                 cg_file,
                 software_version,
                 project_name,
                 plugin_config,
                 render_software="Maya",
                 render_layer_type="0",
                 input_project_path=None,
                 local_os=None,
                 workspace=None,
                 custom_exe_path=None,
                 platform="2",
                 logger=None,
                 log_folder=None,
                 log_name=None,
                 log_level="DEBUG"):
        """Initialize and examine the analysis information.

        Args:
            cg_file (str): Scene file path.
            software_version (str): Software version.
            project_name (str): The project name.
            plugin_config (dict): Plugin information.
            render_software (str): Software name, Maya by default.
            render_layer_type (str): 0 is render layer, 1 is render setup.
            input_project_path (str): The working path of the scenario.
            local_os (str): System name, linux or windows.
            workspace (str): Analysis out of the result file storage path.
            custom_exe_path (str): Customize the exe path for the analysis.
            platform (str): Platform num.
            logger (object, optional): Custom log object.
            log_folder (str, optional): Custom log save location.
            log_name (str, optional): Custom log file name.
            log_level (string):  Set log level, example: "DEBUG","INFO","WARNING","ERROR".
        """
        self.logger = logger
        if not self.logger:
            init_logger(PACKAGE_NAME, log_folder, log_name)
            self.logger = logging.getLogger(__name__)
            self.logger.setLevel(level=log_level.upper())

        self.check_path(cg_file)
        self.cg_file = cg_file

        self.render_software = render_software
        self.input_project_path = input_project_path or ""
        self.render_layer_type = render_layer_type
        self.software_version = software_version
        self.project_name = project_name
        self.plugin_config = plugin_config

        local_os = self.check_local_os(local_os)
        self.local_os = local_os
        self.tmp_mark = str(int(time.time()))
        workspace = os.path.join(self.check_workspace(workspace),
                                 self.tmp_mark)
        if not os.path.exists(workspace):
            os.makedirs(workspace)
        self.workspace = workspace

        if custom_exe_path:
            self.check_path(custom_exe_path)
        self.custom_exe_path = custom_exe_path

        self.platform = platform

        self.task_json = os.path.join(workspace, "task.json")
        self.tips_json = os.path.join(workspace, "tips.json")
        self.asset_json = os.path.join(workspace, "asset.json")
        self.upload_json = os.path.join(workspace, "upload.json")
        self.tips_info = {}
        self.task_info = {}
        self.asset_info = {}
        self.upload_info = {}