def __init__(self, logger=None): if not logger: self.log = Logger().get_logger(self.__class__.__name__) else: self.log = logger self.signature = "( {} )".format(self.__class__.__name__)
def __init__(self, tray_widget, main_window): self.tray_widget = tray_widget self.main_window = main_window self.log = Logger().get_logger(self.__class__.__name__) self.modules = {} self.services = {} self.services_submenu = None self.errors = [] CURRENT_DIR = os.path.dirname(__file__) self.modules_imports = config.load_json( os.path.join(CURRENT_DIR, "modules_imports.json")) presets = config.get_presets(first_run=True) menu_items = presets["tray"]["menu_items"] try: self.modules_usage = menu_items["item_usage"] except Exception: self.modules_usage = {} self.log.critical("Couldn't find modules usage data.") self.module_attributes = menu_items.get("attributes") or {} self.icon_run = QtGui.QIcon( resources.get_resource("icons", "circle_green.png")) self.icon_stay = QtGui.QIcon( resources.get_resource("icons", "circle_orange.png")) self.icon_failed = QtGui.QIcon( resources.get_resource("icons", "circle_red.png"))
def __init__(self): super(IdleManager, self).__init__() self.log = Logger().get_logger(self.__class__.__name__) self.qaction = None self.failed_icon = None self._is_running = False self.threads = []
def __init__(self): super(IdleManager, self).__init__() self.log = Logger().get_logger(self.__class__.__name__) self.signal_reset_timer.connect(self._reset_time) self.qaction = None self.failed_icon = None self._is_running = False
def __init__(self, tray_widget, main_window): self.tray_widget = tray_widget self.main_window = main_window self.log = Logger().get_logger(self.__class__.__name__) self.icon_run = QtGui.QIcon(get_resource('circle_green.png')) self.icon_stay = QtGui.QIcon(get_resource('circle_orange.png')) self.icon_failed = QtGui.QIcon(get_resource('circle_red.png')) self.services_thread = None
def __init__(self, main_parent=None, parent=None): self.log = Logger().get_logger(__name__) self.main_parent = main_parent self.parent = parent self.app_launcher = LauncherWindow() # actions.register_default_actions() actions.register_config_actions() actions.register_environment_actions()
def __init__(self, tray_widget, main_widget): self.log = Logger().get_logger(self.__class__.__name__) self.modules = [] self.is_running = False self.last_task = None self.tray_widget = tray_widget self.main_widget = main_widget self.idle_man = None self.signal_handler = None self.widget_user_idle = WidgetUserIdle(self, tray_widget)
class AvalonApps: def __init__(self, main_parent=None, parent=None): self.log = Logger().get_logger(__name__) self.main_parent = main_parent self.parent = parent self.app_launcher = LauncherWindow() # actions.register_default_actions() actions.register_config_actions() actions.register_environment_actions() def process_modules(self, modules): if "RestApiServer" in modules: from .rest_api import AvalonRestApi self.rest_api_obj = AvalonRestApi() # Definition of Tray menu def tray_menu(self, parent_menu=None): # Actions if parent_menu is None: if self.parent is None: self.log.warning('Parent menu is not set') return elif self.parent.hasattr('menu'): parent_menu = self.parent.menu else: self.log.warning('Parent menu is not set') return action_launcher = QtWidgets.QAction("Launcher", parent_menu) action_library_loader = QtWidgets.QAction("Library loader", parent_menu) action_launcher.triggered.connect(self.show_launcher) action_library_loader.triggered.connect(self.show_library_loader) parent_menu.addAction(action_launcher) parent_menu.addAction(action_library_loader) def show_launcher(self): # if app_launcher don't exist create it/otherwise only show main window self.app_launcher.show() self.app_launcher.raise_() self.app_launcher.activateWindow() def show_library_loader(self): libraryloader.show(parent=self.main_parent, icon=self.parent.icon, show_projects=True, show_libraries=True)
class AvalonApps: def __init__(self, main_parent=None, parent=None): self.log = Logger().get_logger(__name__) self.main_parent = main_parent self.parent = parent self.app_launcher = None def process_modules(self, modules): if "RestApiServer" in modules: from .rest_api import AvalonRestApi self.rest_api_obj = AvalonRestApi() # Definition of Tray menu def tray_menu(self, parent_menu=None): # Actions if parent_menu is None: if self.parent is None: self.log.warning('Parent menu is not set') return elif self.parent.hasattr('menu'): parent_menu = self.parent.menu else: self.log.warning('Parent menu is not set') return icon = QtGui.QIcon(launcher_lib.resource("icon", "main.png")) aShowLauncher = QtWidgets.QAction(icon, "&Launcher", parent_menu) aLibraryLoader = QtWidgets.QAction("Library", parent_menu) aShowLauncher.triggered.connect(self.show_launcher) aLibraryLoader.triggered.connect(self.show_library_loader) parent_menu.addAction(aShowLauncher) parent_menu.addAction(aLibraryLoader) def show_launcher(self): # if app_launcher don't exist create it/otherwise only show main window if self.app_launcher is None: io.install() APP_PATH = launcher_lib.resource("qml", "main.qml") self.app_launcher = launcher_widget.Launcher(APP_PATH) self.app_launcher.window.show() def show_library_loader(self): libraryloader.show(parent=self.main_parent, icon=self.parent.icon, show_projects=True, show_libraries=True)
def __init__(self, session): '''Expects a ftrack_api.Session instance''' self.log = Logger().get_logger(self.__class__.__name__) if not (isinstance(session, ftrack_api.session.Session) or isinstance(session, ftrack_server.lib.SocketSession)): raise Exception( ("Session object entered with args is instance of \"{}\"" " but expected instances are \"{}\" and \"{}\"").format( str(type(session)), str(ftrack_api.session.Session), str(ftrack_server.lib.SocketSession))) self._session = session # Using decorator self.register = self.register_decorator(self.register) self.launch = self.launch_log(self.launch)
def __init__(self, name, port, filepath, additional_args=[]): super(SocketThread, self).__init__() self.log = Logger().get_logger(self.__class__.__name__) self.setName(name) self.name = name self.port = port self.filepath = filepath self.additional_args = additional_args self.sock = None self.subproc = None self.connection = None self._is_running = False self.finished = False self.mongo_error = False self._temp_data = {}
def __init__(self, main_parent=None, parent=None): self.log = Logger().get_logger(self.__class__.__name__, "PypeTray") self.main_parent = main_parent self.parent = parent self.clockapi = ClockifyAPI() self.message_widget = None self.widget_settings = ClockifySettings(main_parent, self) self.widget_settings_required = None self.thread_timer_check = None # Bools self.bool_thread_check_running = False self.bool_api_key_set = False self.bool_workspace_set = False self.bool_timer_run = False self.clockapi.set_master(self) self.bool_api_key_set = self.clockapi.set_api()
class PhotoshopPrelaunch(pype.lib.PypeHook): """This hook will check for the existence of PyWin PyWin is a requirement for the Photoshop integration. """ project_code = None def __init__(self, logger=None): if not logger: self.log = Logger().get_logger(self.__class__.__name__) else: self.log = logger self.signature = "( {} )".format(self.__class__.__name__) def execute(self, *args, env: dict = None) -> bool: output = pype.lib._subprocess(["pip", "install", "pywin32==227"]) self.log.info(output) return True
def __init__(self, tray_widget, main_window): self.tray_widget = tray_widget self.main_window = main_window self.pype_info_widget = None self.log = Logger.get_logger(self.__class__.__name__) self.module_settings = get_system_settings()["modules"] self.modules_manager = TrayModulesManager() self.errors = []
def __init__(self, main_parent=None, parent=None): if not self.workspace_name: raise Exception("Clockify Workspace is not set in config.") os.environ["CLOCKIFY_WORKSPACE"] = self.workspace_name self.log = Logger().get_logger(self.__class__.__name__, "PypeTray") self.main_parent = main_parent self.parent = parent self.clockapi = ClockifyAPI(master_parent=self) self.message_widget = None self.widget_settings = ClockifySettings(main_parent, self) self.widget_settings_required = None self.thread_timer_check = None # Bools self.bool_thread_check_running = False self.bool_api_key_set = False self.bool_workspace_set = False self.bool_timer_run = False self.bool_api_key_set = self.clockapi.set_api()
def publish(paths): """Start headless publishing. Publish use json from passed paths argument. Args: paths (list): Paths to jsons. Raises: RuntimeError: When there is no pathto process. """ if not any(paths): raise RuntimeError("No publish paths specified") from pype import install, uninstall from pype.api import Logger # Register target and host import pyblish.api import pyblish.util env = get_app_environments_for_context(os.environ["AVALON_PROJECT"], os.environ["AVALON_ASSET"], os.environ["AVALON_TASK"], os.environ["AVALON_APP_NAME"]) os.environ.update(env) log = Logger.get_logger() install() pyblish.api.register_target("filesequence") pyblish.api.register_host("shell") os.environ["PYPE_PUBLISH_DATA"] = os.pathsep.join(paths) log.info("Running publish ...") # Error exit as soon as any error occurs. error_format = "Failed {plugin.__name__}: {error} -- {error.traceback}" for result in pyblish.util.publish_iter(): if result["error"]: log.error(error_format.format(**result)) uninstall() sys.exit(1) log.info("Publish finished.") uninstall()
#!/usr/bin/env python import time from pype.hosts.resolve.utils import get_resolve_module from pype.api import Logger log = Logger().get_logger(__name__) wait_delay = 2.5 wait = 0.00 ready = None while True: try: # Create project and set parameters: resolve = get_resolve_module() pm = resolve.GetProjectManager() if pm: ready = None else: ready = True except AttributeError: pass if ready is None: time.sleep(wait_delay) log.info(f"Waiting {wait}s for Resolve to have opened Project Manager") wait += wait_delay else: print(f"Preloaded variables: \n\n\tResolve module: " f"`resolve` > {type(resolve)} \n\tProject manager: " f"`pm` > {type(pm)}") break
from .menu import (install as menu_install, _update_menu_task_label) from .events import register_hiero_events __all__ = [ # Workfiles API "open_file", "save_file", "current_file", "has_unsaved_changes", "file_extensions", "work_root", ] # get logger log = Logger().get_logger(__name__, "nukestudio") ''' Creating all important host related variables ''' AVALON_CONFIG = os.getenv("AVALON_CONFIG", "pype") # plugin root path PUBLISH_PATH = os.path.join(PLUGINS_DIR, "nukestudio", "publish") LOAD_PATH = os.path.join(PLUGINS_DIR, "nukestudio", "load") CREATE_PATH = os.path.join(PLUGINS_DIR, "nukestudio", "create") INVENTORY_PATH = os.path.join(PLUGINS_DIR, "nukestudio", "inventory") # registering particular pyblish gui but `lite` is recomended!! if os.getenv("PYBLISH_GUI", None): pyblish.register_gui(os.getenv("PYBLISH_GUI", None)) def install():
#! python3 """ Resolve's tools for setting environment """ import sys import os import shutil from . import HOST_DIR from pype.api import Logger log = Logger().get_logger(__name__) def get_resolve_module(): from pype.hosts import resolve # dont run if already loaded if resolve.api.bmdvr: log.info(("resolve module is assigned to " f"`pype.hosts.resolve.api.bmdvr`: {resolve.api.bmdvr}")) return resolve.api.bmdvr try: """ The PYTHONPATH needs to be set correctly for this import statement to work. An alternative is to import the DaVinciResolveScript by specifying absolute path (see ExceptionHandler logic) """ import DaVinciResolveScript as bmd except ImportError: if sys.platform.startswith("darwin"): expected_path = ("/Library/Application Support/Blackmagic Design"
class SocketThread(threading.Thread): """Thread that checks suprocess of storer of processor of events""" MAX_TIMEOUT = int(os.environ.get("PYPE_FTRACK_SOCKET_TIMEOUT", 45)) def __init__(self, name, port, filepath, additional_args=[]): super(SocketThread, self).__init__() self.log = Logger().get_logger(self.__class__.__name__) self.setName(name) self.name = name self.port = port self.filepath = filepath self.additional_args = additional_args self.sock = None self.subproc = None self.connection = None self._is_running = False self.finished = False self.mongo_error = False self._temp_data = {} def stop(self): self._is_running = False def run(self): self._is_running = True time_socket = time.time() # Create a TCP/IP socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock = sock # Bind the socket to the port - skip already used ports while True: try: server_address = ("localhost", self.port) sock.bind(server_address) break except OSError: self.port += 1 self.log.debug( "Running Socked thread on {}:{}".format(*server_address)) env = os.environ.copy() env["PYPE_PROCESS_MONGO_ID"] = str(Logger.mongo_process_id) # Pype executable (with path to start script if not build) args = get_pype_execute_args( # Add `run` command "run", self.filepath, *self.additional_args, str(self.port)) self.subproc = subprocess.Popen(args, env=env, stdin=subprocess.PIPE) # Listen for incoming connections sock.listen(1) sock.settimeout(1.0) while True: if not self._is_running: break try: connection, client_address = sock.accept() time_socket = time.time() connection.settimeout(1.0) self.connection = connection except socket.timeout: if (time.time() - time_socket) > self.MAX_TIMEOUT: self.log.error("Connection timeout passed. Terminating.") self._is_running = False self.subproc.terminate() break continue try: time_con = time.time() # Receive the data in small chunks and retransmit it while True: try: if not self._is_running: break data = None try: data = self.get_data_from_con(connection) time_con = time.time() except socket.timeout: if (time.time() - time_con) > self.MAX_TIMEOUT: self.log.error( "Connection timeout passed. Terminating.") self._is_running = False self.subproc.terminate() break continue except ConnectionResetError: self._is_running = False break self._handle_data(connection, data) except Exception as exc: self.log.error("Event server process failed", exc_info=True) finally: # Clean up the connection connection.close() if self.subproc.poll() is None: self.subproc.terminate() self.finished = True def get_data_from_con(self, connection): return connection.recv(16) def _handle_data(self, connection, data): if not data: return if data == b"MongoError": self.mongo_error = True connection.sendall(data)
class ClockifyModule: def __init__(self, main_parent=None, parent=None): self.log = Logger().get_logger(self.__class__.__name__, "PypeTray") self.main_parent = main_parent self.parent = parent self.clockapi = ClockifyAPI() self.message_widget = None self.widget_settings = ClockifySettings(main_parent, self) self.widget_settings_required = None self.thread_timer_check = None # Bools self.bool_thread_check_running = False self.bool_api_key_set = False self.bool_workspace_set = False self.bool_timer_run = False self.clockapi.set_master(self) self.bool_api_key_set = self.clockapi.set_api() def tray_start(self): if self.bool_api_key_set is False: self.show_settings() return self.bool_workspace_set = self.clockapi.workspace_id is not None if self.bool_workspace_set is False: return self.start_timer_check() self.set_menu_visibility() def process_modules(self, modules): if 'FtrackModule' in modules: actions_path = os.path.sep.join( [os.path.dirname(__file__), 'ftrack_actions']) current = os.environ.get('FTRACK_ACTIONS_PATH', '') if current: current += os.pathsep os.environ['FTRACK_ACTIONS_PATH'] = current + actions_path if 'AvalonApps' in modules: from launcher import lib actions_path = os.path.sep.join( [os.path.dirname(__file__), 'launcher_actions']) current = os.environ.get('AVALON_ACTIONS', '') if current: current += os.pathsep os.environ['AVALON_ACTIONS'] = current + actions_path if 'TimersManager' in modules: self.timer_manager = modules['TimersManager'] self.timer_manager.add_module(self) def start_timer_manager(self, data): self.start_timer(data) def stop_timer_manager(self): self.stop_timer() def timer_started(self, data): if hasattr(self, 'timer_manager'): self.timer_manager.start_timers(data) def timer_stopped(self): self.bool_timer_run = False if hasattr(self, 'timer_manager'): self.timer_manager.stop_timers() def start_timer_check(self): self.bool_thread_check_running = True if self.thread_timer_check is None: self.thread_timer_check = threading.Thread( target=self.check_running) self.thread_timer_check.daemon = True self.thread_timer_check.start() def stop_timer_check(self): self.bool_thread_check_running = True if self.thread_timer_check is not None: self.thread_timer_check.join() self.thread_timer_check = None def check_running(self): import time while self.bool_thread_check_running is True: bool_timer_run = False if self.clockapi.get_in_progress() is not None: bool_timer_run = True if self.bool_timer_run != bool_timer_run: if self.bool_timer_run is True: self.timer_stopped() elif self.bool_timer_run is False: actual_timer = self.clockapi.get_in_progress() if not actual_timer: continue actual_proj_id = actual_timer["projectId"] if not actual_proj_id: continue project = self.clockapi.get_project_by_id(actual_proj_id) if project and project.get("code") == 501: continue project_name = project["name"] actual_timer_hierarchy = actual_timer["description"] hierarchy_items = actual_timer_hierarchy.split("/") # Each pype timer must have at least 2 items! if len(hierarchy_items) < 2: continue task_name = hierarchy_items[-1] hierarchy = hierarchy_items[:-1] task_type = None if len(actual_timer.get("tags", [])) > 0: task_type = actual_timer["tags"][0].get("name") data = { "task_name": task_name, "hierarchy": hierarchy, "project_name": project_name, "task_type": task_type } self.timer_started(data) self.bool_timer_run = bool_timer_run self.set_menu_visibility() time.sleep(5) def stop_timer(self): self.clockapi.finish_time_entry() if self.bool_timer_run: self.timer_stopped() def signed_in(self): if hasattr(self, 'timer_manager'): if not self.timer_manager: return if not self.timer_manager.last_task: return if self.timer_manager.is_running: self.start_timer_manager(self.timer_manager.last_task) def start_timer(self, input_data): # If not api key is not entered then skip if not self.clockapi.get_api_key(): return actual_timer = self.clockapi.get_in_progress() actual_timer_hierarchy = None actual_project_id = None if actual_timer is not None: actual_timer_hierarchy = actual_timer.get("description") actual_project_id = actual_timer.get("projectId") # Concatenate hierarchy and task to get description desc_items = [val for val in input_data.get("hierarchy", [])] desc_items.append(input_data["task_name"]) description = "/".join(desc_items) # Check project existence project_name = input_data["project_name"] project_id = self.clockapi.get_project_id(project_name) if not project_id: self.log.warning( ("Project \"{}\" was not found in Clockify. Timer won't start." ).format(project_name)) msg = ( "Project <b>\"{}\"</b> is not in Clockify Workspace <b>\"{}\"</b>." "<br><br>Please inform your Project Manager.").format( project_name, str(self.clockapi.workspace)) self.message_widget = MessageWidget(self.main_parent, msg, "Clockify - Info Message") self.message_widget.closed.connect(self.on_message_widget_close) self.message_widget.show() return if (actual_timer is not None and description == actual_timer_hierarchy and project_id == actual_project_id): return tag_ids = [] task_tag_id = self.clockapi.get_tag_id(input_data["task_type"]) if task_tag_id is not None: tag_ids.append(task_tag_id) self.clockapi.start_time_entry(description, project_id, tag_ids=tag_ids) def on_message_widget_close(self): self.message_widget = None # Definition of Tray menu def tray_menu(self, parent_menu): # Menu for Tray App self.menu = QtWidgets.QMenu('Clockify', parent_menu) self.menu.setProperty('submenu', 'on') self.menu.setStyleSheet(style.load_stylesheet()) # Actions self.aShowSettings = QtWidgets.QAction("Settings", self.menu) self.aStopTimer = QtWidgets.QAction("Stop timer", self.menu) self.menu.addAction(self.aShowSettings) self.menu.addAction(self.aStopTimer) self.aShowSettings.triggered.connect(self.show_settings) self.aStopTimer.triggered.connect(self.stop_timer) self.set_menu_visibility() parent_menu.addMenu(self.menu) def show_settings(self): self.widget_settings.input_api_key.setText(self.clockapi.get_api_key()) self.widget_settings.show() def set_menu_visibility(self): self.aStopTimer.setVisible(self.bool_timer_run)
import os import pype from pype.api import Logger from .lib import AdobeRestApi, PUBLISH_PATHS log = Logger().get_logger("AdobeCommunicator") class AdobeCommunicator: rest_api_obj = None def __init__(self): self.rest_api_obj = None # Add "adobecommunicator" publish paths PUBLISH_PATHS.append(os.path.sep.join( [pype.PLUGINS_DIR, "adobecommunicator", "publish"] )) def tray_start(self): return def process_modules(self, modules): # Module requires RestApiServer rest_api_module = modules.get("RestApiServer") if not rest_api_module: log.warning( "AdobeCommunicator won't work without RestApiServer." ) return
import sys import signal import socket import datetime from pype.modules.ftrack.ftrack_server.ftrack_server import FtrackServer from pype.modules.ftrack.ftrack_server.lib import (SocketSession, ProcessEventHub, TOPIC_STATUS_SERVER) from pype.modules import ModulesManager from pype.api import Logger import ftrack_api log = Logger().get_logger("Event processor") subprocess_started = datetime.datetime.now() class SessionFactory: session = None def send_status(event): subprocess_id = event["data"].get("subprocess_id") if not subprocess_id: return if subprocess_id != os.environ["FTRACK_EVENT_SUB_ID"]: return
class TimersManager(metaclass=Singleton): """ Handles about Timers. Should be able to start/stop all timers at once. If IdleManager is imported then is able to handle about stop timers when user idles for a long time (set in presets). """ # Presetable attributes # - when timer will stop if idle manager is running (minutes) full_time = 15 # - how many minutes before the timer is stopped will popup the message message_time = 0.5 def __init__(self, tray_widget, main_widget): self.log = Logger().get_logger(self.__class__.__name__) self.modules = [] self.is_running = False self.last_task = None self.tray_widget = tray_widget self.main_widget = main_widget self.idle_man = None self.signal_handler = None self.widget_user_idle = WidgetUserIdle(self, tray_widget) def set_signal_times(self): try: full_time = int(self.full_time * 60) message_time = int(self.message_time * 60) self.time_show_message = full_time - message_time self.time_stop_timer = full_time return True except Exception: self.log.error("Couldn't set timer signals.", exc_info=True) def add_module(self, module): """ Adds module to context Module must have implemented methods: - ``start_timer_manager(data)`` - ``stop_timer_manager()`` """ self.modules.append(module) def start_timers(self, data): ''' :param data: basic information needed to start any timer :type data: dict ..note:: Dictionary "data" should contain: - project_name(str) - Name of Project - hierarchy(list/tuple) - list of parents(except project) - task_type(str) - task_name(str) Example: - to run timers for task in 'C001_BackToPast/assets/characters/villian/Lookdev BG' - input data should contain: .. code-block:: Python data = { 'project_name': 'C001_BackToPast', 'hierarchy': ['assets', 'characters', 'villian'], 'task_type': 'lookdev', 'task_name': 'Lookdev BG' } ''' if len(data['hierarchy']) < 1: self.log.error(( 'Not allowed action in Pype!!' ' Timer has been launched on task which is child of Project.')) return self.last_task = data for module in self.modules: module.start_timer_manager(data) self.is_running = True def restart_timers(self): if self.last_task is not None: self.start_timers(self.last_task) def stop_timers(self): if self.is_running is False: return self.widget_user_idle.bool_not_stopped = False self.widget_user_idle.refresh_context() for module in self.modules: module.stop_timer_manager() self.is_running = False def process_modules(self, modules): """ Gives ability to connect with imported modules from TrayManager. :param modules: All imported modules from TrayManager :type modules: dict """ if 'IdleManager' in modules: self.signal_handler = SignalHandler(self) if self.set_signal_times() is True: self.register_to_idle_manager(modules['IdleManager']) def time_callback(self, int_def): if not self.signal_handler: return if int_def == 0: self.signal_handler.signal_show_message.emit() elif int_def == 1: self.signal_handler.signal_change_label.emit() elif int_def == 2: self.signal_handler.signal_stop_timers.emit() def register_to_idle_manager(self, man_obj): self.idle_man = man_obj # Time when message is shown self.idle_man.add_time_callback(self.time_show_message, lambda: self.time_callback(0)) # Times when idle is between show widget and stop timers show_to_stop_range = range(self.time_show_message - 1, self.time_stop_timer) for num in show_to_stop_range: self.idle_man.add_time_callback(num, lambda: self.time_callback(1)) # Times when widget is already shown and user restart idle shown_and_moved_range = range(self.time_stop_timer - self.time_show_message) for num in shown_and_moved_range: self.idle_man.add_time_callback(num, lambda: self.time_callback(1)) # Time when timers are stopped self.idle_man.add_time_callback(self.time_stop_timer, lambda: self.time_callback(2)) def change_label(self): if self.is_running is False: return if not self.idle_man or self.widget_user_idle.bool_is_showed is False: return if self.idle_man.idle_time > self.time_show_message: value = self.time_stop_timer - self.idle_man.idle_time else: value = 1 + (self.time_stop_timer - self.time_show_message - self.idle_man.idle_time) self.widget_user_idle.change_count_widget(value) def show_message(self): if self.is_running is False: return if self.widget_user_idle.bool_is_showed is False: self.widget_user_idle.show()
import os import sys import re import subprocess import json import opentimelineio_contrib.adapters.ffmpeg_burnins as ffmpeg_burnins from pype.api import Logger, config import pype.lib log = Logger().get_logger("BurninWrapper", "burninwrap") ffmpeg_path = pype.lib.get_ffmpeg_tool_path("ffmpeg") ffprobe_path = pype.lib.get_ffmpeg_tool_path("ffprobe") FFMPEG = ( '{} -loglevel panic -i %(input)s %(filters)s %(args)s%(output)s' ).format(ffmpeg_path) FFPROBE = ( '{} -v quiet -print_format json -show_format -show_streams "%(source)s"' ).format(ffprobe_path) DRAWTEXT = ( "drawtext=text=\\'%(text)s\\':x=%(x)s:y=%(y)s:fontcolor=" "%(color)s@%(opacity).1f:fontsize=%(size)d:fontfile='%(font)s'" ) TIMECODE = ( "drawtext=timecode=\\'%(timecode)s\\':text=\\'%(text)s\\'" ":timecode_rate=%(fps).2f:x=%(x)s:y=%(y)s:fontcolor="
import os import time import datetime import threading from Qt import QtCore, QtWidgets, QtGui import ftrack_api from ..ftrack_server.lib import check_ftrack_url from ..ftrack_server import socket_thread from ..lib import credentials from ..ftrack_module import FTRACK_MODULE_DIR from . import login_dialog from pype.api import Logger, resources log = Logger().get_logger("FtrackModule") class FtrackTrayWrapper: def __init__(self, module): self.module = module self.thread_action_server = None self.thread_socket_server = None self.thread_timer = None self.bool_logged = False self.bool_action_server_running = False self.bool_action_thread_running = False self.bool_timer_event = False
import sys import json import threading import signal import socket import datetime import ftrack_api from ftrack_server import FtrackServer from pype.modules.ftrack.ftrack_server.lib import (SocketSession, StatusEventHub, TOPIC_STATUS_SERVER, TOPIC_STATUS_SERVER_RESULT) from pype.api import Logger, config log = Logger().get_logger("Event storer") action_identifier = ("event.server.status" + os.environ["FTRACK_EVENT_SUB_ID"]) host_ip = socket.gethostbyname(socket.gethostname()) action_data = { "label": "Pype Admin", "variant": "- Event server Status ({})".format(host_ip), "description": "Get Infromation about event server", "actionIdentifier": action_identifier, "icon": "{}/ftrack/action_icons/PypeAdmin.svg".format( os.environ.get( "PYPE_STATICS_SERVER",
import collections from Qt import QtCore, QtGui from pype.api import Logger from pypeapp.lib.log import _bootstrap_mongo_log, LOG_COLLECTION_NAME log = Logger().get_logger("LogModel", "LoggingModule") class LogModel(QtGui.QStandardItemModel): COLUMNS = ("process_name", "hostname", "hostip", "username", "system_name", "started") colums_mapping = { "process_name": "Process Name", "process_id": "Process Id", "hostname": "Hostname", "hostip": "Host IP", "username": "******", "system_name": "System name", "started": "Started at" } process_keys = ("process_id", "hostname", "hostip", "username", "system_name", "process_name") log_keys = ("timestamp", "level", "thread", "threadName", "message", "loggerName", "fileName", "module", "method", "lineNumber") default_value = "- Not set -" ROLE_LOGS = QtCore.Qt.UserRole + 2 ROLE_PROCESS_ID = QtCore.Qt.UserRole + 3 def __init__(self, parent=None): super(LogModel, self).__init__(parent)
"""A module containing generic loader actions that will display in the Loader. """ from avalon import api from pype.api import Logger log = Logger().get_logger(__name__, "nuke") class SetFrameRangeLoader(api.Loader): """Specific loader of Alembic for the avalon.animation family""" families = ["animation", "camera", "write", "yeticache", "pointcache"] representations = ["*"] label = "Set frame range" order = 11 icon = "clock-o" color = "white" def load(self, context, name, namespace, data): from pype.nuke import lib version = context['version'] version_data = version.get("data", {})
class IdleManager(threading.Thread): """ Measure user's idle time in seconds. Idle time resets on keyboard/mouse input. Is able to emit signals at specific time idle. """ time_callbacks = collections.defaultdict(list) idle_time = 0 def __init__(self): super(IdleManager, self).__init__() self.log = Logger().get_logger(self.__class__.__name__) self.qaction = None self.failed_icon = None self._is_running = False self.threads = [] def set_qaction(self, qaction, failed_icon): self.qaction = qaction self.failed_icon = failed_icon def tray_start(self): self.start() def tray_exit(self): self.stop() try: self.time_callbacks = {} except Exception: pass def add_time_callback(self, emit_time, callback): """If any module want to use IdleManager, need to use this method. Args: emit_time(int): Time when callback will be triggered. callback(func): Callback that will be triggered. """ self.time_callbacks[emit_time].append(callback) @property def is_running(self): return self._is_running def _reset_time(self): self.idle_time = 0 def stop(self): self._is_running = False def run(self): self.log.info('IdleManager has started') self._is_running = True thread_mouse = MouseThread(self._reset_time) thread_mouse.start() thread_keyboard = KeyboardThread(self._reset_time) thread_keyboard.start() try: while self.is_running: if self.idle_time in self.time_callbacks: for callback in self.time_callbacks[self.idle_time]: thread = threading.Thread(target=callback) thread.start() self.threads.append(thread) for thread in tuple(self.threads): if not thread.isAlive(): thread.join() self.threads.remove(thread) self.idle_time += 1 time.sleep(1) except Exception: self.log.warning( 'Idle Manager service has failed', exc_info=True ) if self.qaction and self.failed_icon: self.qaction.setIcon(self.failed_icon) # Threads don't have their attrs when Qt application already finished try: thread_mouse.stop() thread_mouse.join() except AttributeError: pass try: thread_keyboard.stop() thread_keyboard.join() except AttributeError: pass self._is_running = False self.log.info('IdleManager has stopped')