Esempio n. 1
0
def heartbeat_thread_run():
    logger = logging.getLogger('sgtk.syntheyes.heartbeat')

    try:
        interval = float(os.getenv(HEARTBEAT_INTERVAL, '0.2'))
    except:
        logger.error("Error setting interval from %s: %s", HEARTBEAT_INTERVAL,
                     os.getenv(HEARTBEAT_INTERVAL))

    try:
        tolerance = int(os.getenv(HEARTBEAT_TOLERANCE, '1'))
    except:
        logger.error("Error setting tolerance from %s: %s", HEARTBEAT_TOLERANCE,
                     os.getenv(HEARTBEAT_TOLERANCE))

    error_cycle = 0
    while True:
        time.sleep(interval)
        try:
            hlev = get_existing_connection()
            if not hlev.core.OK():
                logger.error("Heartbeat: No connection.")
                error_cycle += 1
        except Exception, e:
            logger.exception("Python: Heartbeat unknown exception: %s" % e)

        if error_cycle >= tolerance:
            msg = "Python: Quitting. Heartbeat errors greater than tolerance."
            logger.error(msg)
            os._exit(0)
Esempio n. 2
0
        return

    engine_name = os.environ.get("TANK_ENGINE")
    try:
        context = sgtk.context.deserialize(os.environ.get("TANK_CONTEXT"))
    except Exception, e:
        msg = ("Shotgun: Could not create context! Shotgun Pipeline Toolkit "
               "will be disabled. Details: %s" % e)
        msg_box(msg)
        return

    try:
        sgtk.platform.start_engine(engine_name, context.tank, context)
    except Exception, e:
        msg_box("Shotgun: Could not start SynthEyes engine: %s" % e)
        return

    file_to_open = os.environ.get("TANK_FILE_TO_OPEN")
    if file_to_open:
        from syntheyes import get_existing_connection
        hlev = get_existing_connection()
        hlev.OpenSNI(file_path)

    # clean up temp env vars
    for var in ["TANK_ENGINE", "TANK_CONTEXT", "TANK_FILE_TO_OPEN"]:
        if var in os.environ:
            del os.environ[var]


bootstrap_tank()