def __init__(self, runtime_env, ini_file="config.ini", os=None): self.logger = Logger(log_level=0, console_level=3) self.sts = Settings(self.logger, runtime_env, ini_file=ini_file) # sts self.logger.set_console_level(self.sts.debug_level) self.logger.set_log_level(0) self.comfun = CommonFunctions(self.logger) if os is None: self.os = platform.system() if self.os == "Windows": self.os = "w" elif self.os == "Linux": self.os = "l" else: self.os = None # abbreviation for very often used variables, helping with identification the main modules self.usr = Users(self) # usr self.prj = Projects(self) # prj self.sch = Schemas(self) # sch self.tsk = Tasks(self) # tsk self.que = Queue(self) # que self.nod = SimNodes(self) # nod self.dfn = Definitions(self) # dfn self.sio = StorageInOut(self) # sio # abbreviation END self.logger.inf("SimBatch started")
def __init__(self, project_id, project_name, is_default, state_id, state, project_directory, working_directory, cameras_directory, cache_directory, env_directory, props_directory, scripts_directory, custom_directory, seq_shot_take_pattern, description, zeros_in_version=3): self.comfun = CommonFunctions() self.id = project_id self.project_name = project_name self.project_directory = self.comfun.get_proper_path(project_directory, info="proj dir") self.working_directory = self.comfun.get_proper_path(working_directory, info="wrk dir") self.cameras_directory = self.comfun.get_proper_path(cameras_directory, info="cam dir") self.cache_directory = self.comfun.get_proper_path(cache_directory, info="ani cache dir") self.env_directory = self.comfun.get_proper_path(env_directory, info="env dir") self.props_directory = self.comfun.get_proper_path(props_directory, info="props dir") self.scripts_directory = self.comfun.get_proper_path(scripts_directory, info="scripts dir") self.custom_directory = self.comfun.get_proper_path(custom_directory, info="custom dir") self.working_directory_absolute = "" self.cameras_directory_absolute = "" self.cache_directory_absolute = "" self.env_directory_absolute = "" self.props_directory_absolute = "" self.scripts_directory_absolute = "" self.custom_directory_absolute = "" # self.frame_range_directory_absolute = self.working_directory_absolute + "\\frame_range\\" # TODO frame range self.is_default = is_default if state_id == 0: state_id = self.DEF_STATE_ID_FOR_NEW_PROJ state = self.DEF_STATE_FOR_NEW_PROJ self.state_id = state_id self.state = state self.seq_shot_take_pattern = seq_shot_take_pattern self.zeros_in_version = zeros_in_version self.description = description self.update_absolute_directories()
def __init__(self, logger, runtime_env, ini_file="config.ini", force_os=False): self.logger = logger if force_os is False: if os.name == "posix": self.current_os = 1 else: self.current_os = 2 else: self.current_os = force_os if self.current_os == 1: self.dir_separator = "/" else: self.dir_separator = "\\" self.runtime_env = runtime_env self.ini_file = ini_file self.comfun = CommonFunctions() self.sql = [None, None, None, None] self.clear_state_colors() self.load_settings() if self.loading_state >= 3: if self.WITH_GUI == 1: self.update_ui_colors() else: print " [WRN] Settings not loaded !!!", self.loading_state
def __init__(self, logger, runtime_env, ini_file="config.ini", force_os=False): self.logger = logger if force_os is False: if os.name == "posix": self.current_os = 1 else: self.current_os = 2 else: self.current_os = force_os if self.current_os == 1: self.dir_separator = "/" else: self.dir_separator = "\\" self.store_abs_dir = os.path.abspath( "" ) + self.dir_separator # os.path.dirname(os.path.realpath(__file__)) self.comfun = CommonFunctions() self.runtime_env = runtime_env if self.comfun.is_absolute(ini_file): self.ini_file = ini_file else: self.ini_file = os.path.abspath(ini_file) """ check and force DEV config """ if self.comfun.file_exists( os.path.join(os.path.dirname(self.ini_file), "config_dev.ini")): self.ini_file = os.path.join(os.path.dirname(self.ini_file), "config_dev.ini") self.logger.inf(("force DEV config:", self.ini_file)) self.sql = [None, None, None, None] self.clear_state_colors() self.load_settings() if self.loading_state >= 4: if self.WITH_GUI == 1: self.update_ui_colors() else: self.logger.wrn(("Settings not loaded !!!", self.loading_state))
def __init__(self, logger, runtime_env, ini_path="", ini_file="", force_os=False): self.logger = logger if force_os is False: if os.name == "posix": self.current_os = 1 else: self.current_os = 2 else: self.current_os = force_os if self.current_os == 1: self.dir_separator = "/" else: self.dir_separator = "\\" """ STANDALONE """ self.store_abs_dir = (os.path.dirname( os.path.dirname(os.path.abspath(__file__)))) + self.dir_separator """ MAYA win C:\Program Files\Autodesk\Maya2014\ """ # TODO check abs self.comfun = CommonFunctions(self.logger) self.runtime_env = runtime_env if runtime_env == "Server": self.with_gui = 0 self.ini_file = self.get_ini_file_and_path(ini_path, ini_file) """ check and force DEV config """ if self.comfun.file_exists(os.path.join(os.path.dirname(self.ini_file), "config_dev.ini"), info=False): self.ini_file = os.path.join(os.path.dirname(self.ini_file), "config_dev.ini") self.logger.inf(("force DEV config:", self.ini_file), nl=True) self.sql = [None, None, None, None] self.load_settings() if self.loading_state < 4: self.logger.err("Data not loaded !!! ({})".format( self.loading_state))
class Settings: logger = None # logger prints errors, warnings, info and db to console and to log file ini_file = None # fundamental config file, json format loading_state = 0 # check fundamental config.ini settings_err_info = "" # store last err/wrn when loading config.ini json_settings_data = None # basic config data # fundamental settings (config.ini) current_os = -1 # 1 Linux, 2 windoza detected on __init__ or forced by force_os dir_separator = "" # set on __init__ depend on current_os store_data_mode = None # 1 json 2 MySQL (PRO version) debug_level = None # 1 only ERR, 2 +WRN, 3 +INF, 4 +important [db], 5 +[db], 6 ALL store_data_json_directory = None # dir basic config settings (def:config.ini) store_data_json_directory_abs = None # dir basic config settings (def:config.ini) store_data_backup_directory = None # dir backup data store_data_backup_directory_abs = None # dir backup data store_definitions_directory = None # dir with software, actions, engines and param definitions store_definitions_directory_abs = None # dir with software, actions, engines and param definitions store_abs_dir = "" # sql = [None, None, None, None] # "db" "pass" "port" "user" (PRO version) admin_user = None # PRO version # predefined settings SIMBATCH_VERSION = "v0.2.30" # current version JSON_PROJECTS_FILE_NAME = "data_projects.json" JSON_SCHEMAS_FILE_NAME = "data_schemas.json" JSON_TASKS_FILE_NAME = "data_tasks.json" JSON_QUEUE_FILE_NAME = "data_queue.json" JSON_SIMNODES_FILE_NAME = "data_simnodes.json" states_visible_names = {} INDEX_STATE_NULL = 0 INDEX_STATE_INIT = 1 INDEX_STATE_WAITING = 2 INDEX_STATE_QUEUED = 3 INDEX_STATE_WORKING = 4 INDEX_STATE_SIM = 5 INDEX_STATE_CACHE = 6 INDEX_STATE_RENDER = 7 INDEX_STATE_HOLD = 8 INDEX_STATE_ERROR = 9 INDEX_STATE_OK = 10 INDEX_STATE_DONE = 11 INDEX_STATE_REVIEW = 12 INDEX_STATE_ACCEPTED = 13 INDEX_STATE_REJECTED = 14 INDEX_STATE_CUSTOM = 18 INDEX_STATE_OFFLINE = 19 INDEX_STATE_INACTIVE = 20 INDEX_STATE_SUSPEND = 21 INDEX_STATE_ACTIVE = 22 INDEX_STATE_DEFAULT = 23 states_visible_names[INDEX_STATE_NULL] = "NULL" states_visible_names[INDEX_STATE_INIT] = "INIT" states_visible_names[INDEX_STATE_WAITING] = "WAITING" states_visible_names[INDEX_STATE_QUEUED] = "QUEUED" states_visible_names[INDEX_STATE_WORKING] = "WORKING" states_visible_names[INDEX_STATE_SIM] = "SIM" states_visible_names[INDEX_STATE_CACHE] = "CACHE" states_visible_names[INDEX_STATE_RENDER] = "RENDER" states_visible_names[INDEX_STATE_ERROR] = "ERROR" states_visible_names[INDEX_STATE_HOLD] = "HOLD" states_visible_names[INDEX_STATE_OK] = "OK" states_visible_names[INDEX_STATE_DONE] = "DONE" states_visible_names[INDEX_STATE_REVIEW] = "REVIEW" states_visible_names[INDEX_STATE_ACCEPTED] = "ACCEPTED" states_visible_names[INDEX_STATE_REJECTED] = "REJECTED" states_visible_names[INDEX_STATE_CUSTOM] = "CUSTOM" states_visible_names[INDEX_STATE_OFFLINE] = "OFFLINE" states_visible_names[INDEX_STATE_INACTIVE] = "INACTIVE" states_visible_names[ INDEX_STATE_SUSPEND] = "SUSPEND" # TODO decide SUSPEND or SUSPENDED ? states_visible_names[INDEX_STATE_ACTIVE] = "ACTIVE" states_visible_names[INDEX_STATE_DEFAULT] = "DEFAULT" # GUI settings runtime_env = "" # runtime environment as software name display on frame and set active definition ui_edition_mode = 0 # 0 open source 1 Pro version (with Wizard tab as first) ui_color_mode = 1 # color palette 1 gray, 2 pastel, 3 dark, 4 custom ui_brightness_mode = 1 # 0 dark mode 1 light mode state_colors = [] # item list colors state_colors_up = [] # selected item list colors window = None # store def window position always_on_top = False # obvious obviousness force_start_tab = 0 # if > 0 show tab with this index after run # check screen resolution: protect window position (outside screen if second monitor is off) CHECK_SCREEN_RES_ON_START = 1 WITH_GUI = 1 # loading color schema # TODO auto detect COLORS_PASTEL_FILE_NAME = "colors_pastel.ini" COLORS_CUSTOM_FILE_NAME = "colors_custom.ini" COLORS_GRAY_FILE_NAME = "colors_gray.ini" COLORS_DARK_FILE_NAME = "colors_dark.ini" default_settings = { "! json info": { "config": "this is fundamental config file", "format": "more about format: http://json.org" }, "dataMode": { "current": 1, "modes": "1-json, 2-MySQL" }, "colorMode": { "current": 2, "levels": "1 gray, 2 pastel, 3 dark, 4 custom " }, "debugLevel": { "current": 4, "levels": "1 only ERR, 2 +WRN, 3 +INF, 4 +important [db], 5 +[db], 6 ALL " }, "storeData": { "dataDirectory": "/server/simbatch/dataDir/", "backupDirectory": "/server/simbatch/backups/", "definitionsDirectory": "/server/simbatch/definitions/" }, "sql": { "db": "127.0.1.220", "user": "******", "pass": "******", "port": "3306" }, "adminUser": { "name": "admin", "sign": "A", "pass": "******" }, "window": { "posX": 70, "posY": 150, "sizeX": 600, "sizeY": 800, "alwaysOnTop": False } } def __init__(self, logger, runtime_env, ini_file="config.ini", force_os=False): self.logger = logger if force_os is False: if os.name == "posix": self.current_os = 1 else: self.current_os = 2 else: self.current_os = force_os if self.current_os == 1: self.dir_separator = "/" else: self.dir_separator = "\\" self.store_abs_dir = os.path.abspath( "" ) + self.dir_separator # os.path.dirname(os.path.realpath(__file__)) self.comfun = CommonFunctions() self.runtime_env = runtime_env if self.comfun.is_absolute(ini_file): self.ini_file = ini_file else: self.ini_file = os.path.abspath(ini_file) """ check and force DEV config """ if self.comfun.file_exists( os.path.join(os.path.dirname(self.ini_file), "config_dev.ini")): self.ini_file = os.path.join(os.path.dirname(self.ini_file), "config_dev.ini") self.logger.inf(("force DEV config:", self.ini_file)) self.sql = [None, None, None, None] self.clear_state_colors() self.load_settings() if self.loading_state >= 4: if self.WITH_GUI == 1: self.update_ui_colors() else: self.logger.wrn(("Settings not loaded !!!", self.loading_state)) def print_all(self): print " loading_state: ", self.loading_state print " ini_file: ", self.ini_file print " runtime_env: ", self.runtime_env if self.json_settings_data is not None: if "dataMode" in self.json_settings_data: print " json_settings_data[dataMode][current]: ", self.json_settings_data[ "dataMode"]["current"] else: self.logger.err( ("MISSING dataMode KEY IN SETTINGS FILE:", self.ini_file)) if "colorMode" in self.json_settings_data: print " json_settings_data[colorMode][current]: ", self.json_settings_data[ "colorMode"]["current"] else: self.logger.err( ("MISSING colorMode KEY IN SETTINGS FILE:", self.ini_file)) if "debugLevel" in self.json_settings_data: print " json_settings_data[debugLevel][current]: ", self.json_settings_data[ "debugLevel"]["current"] else: self.logger.err(("MISSING debugLevel KEY IN SETTINGS FILE:", self.ini_file)) if "window" in self.json_settings_data: print " json_settings_data[window]: ", self.json_settings_data[ "window"] else: self.logger.err( ("MISSING window KEY IN SETTINGS FILE:", self.ini_file)) print " store_data_mode: ", self.store_data_mode print " debug_level: ", self.debug_level print " store_data_json_directory: ", self.store_data_json_directory if self.store_data_json_directory != self.store_data_json_directory_abs: print " store_data_json_directory_abs: ", self.store_data_json_directory_abs print " store_data_backup_directory: ", self.store_data_backup_directory if self.store_data_backup_directory != self.store_data_backup_directory_abs: print " store_data_backup_directory_abs: ", self.store_data_backup_directory_abs print " store_definitions_directory: ", self.store_definitions_directory if self.store_definitions_directory != self.store_definitions_directory_abs: print " store_definitions_directory_abs: ", self.store_definitions_directory_abs print " sql settings: ", self.sql print " admin_user: "******" window:", self.window print "\n\n" @staticmethod def random_welcome_message(): messages = ("Welcome", "Have a nice sim!", "Sim, Forrest, sim!") rand = randint(0, len(messages) - 1) return messages[rand] def clear_state_colors(self): self.state_colors = [] self.state_colors_up = [] for i in range(0, 40): self.state_colors.append(QBrush(QColor.fromRgb(40, 40, 40, a=255))) self.state_colors_up.append( QBrush(QColor.fromRgb(140, 140, 140, a=255))) def update_absolute_directories(self): data_path = self.store_data_json_directory if len(data_path) == 0: self.store_data_json_directory_abs = "" else: if self.comfun.is_absolute(data_path): if data_path[-1:] == "\\" or data_path[-1:] == "/": self.store_data_json_directory_abs = data_path self.store_data_backup_directory_abs = data_path + "backup" + self.dir_separator else: self.store_data_json_directory = data_path + self.dir_separator self.store_data_json_directory_abs = data_path + self.dir_separator self.store_data_backup_directory_abs = data_path + self.dir_separator + "backup" + \ self.dir_separator else: if data_path[-1:] == "\\" or data_path[-1:] == "/": self.store_data_json_directory_abs = self.store_abs_dir + data_path self.store_data_backup_directory_abs = self.store_abs_dir + data_path + "backup" + \ self.dir_separator else: self.store_data_json_directory_abs = self.store_abs_dir + data_path + self.dir_separator self.store_data_backup_directory_abs = self.store_abs_dir + data_path + self.dir_separator + \ "backup" + self.dir_separator definitions_path = self.store_definitions_directory if len(definitions_path) == 0: self.store_definitions_directory_abs = "" else: if self.comfun.is_absolute(definitions_path): if definitions_path[-1:] == "\\" or definitions_path[ -1:] == "/": self.store_definitions_directory_abs = definitions_path else: self.store_definitions_directory = definitions_path + self.dir_separator self.store_definitions_directory_abs = definitions_path + self.dir_separator else: if definitions_path[-1:] == "\\" or definitions_path[ -1:] == "/": self.store_definitions_directory_abs = self.store_abs_dir + self.store_definitions_directory else: self.store_definitions_directory_abs = self.store_abs_dir + self.store_definitions_directory + \ self.dir_separator def load_settings(self): self.settings_err_info = "" if self.comfun.file_exists(self.ini_file, info="settings init"): self.loading_state = 1 with open(self.ini_file) as f: self.json_settings_data = json.load(f) ret = self.check_data_integration() if ret: self.debug_level = self.json_settings_data["debugLevel"][ "current"] self.store_data_mode = self.json_settings_data["dataMode"][ "current"] self.ui_color_mode = self.json_settings_data["colorMode"][ "current"] self.store_data_json_directory = self.json_settings_data[ "storeData"]["dataDirectory"] self.store_data_backup_directory = self.json_settings_data[ "storeData"]["backupDirectory"] self.store_definitions_directory = self.json_settings_data[ "storeData"]["definitionsDirectory"] self.update_absolute_directories() s1 = self.json_settings_data["sql"]["db"] s2 = self.json_settings_data["sql"]["user"] s3 = self.json_settings_data["sql"]["pass"] s4 = self.json_settings_data["sql"]["port"] # self.sql = self.json_settings_data["sql"].values() self.sql = (s1, s2, s3, s4) self.admin_user = self.json_settings_data[ "adminUser"].values() # TODO order values() wnd = self.json_settings_data["window"] self.window = [ wnd["posX"], wnd["posY"], wnd["sizeX"], wnd["sizeY"] ] self.always_on_top = wnd["alwaysOnTop"] if "startup" in self.json_settings_data.keys(): if "tab" in self.json_settings_data["startup"].keys(): self.force_start_tab = self.json_settings_data[ "startup"]["tab"] self.logger.inf( "forced startup tab index: {}".format( self.force_start_tab)) if self.comfun.int_or_val(self.store_data_mode, 0): if self.store_data_mode == 1: if self.comfun.path_exists( self.store_data_json_directory_abs ) is False: if len(self.store_data_json_directory_abs ) == 0: self.settings_err_info = "Data directory not defined!" else: self.settings_err_info = "Data directory not exists!" elif self.comfun.path_exists( self.store_definitions_directory_abs ) is False: if len(self.store_definitions_directory_abs ) == 0: self.settings_err_info = "Definitions directory not defined!" else: self.settings_err_info = "Definitions directory not exists!" else: """ SETTINGS VALUES ARE OK""" self.loading_state = 4 if self.debug_level >= 3: print "\n\n [INF] settings loaded ", self.ini_file return True elif self.store_data_mode == 2: # PRO VERSION self.loading_state = 3 self.settings_err_info = "MySQL will be supported with the PRO version" else: self.loading_state = 3 self.settings_err_info = "Store data mode: {} incorrect value".format( self.store_data_mode) else: print " [WRN] json data inconsistency:", self.ini_file self.loading_state = 2 else: self.settings_err_info = " [ERR] config.ini file not exists: {}".format( self.ini_file) self.loading_state = -1 print self.settings_err_info return False def save_settings(self, settings_file=""): comfun = self.comfun data_path = self.store_data_json_directory_abs self.default_settings["dataMode"]["current"] = self.store_data_mode self.default_settings["colorMode"]["current"] = self.ui_color_mode self.default_settings["debugLevel"]["current"] = self.debug_level self.default_settings["storeData"][ "dataDirectory"] = self.store_data_json_directory self.default_settings["storeData"][ "backupDirectory"] = self.store_data_backup_directory self.default_settings["storeData"][ "definitionsDirectory"] = self.store_definitions_directory self.default_settings["sql"]["db"] = self.sql[0] # PRO VERSION self.default_settings["sql"]["user"] = self.sql[1] # PRO VERSION self.default_settings["sql"]["pass"] = self.sql[2] # PRO VERSION self.default_settings["sql"]["port"] = self.sql[3] # PRO VERSION self.default_settings["window"]["posX"] = self.window[0] self.default_settings["window"]["posY"] = self.window[1] self.default_settings["window"]["sizeX"] = self.window[2] self.default_settings["window"]["sizeY"] = self.window[3] self.default_settings["window"]["alwaysOnTop"] = self.always_on_top if len(settings_file) == 0: settings_file = self.ini_file # JSON format comfun.save_to_file( settings_file, json.dumps(self.default_settings, indent=2, sort_keys=True)) print ' [INF] settings saved to: ', settings_file if self.store_data_mode == 1: if comfun.file_exists(data_path + self.JSON_PROJECTS_FILE_NAME) is False: comfun.create_empty_file(data_path + self.JSON_PROJECTS_FILE_NAME) if comfun.file_exists(data_path + self.JSON_SCHEMAS_FILE_NAME) is False: comfun.create_empty_file(data_path + self.JSON_SCHEMAS_FILE_NAME) if comfun.file_exists(data_path + self.JSON_TASKS_FILE_NAME) is False: comfun.create_empty_file(data_path + self.JSON_TASKS_FILE_NAME) if comfun.file_exists(data_path + self.JSON_QUEUE_FILE_NAME) is False: comfun.create_empty_file(data_path + self.JSON_QUEUE_FILE_NAME) if comfun.file_exists(data_path + self.JSON_SIMNODES_FILE_NAME) is False: comfun.create_empty_file(data_path + self.JSON_SIMNODES_FILE_NAME) def check_data_integration(self): # out = json.dumps(self.json_settings_data, indent=2) TODO cleanup jd = self.json_settings_data json_keys = [ "dataMode", "debugLevel", "storeData", "sql", "adminUser", "window" ] errors = 0 if self.json_settings_data is not None: for k in json_keys: if (k in jd) is False: print " [ERR] missing key:", k errors += 1 else: return False if errors == 0: return True else: return False def update_ui_colors(self): if self.store_definitions_directory_abs is not None: palette_id = self.ui_color_mode if palette_id == 1: color_file = self.store_definitions_directory_abs + "colors/" + self.COLORS_GRAY_FILE_NAME elif palette_id == 2: color_file = self.store_definitions_directory_abs + "colors/" + self.COLORS_PASTEL_FILE_NAME elif palette_id == 3: color_file = self.store_definitions_directory_abs + "colors/" + self.COLORS_DARK_FILE_NAME else: # palette_id == 4: color_file = self.store_definitions_directory_abs + "colors/" + self.COLORS_CUSTOM_FILE_NAME if self.comfun.file_exists(color_file, info="colors file"): self.clear_state_colors() f = open(color_file, 'r') for li_counter, line in enumerate(f.readlines()): li = line.split(";") if len(li) > 7: self.state_colors[li_counter] = QBrush( QColor.fromRgb(self.comfun.int_or_val(li[2], 40), self.comfun.int_or_val(li[3], 40), self.comfun.int_or_val(li[4], 40), a=255)) self.state_colors_up[li_counter] = QBrush( QColor.fromRgb(self.comfun.int_or_val(li[6], 140), self.comfun.int_or_val(li[7], 140), self.comfun.int_or_val(li[8], 140), a=255)) f.close() if self.debug_level >= 3: print " [INF] loaded colors: ", color_file return True else: for i in range(0, 40): self.state_colors.append( QBrush(QColor.fromRgb(40, 40, 40, a=255))) self.state_colors_up.append( QBrush(QColor.fromRgb(140, 140, 140, a=255))) if self.debug_level >= 3: print " [WRN] not loaded colors: ", color_file return False else: # TODO dblvl print " [WRN] store_definitions_directory is None" return False
class SimBatch: s = None comfun = None logger = None os = None def __init__(self, runtime_env, ini_file="config.ini", os=None): self.logger = Logger(log_level=0, console_level=3) self.sts = Settings(self.logger, runtime_env, ini_file=ini_file) # sts self.logger.set_console_level(self.sts.debug_level) self.logger.set_log_level(0) self.comfun = CommonFunctions(self.logger) if os is None: self.os = platform.system() if self.os == "Windows": self.os = "w" elif self.os == "Linux": self.os = "l" else: self.os = None # abbreviation for very often used variables, helping with identification the main modules self.usr = Users(self) # usr self.prj = Projects(self) # prj self.sch = Schemas(self) # sch self.tsk = Tasks(self) # tsk self.que = Queue(self) # que self.nod = SimNodes(self) # nod self.dfn = Definitions(self) # dfn self.sio = StorageInOut(self) # sio # abbreviation END self.logger.inf("SimBatch started") def print_data(self): self.prj.print_all() def print_important_values(self): print " \n\n Current runtime_env: {}", self.sts.runtime_env # projects print "\n PROJECTS: " self.prj.print_current() # schemas print "\n SCHEMAS: " self.sch.print_current() # tasks print "\n TASKS: " self.tsk.print_current() # queue print "\n QUEUE: " self.que.print_current() # nodes print "\n NODES: " self.nod.print_current() # nodes print "\n DEFINITIONS: " self.dfn.print_current() print "\n\n" def print_current_detailed_values(self, index): print " \n\n" if self.sts.ui_edition_mode == 0: # open source hide wizard tab index += 1 # index compensation if index == 0: print " WIZARD: " if index == 1: self.prj.print_all() self.prj.print_current() if index == 2: print " SCHEMAS: " self.sch.print_all() self.sch.print_current() if index == 3: print " TASKS: " self.tsk.print_all() self.tsk.print_current() if index == 4: print " QUEUE: " self.que.print_all() self.que.print_current() # if index == 5: # TODO NODES !!!! # self.nod.print_all() # self.nod.print_current() if index == 5: # TODO NODES index 4 vs 5 ! print " SETTINGS: " self.sts.print_all() print "\n\n" def clear_all_stored_data(self): self.prj.clear_all_projects_data(clear_stored_data=True) self.sch.clear_all_schemas_data(clear_stored_data=True) def clear_all_memory_data(self): self.prj.clear_all_projects_data() self.sch.clear_all_schemas_data() def loading_errors(self, check_this, counter, msg): if self.comfun.is_int(check_this): counter += check_this self.logger.err( "Loading error! File: ({}) file errors count:{}".format( msg, check_this)) return counter def load_data(self): if self.sts.loading_state >= 3: ret_def = self.dfn.load_definitions() ret_prj = self.prj.load_projects() if ret_prj is not False: self.prj.init_default_proj() ret_sch = self.sch.load_schemas() if ret_sch is not False: ret_tsk = self.tsk.load_tasks() if ret_tsk is not False: ret_que = self.que.load_queue() if ret_que is not False: ret_nod = self.nod.load_nodes() if ret_tsk is not False: loading_err_count = 0 # count number errors while of loading external data loading_err_count = self.loading_errors( ret_def, loading_err_count, "definitions") loading_err_count = self.loading_errors( ret_prj, loading_err_count, "project") loading_err_count = self.loading_errors( ret_sch, loading_err_count, "schemas") loading_err_count = self.loading_errors( ret_tsk, loading_err_count, "tasks") if loading_err_count == 0: return True else: return loading_err_count else: return -5 else: return -4 else: return -1 else: return -2 else: return -3 else: return False def create_example_data(self): self.prj.create_example_project_data()
class SimBatch: s = None comfun = None logger = None os = None def __init__(self, runtime_env, ini_file="config.ini", os=None): self.logger = Logger(log_level=0, console_level=3) self.sts = Settings(self.logger, runtime_env, ini_file=ini_file) # sts self.logger.set_console_level(self.sts.debug_level) self.logger.set_log_level(0) self.comfun = CommonFunctions(self.logger) if os is None: self.os = platform.system() if self.os == "Windows": self.os = "w" elif self.os == "Linux": self.os = "l" else: self.os = None # abbreviation for very often used variables, helping with identification the main modules self.usr = Users( self, mode=1) # usr """ users are fully implemented in Pro version """ self.prj = Projects(self) # prj self.sch = Schemas(self) # sch self.tsk = Tasks(self) # tsk self.que = Queue(self) # que self.nod = SimNodes(self) # nod self.dfn = Definitions(self) # dfn self.sio = StorageInOut(self) # sio self.pat = Patterns() # pat # abbreviation END self.logger.inf("SimBatch {} started".format(self.sts.get_version()), nl=True, nl_after=True) def print_data(self): self.prj.print_all() def print_important_values(self): print " \n\n Current runtime_env: {}".format(self.sts.runtime_env) # projects print "\n PROJECTS: " self.prj.print_current() # schemas print "\n SCHEMAS: " self.sch.print_current() # tasks print "\n TASKS: " self.tsk.print_current() # queue print "\n QUEUE: " self.que.print_current() # nodes print "\n NODES: " self.nod.print_current() # nodes print "\n DEFINITIONS: " self.dfn.print_current() print "\n\n" def print_current_detailed_values(self, index): print " \n\n" if self.sts.ui_edition_mode == 0: # open source no wizard tab index += 1 # index compensation if index == 0: print " WIZARD: " if index == 1: print " PROJECTS: " self.prj.print_all() self.prj.print_current() if index == 2: print " SCHEMAS: " self.sch.print_all() self.sch.print_current() if index == 3: print " TASKS: " self.tsk.print_all() self.tsk.print_current() if index == 4: print " QUEUE: " self.que.print_all() self.que.print_current() if index == 5: print " SIMNODES: " self.nod.print_all() self.nod.print_current() if index == 6: print " DEFINITIONS: " self.dfn.print_all() self.dfn.print_current() if index == 7: print " SETTINGS: " self.sts.print_all() print "\n\n" def clear_all_stored_data(self): self.prj.clear_all_projects_data(clear_stored_data=True) self.sch.clear_all_schemas_data(clear_stored_data=True) def clear_all_memory_data(self): self.prj.clear_all_projects_data() self.sch.clear_all_schemas_data() def loading_errors(self, check_this, counter, msg): if self.comfun.is_int(check_this): counter += check_this self.logger.err( "Loading error! File: ({}) file errors count:{}".format( msg, check_this)) return counter def load_data(self): if self.sts.loading_state >= 4: ret_def = self.dfn.load_definitions() if self.sio.check_any_data_to_load_exist(): ret_prj = self.prj.load_projects() if ret_prj is not False: self.prj.init_default_proj() ret_sch = self.sch.load_schemas() if ret_sch is not False: ret_tsk = self.tsk.load_tasks() if ret_tsk is not False: ret_que = self.que.load_queue() if ret_que is not False: ret_nod = self.nod.load_nodes() if ret_nod is not False: loading_err_count = 0 # count number errors while of loading external data loading_err_count = self.loading_errors( ret_def, loading_err_count, "definitions") loading_err_count = self.loading_errors( ret_prj, loading_err_count, "project") loading_err_count = self.loading_errors( ret_sch, loading_err_count, "schemas") loading_err_count = self.loading_errors( ret_tsk, loading_err_count, "tasks") loading_err_count = self.loading_errors( ret_tsk, loading_err_count, "queue") loading_err_count = self.loading_errors( ret_tsk, loading_err_count, "simnodes") if loading_err_count == 0: return True, "" else: return loading_err_count, "error info in log" else: return -5, "SimNodes not loaded" else: return -4, "Queue items not loaded" else: return -1, "Tasks data not loaded" else: return -2, "Schemas data not loaded" else: return -3, "Projects data not loaded" else: return -100, "No data exist" else: return False, "config.ini not loaded"
class SingleProject: DEF_STATE_FOR_NEW_PROJ = "ACTIVE" DEF_STATE_ID_FOR_NEW_PROJ = 22 comfun = None def __init__(self, project_id, project_name, is_default, state_id, state, project_directory, working_directory, cameras_directory, cache_directory, env_directory, props_directory, scripts_directory, custom_directory, seq_shot_take_pattern, description, zeros_in_version=3): self.comfun = CommonFunctions() self.id = project_id self.project_name = project_name self.project_directory = self.comfun.get_proper_path(project_directory, info="proj dir") self.working_directory = self.comfun.get_proper_path(working_directory, info="wrk dir") self.cameras_directory = self.comfun.get_proper_path(cameras_directory, info="cam dir") self.cache_directory = self.comfun.get_proper_path( cache_directory, info="ani cache dir") if len(env_directory) == 0: env_directory = project_directory if len(props_directory) == 0: props_directory = project_directory if len(scripts_directory) == 0: scripts_directory = project_directory if len(custom_directory) == 0: custom_directory = project_directory self.env_directory = self.comfun.get_proper_path(env_directory, info="env dir") self.props_directory = self.comfun.get_proper_path(props_directory, info="props dir") self.scripts_directory = self.comfun.get_proper_path( scripts_directory, info="scripts dir") self.custom_directory = self.comfun.get_proper_path(custom_directory, info="custom dir") self.working_directory_absolute = "" self.cameras_directory_absolute = "" self.cache_directory_absolute = "" self.env_directory_absolute = "" self.props_directory_absolute = "" self.scripts_directory_absolute = "" self.custom_directory_absolute = "" # self.frame_range_directory_absolute = self.working_directory_absolute + "\\frame_range\\" # TODO frame range self.is_default = is_default if state_id == 0: state_id = self.DEF_STATE_ID_FOR_NEW_PROJ state = self.DEF_STATE_FOR_NEW_PROJ self.state_id = state_id self.state = state self.seq_shot_take_pattern = seq_shot_take_pattern self.zeros_in_version = zeros_in_version self.description = description self.update_absolute_directories() def update_absolute_directories(self): if self.comfun.is_absolute(self.working_directory) is False: self.working_directory_absolute = self.project_directory + self.working_directory else: self.working_directory_absolute = self.working_directory if self.comfun.is_absolute(self.cameras_directory) is False: self.cameras_directory_absolute = self.project_directory + self.cameras_directory else: self.cameras_directory_absolute = self.cameras_directory if self.comfun.is_absolute(self.cache_directory) is False: self.cache_directory_absolute = self.project_directory + self.cache_directory else: self.cache_directory_absolute = self.cache_directory # TODO standard directories on settings if self.comfun.is_absolute(self.env_directory) is False: self.env_directory_absolute = self.project_directory + self.env_directory else: self.env_directory_absolute = self.env_directory if self.comfun.is_absolute(self.props_directory) is False: self.props_directory_absolute = self.project_directory + self.props_directory else: self.props_directory_absolute = self.props_directory if self.comfun.is_absolute(self.scripts_directory) is False: self.scripts_directory_absolute = self.project_directory + self.scripts_directory else: self.scripts_directory_absolute = self.scripts_directory if self.comfun.is_absolute(self.custom_directory) is False: self.custom_directory_absolute = self.project_directory + self.custom_directory else: self.custom_directory_absolute = self.custom_directory