Exemple #1
0
 def list_recording_ids(self):
     Config.read()
     recs = os.listdir(Config.recordings_dir())
     logging.info(u"List of files: {} -> {}".format(Config.recordings_dir(),
                                                    recs))
     extracted = [rec_id for rec_id in recs if self.is_extracted(rec_id)]
     return list(sorted(extracted))
Exemple #2
0
def register():
    import bpy
    from byplay.byplay_import_operator import ByplayImportOperator
    from byplay.config import Config

    Config.setup_logger()

    logging.info("Registering Byplay plugin from " + byplay_plugin_path)
    bpy.utils.register_class(ByplayImportOperator)
    bpy.types.TOPBAR_MT_file_import.append(menu_func)
Exemple #3
0
def reload_all_modules():
    hou = get_hou()

    hou.ui.displayMessage(u"reloading")
    for name, module in sys.modules.items():
        if name.split(u".")[0] == u"byplay" and module is not None:
            print u"reloading {}".format(name)
            from importlib import reload
            reload(module)
    Config.read()
Exemple #4
0
def log_amplitude(event_type, **props):
    logging.info("AMP: {} {}".format(event_type, props))

    global AMPLITUDE
    if Config.mute_amplitude():
        return
    AMPLITUDE.log_event(
        AMPLITUDE.create_event(
            event_type=event_type,
            user_id=Config.user_id(),
            event_properties=props
        )
    )
Exemple #5
0
 def run(self, command, params={}):
     args = command.replace("\n", " ")
     for k, v in params.items():
         args = args.replace("${}".format(k), v)
     final_cmd = "{} {}".format(Config.ffmpeg_path(), args)
     logging.debug("Executing ffmpeg '{}'".format(final_cmd))
     os.system(final_cmd)
Exemple #6
0
    def apply_recording(self):
        self.connect_to_loader()

        HoudiniParamsBuilder.add_byplay_tab_to_recording_container(self.node)
        pref = self.recording.frames_prefix()
        path_params = {
            "video_frames_path":
            '`chs("recording_path")`/frames/{}`padzero(5, $F-ch("byplay_start_frame")+1)`.png'
            .format(pref),
        }
        HoudiniParamsBuilder.set_exr_paths(
            self.node, self.recording.environment_exr_names)

        for k, v in path_params.items():
            path_params[k] = v.replace(self.recording.base_path,
                                       '`chs("recording_path")`')

        path_params['recording_path'] = self.recording.base_path.replace(
            Config.recordings_dir(),
            '`chs("/obj/byplayloader/byplay_recordings_dir")`')
        self.node.setParms(path_params)

        self.node.setParms({
            'byplay_recording_id':
            self.recording.id,
            'byplay_applied_postprocessing_y_offset':
            self.recording.postprocessing_y_offset,
            'byplay_target_postprocessing_y_offset':
            self.target_y_offset(),
            'byplay_recording_session_id':
            self.recording.recording_session_id,
        })
        self.node.parm("ty").setExpression(
            "ch('byplay_applied_postprocessing_y_offset') - ch('byplay_target_postprocessing_y_offset')"
        )
Exemple #7
0
def _try_user_id():
    try:
        return Config.user_id()
    except Exception as e:
        print(e)
        logging.error(e)
        return "[unk]"
Exemple #8
0
 def __init__(self, _doc):
     super(ByplayDialog, self).__init__()
     with ExceptionCatcher():
         Config.setup_logger()
         logging.info(u"Creating ByplayDialog")
         log_amplitude(u"Opened ByplayDialog")
         self.recording_storage = RecordingLocalStorage()
         self.recording_ids = list(reversed(self.recording_storage.list_recording_ids()))
         logging.info(u"Found {} recording ids".format(self.recording_ids))
         self.recording_id = None
         self._value = 0
         self._ids_by_names = {}
         self._last_id = 100000
         self.recording_thumbnail_image = None
         self.recording_manifest = None
         self.resolution = None
Exemple #9
0
def log_amplitude(event_type, **props):
    global AMPLITUDE
    AMPLITUDE.log_event(
        AMPLITUDE.create_event(device_id=u"houdini-plugin",
                               event_type=event_type,
                               user_id=Config.user_id(),
                               event_properties=props))
Exemple #10
0
 def list_env_exr_paths(self, recording_id):
     assets_path = join(Config.recordings_dir(), recording_id, u'assets')
     if not os.path.exists(assets_path):
         return []
     paths = [
         join(assets_path, p) for p in os.listdir(assets_path)
         if p.endswith(u".exr")
     ]
     return paths
Exemple #11
0
def log_amplitude(event_type, **props):
    try:
        global AMPLITUDE
        AMPLITUDE.log_event(
            AMPLITUDE.create_event(device_id="c4d-plugin",
                                   event_type=event_type,
                                   user_id=Config.user_id(),
                                   event_properties=props))
    except Exception as e:
        logging.error(e)
Exemple #12
0
def send_exception(exc_type, exc_value, exc_traceback):
    logging.error(exc_value)
    try:
        value = exc_value
        payload = {
            u'event_id': generate_random_key(32),
            u'platform': u'python',
            u'culpit': u'-',
            u'timestamp': unicode(datetime.utcnow()),
            u'dist': Config.build(),
            u'tags': sys_info(),
            u'user': {
                u'id': Config.user_id(),
            },
            u"exception": {
                u"values": [{
                    u"type": exc_type.__name__,
                    u"value": unicode(value),
                    u"stacktrace": {
                        u"frames":
                        list(
                            imap(
                                lambda f: {
                                    u'filename': f[0],
                                    u'lineno': f[1] + 1,
                                    u'function': f[2]
                                }, traceback.extract_tb(exc_traceback)))
                    }
                }]
            }
        }
        async_post(STORE_URL,
                   headers={
                       u"X-Sentry-Auth":
                       AUTH.format(timestamp=int(time.time()))
                   },
                   json=payload)
    except Exception, sending_exception:
        # raise sending_exception
        print u"Could not send:("
        print sending_exception
        logging.error(sending_exception)
Exemple #13
0
def send_exception(exc_type, exc_value, exc_traceback):
    logging.error(exc_value)
    try:
        value = exc_value
        payload = {
            'event_id': generate_random_key(32),
            'platform': 'python',
            'culpit': '-',
            'timestamp': str(datetime.utcnow()),
            'dist': Config.build(),
            'tags': sys_info(),
            'user': {
                'id': Config.user_id(),
            },
            "exception": {
                "values": [{
                    "type": exc_type.__name__,
                    "value": str(value),
                    "stacktrace": {
                        "frames":
                        list(
                            map(
                                lambda f: {
                                    'filename': f[0],
                                    'lineno': f[1] + 1,
                                    'function': f[2]
                                }, traceback.extract_tb(exc_traceback)))
                    }
                }]
            }
        }
        async_post(
            STORE_URL,
            headers={"X-Sentry-Auth": AUTH.format(timestamp=int(time.time()))},
            json=payload)
    except Exception as sending_exception:
        # raise sending_exception
        print("Could not send:(")
        print(sending_exception)
        logging.error(sending_exception)
Exemple #14
0
    def create_event(self, **kwargs):
        event = {}
        user_id = kwargs.get(u'user_id', None)
        device_id = kwargs.get(u'device_id', None)
        if self._is_None_or_not_str(user_id) and self._is_None_or_not_str(
                device_id):
            return None

        if self._is_None_or_not_str(user_id):
            event[u"device_id"] = device_id
        else:
            event[u"user_id"] = user_id

        event_type = kwargs.get(u'event_type', None)
        if self._is_None_or_not_str(event_type):
            return None

        event[u"event_type"] = event_type

        # integer epoch time in milliseconds
        if u"time" in kwargs:
            event[u"time"] = kwargs[u"time"]
        else:
            event[u"time"] = int(time.time() * 1000)

        if u"ip" in kwargs:
            event[u"ip"] = kwargs[u"ip"]

        event_properties = kwargs.get(u'event_properties', None)
        if event_properties is not None and type(event_properties) == dict:
            event[u"event_properties"] = event_properties

        sys = sys_info()
        event[u"platform"] = u"Houdini plugin"
        event[u"os_name"] = sys[u"os.name"]
        event[u"os_version"] = sys[u"os.version"]
        event[u"app_version"] = u"houdini-plugin:{}".format(Config.build())
        event[u"device_model"] = u"houdini:{}:{}".format(
            sys[u"houdini.version"], sys[u"houdini.platform"])

        event_package = [
            (u'api_key', self.api_key),
            (u'event', json.dumps([event])),
        ]

        # print(event_package)

        # ++ many other properties
        # details: https://amplitude.zendesk.com/hc/en-us/articles/204771828-HTTP-API
        return event_package
Exemple #15
0
def setup_byplay_helper_nodes(node):
    try:
        Config.setup_logger()
    except Exception as e:
        capture_exception()
        raise e

    try:
        Config.read()
    except Exception as e:
        capture_exception()
        hou = get_hou()
        hou.ui.displayMessage(
            "Could not read config file. Please open Byplay Desktop and set it up",
            severity=hou.severityType.Error)
        raise e

    try:
        logging.info("Creating byplay loader node")
        byplay_settings_container.ByplaySettingsContainer(node).setup()
    except Exception as e:
        capture_exception()
        raise e
Exemple #16
0
    def add_byplay_tab_to_loader(node):
        hou = get_hou()
        parm_group = node.parmTemplateGroup()

        parm_folder = hou.FolderParmTemplate(u"byplay_settings", u"Byplay")

        for tpl in HoudiniParamsBuilder.byplay_settings_parm_templates(node):
            parm_folder.addParmTemplate(tpl)

        if Config.is_dev():
            parm_folder.addParmTemplate(
                hou.ButtonParmTemplate(
                    u"byplay_reload_modules",
                    u"[[DEV]] reload Byplay python modules",
                    script_callback=
                    u"__import__('byplay').ui_callbacks.reload_all_modules()",
                    script_callback_language=hou.scriptLanguage.Python))

        parm_group.append(parm_folder)
        node.setParmTemplateGroup(parm_group)
Exemple #17
0
def setup_byplay_helper_nodes(node):
    try:
        Config.setup_logger()
    except Exception, e:
        capture_exception()
        raise e
Exemple #18
0
 def list_env_exr_paths(self, recording_id):
     assets_path = join(Config.recordings_dir(), recording_id, 'assets')
     paths = [join(assets_path, p) for p in os.listdir(assets_path) if p.endswith(".exr")]
     return paths
Exemple #19
0
from byplay.config import Config
from byplay.helpers.recording_local_storage import RecordingLocalStorage
from byplay.recording import Recording
import byplay.wrappers.byplay_settings_container as byplay_settings_container
from byplay.wrappers.houdini_scene import HoudiniScene


def setup_byplay_helper_nodes(node):
    try:
        Config.setup_logger()
    except Exception, e:
        capture_exception()
        raise e

    try:
        Config.read()
    except Exception, e:
        capture_exception()
        hou = get_hou()
        hou.ui.displayMessage(
            u"Could not read config file. Please open Byplay Desktop and set it up",
            severity=hou.severityType.Error)
        raise e

    try:
        logging.info(u"Creating byplay loader node")
        byplay_settings_container.ByplaySettingsContainer(node).setup()
    except Exception, e:
        capture_exception()
        raise e
Exemple #20
0
 def apply_config(self):
     self.node.setParms({u"byplay_recordings_dir": Config.recordings_dir()})
Exemple #21
0
 def full_path(self, recording_id):
     return join(Config.recordings_dir(), recording_id)