Exemple #1
0
    def get_assets(self, request):
        _project_name = request.url_data["project_name"]
        _asset = request.url_data["asset"]

        if not self.dbcon.exist_table(_project_name):
            abort(404, "Project \"{}\" was not found in database".format(
                _project_name
            ))

        if not _asset:
            assets = self.dbcon[_project_name].find({"type": "asset"})
            output = self.result_to_json(assets)
            return CallbackResult(data=output)

        # identificator can be specified with url query (default is `name`)
        identificator = request.query.get("identificator", "name")

        asset = self.dbcon[_project_name].find_one({
            "type": "asset",
            identificator: _asset
        })
        if asset:
            id = asset["_id"]
            asset["_id"] = str(id)
            return asset

        abort(404, "Asset \"{}\" with {} was not found in project {}".format(
            _asset, identificator, _project_name
        ))
Exemple #2
0
    def get_project(self, request):
        project_name = request.url_data["project_name"]
        if not project_name:
            output = {}
            for project_name in self.dbcon.tables():
                project = self.dbcon[project_name].find_one(
                    {"type": "project"})
                output[project_name] = project

            return CallbackResult(data=self.result_to_json(output))

        project = self.dbcon[project_name].find_one({"type": "project"})

        if project:
            return CallbackResult(data=self.result_to_json(project))

        abort(404,
              "Project \"{}\" was not found in database".format(project_name))
Exemple #3
0
    def publish(self, request):
        """Triggers publishing script in subprocess.

        The subprocess freeze process and during publishing is not possible to
        handle other requests and is possible that freeze main application.

        TODO: Freezing issue may be fixed with socket communication.

        Example url:
        http://localhost:8021/adobe/publish (POST)
        """
        try:
            publish_env = self._prepare_publish_environments(
                request.request_data
            )
        except Exception as exc:
            log.warning(
                "Failed to prepare environments for publishing.",
                exc_info=True
            )
            abort(400, str(exc))

        output_data_path = publish_env["AC_PUBLISH_OUTPATH"]

        log.info("Pyblish is running")
        try:
            # Trigger subprocess
            # QUESTION should we check returncode?
            returncode = execute(
                [sys.executable, PUBLISH_SCRIPT_PATH],
                env=publish_env
            )

            # Check if output file exists
            if returncode != 0 or not os.path.exists(output_data_path):
                abort(500, "Publishing failed")

            log.info("Pyblish have stopped")

            return CallbackResult(
                data={"return_data_path": output_data_path}
            )

        except Exception:
            log.warning("Publishing failed", exc_info=True)
            abort(500, "Publishing failed")
Exemple #4
0
 def get_presets(self, request):
     project_name = request.url_data["project_name"]
     return CallbackResult(data=config.get_presets(project_name))
Exemple #5
0
 def available(self):
     return CallbackResult()