def _setup_conf_dir(path): """ Setup the custom config dir and cat file """ dir = _find_customconf_dir() # If the plugin directory doesn't exist, create it if not os.path.isdir(dir): os.makedirs(dir) file = os.path.join(dir, "custom_config.py") cat_file = CategoryInstaller.get_user_file() # If the user category file doesn't exist copy the default to # the user directory if not os.path.isfile(cat_file): try: default_cat_file = CategoryInstaller.get_default_file() if os.path.isfile(default_cat_file): shutil.copyfile(default_cat_file, cat_file) else: print "Unable to find/copy default cat file" except: print "Unable to copy default cat file to the user dir." # Place example user models as needed try: if not os.path.isfile(file): shutil.copyfile(os.path.join(path, "custom_config.py"), file) except: # Check for data path next to exe/zip file. #Look for maximum n_dir up of the current dir to find plugins dir n_dir = 12 is_dir = False f_dir = path for i in range(n_dir): if i > 1: f_dir, _ = os.path.split(f_dir) temp_path = os.path.join(f_dir, "custom_config.py") if os.path.isfile(temp_path): shutil.copyfile(temp_path, file) is_dir = True break if not is_dir: raise return dir
def _setup_conf_dir(path): """ Setup the custom config dir and cat file """ dir = _find_customconf_dir() # If the plugin directory doesn't exist, create it if not os.path.isdir(dir): os.makedirs(dir) file = os.path.join(dir, "custom_config.py") cat_file = CategoryInstaller.get_user_file() # If the user category file doesn't exist copy the default to # the user directory if not os.path.isfile(cat_file): try: default_cat_file = CategoryInstaller.get_default_file() if os.path.isfile(default_cat_file): shutil.copyfile(default_cat_file, cat_file) else: print "Unable to find/copy default cat file" except: print "Unable to copy default cat file to the user dir." # Place example user models as needed try: if not os.path.isfile(file): shutil.copyfile(os.path.join(path, "custom_config.py"), file) except: # Check for data path next to exe/zip file. # Look for maximum n_dir up of the current dir to find plugins dir n_dir = 12 is_dir = False f_dir = path for i in range(n_dir): if i > 1: f_dir, _ = os.path.split(f_dir) temp_path = os.path.join(f_dir, "custom_config.py") if os.path.isfile(temp_path): shutil.copyfile(temp_path, file) is_dir = True break if not is_dir: raise return dir
def _read_category_info(self): """ Read in categorization info from file """ try: file = CategoryInstaller.get_user_file() if os.path.isfile(file): cat_file = open(file, 'rb') # self.master_category_dict = pickle.load(cat_file) self.master_category_dict = json.load(cat_file) else: cat_file = open(CategoryInstaller.get_default_file(), 'rb') # self.master_category_dict = pickle.load(cat_file) self.master_category_dict = json.load(cat_file) cat_file.close() except IOError: print 'Problem reading in category file. Please review' self._regenerate_model_dict()
def _save_state(self): """ Serializes categorization info to file """ self._regenerate_master_dict() cat_file = open(CategoryInstaller.get_user_file(), 'wb') json.dump(self.master_category_dict, cat_file ) cat_file.close()
def _save_state(self): """ Serializes categorization info to file """ self._regenerate_master_dict() cat_file = open(CategoryInstaller.get_user_file(), 'wb') json.dump(self.master_category_dict, cat_file) cat_file.close()
class ModelManager(object): """ implement model """ __modelmanager = ModelManagerBase() cat_model_list = [model_name for model_name \ in __modelmanager.model_dictionary.keys() \ if model_name not in __modelmanager.stored_plugins.keys()] CategoryInstaller.check_install(model_list=cat_model_list) def findModels(self): return self.__modelmanager.findModels() def _getModelList(self): return self.__modelmanager._getModelList() def is_changed(self): return self.__modelmanager.is_changed() def update(self): return self.__modelmanager.update() def pulgins_reset(self): return self.__modelmanager.pulgins_reset() def populate_menu(self, modelmenu, event_owner): return self.__modelmanager.populate_menu(modelmenu, event_owner) def _on_model(self, evt): return self.__modelmanager._on_model(evt) def _get_multifunc_models(self): return self.__modelmanager._get_multifunc_models() def get_model_list(self): return self.__modelmanager.get_model_list() def get_model_name_list(self): return self.__modelmanager.get_model_name_list() def get_model_dictionary(self): return self.__modelmanager.get_model_dictionary()