def dropEvent(self, event): if event.mimeData().hasUrls: event.accept() e_urls = event.mimeData().urls() self.add_new = False self.final_path = "" for f in e_urls: new_path = Path(f.toLocalFile()) if new_path.is_dir(): folder_content = new_path.iterdir() for iterated_file in folder_content: if iterated_file.name == "otls" or iterated_file.name == "scripts" or iterated_file.name == "hdas" or iterated_file.name == "toolbar": self.final_path = new_path self.add_new = True if new_path.name == "otls": self.final_path = new_path.parent self.add_new = True if self.add_new: json_data = {} json_data["enable"] = True json_data["path"] = self.final_path.abspath json_file_path = str(packages_path / self.final_path.basename) json_file_path = Path(json_file_path + ".json") obj = Package(json_file_path, self.final_path.basename, json_data) obj.just_save_all() packages[self.final_path.basename] = obj window.load_newest(self.final_path.basename)
class Settings(object): def __init__(self): self.__configuration_path = get_root_dir() self.__packages_path = Path() #loading of config if self.__configuration_path.exists(): with open(self.__configuration_path.abspath, "r") as f: data = json.load(f) self.__packages_path = Path(data["cfg_path"]) else: false_dir = True while false_dir: self.__packages_path = self.__request_dir__( ) ##gettting that folder from user files_to_check = self.__packages_path.iterdir() for f in files_to_check: if f.basename == "houdini.env": false_dir = False self.dingus_box = qt.QMessageBox() self.dingus_box.setBaseSize(qtcore.QSize(360, 160)) if false_dir: self.dingus_box.setText("Bad Folder") self.dingus_box.setInformativeText( "Hey, you are a dingus!\nThat ain't a folder I've asked for!" ) else: self.dingus_box.setText("Done") self.dingus_box.setInformativeText( "Config file has been created.\nIf you need to change the foder just delete hou_packager.json file." ) self.dingus_box.exec_() with open(self.__configuration_path.abspath, "w") as f: new_dic = {} new_dic["cfg_path"] = self.__packages_path.abspath data = json.dumps(new_dic, indent=3) f.write(data) def __request_dir__(self): #return Path("/") ##TODO: add an interface to get dir return Path(Window().get_config_dir()) def give_path(self): return self.__packages_path / "packages"