def emqx_config_explain(self): Logger.info("配置路径:") Logger.info("/etc/emqx") Logger.info("取消匿名访问模式:") Logger.info( "使用sudo nano /etc/emqx/emqx.conf 编辑配置文件,将allow_anonymous设置为false, ctrl o保存" ) Logger.info("鉴权设置:") Logger.info( "使用此命令编辑sudo nano /etc/emqx/etc/plugins/emqx_auth_username.conf, " "注释掉现有内容, 打开auth.user.1的用户名和密码") Logger.warn("在启动鉴权时,请先在dashboard中启动鉴权插件")
def install(self, command: str): if self.os_name == 'Windows': Logger.warn('暂不支持此系统') elif self.os_name == "Linux": out = subprocess.check_output("cat /etc/os-release", shell=True) out = out.decode("utf-8").split('\n') # 判断系统为ubuntu1804 if "VERSION_ID=\"18.04\"" in out and "NAME=\"Ubuntu\"" in out: if command == "更新Python3": UbuntuService().upgrade_python3() elif command == "更新软件包列表": UbuntuService().update_source_list() elif command == "更新系统软件包": UbuntuService().upgrade_software() elif command == "更换系统apt源": UbuntuService().change_apt_source() elif command == "设置时区": UbuntuService().set_timezone() elif command == "安装JDK8": UbuntuService().install_java() elif command == "安装emqx": UbuntuService().install_emqx() elif command == "安装mosquitto": UbuntuService().install_mosquitto() elif command == "安装ssh": UbuntuService().install_ssh() elif command == "安装docker": UbuntuService().install_docker() elif command == "安装redis": UbuntuService().install_redis() elif command == "安装nginx": UbuntuService().install_nginx() # TODO: 其他系统 else: Logger.warn('暂不支持当前系统') else: Logger.warn('暂不支持当前系统')
def find_materials(): """Find material models """ logger = Logger("console") errors = [] mat_libs = {} rx = re.compile(r"(?:^|[\\b_\\.-])[Mm]at") a = ["MaterialModel", "AbaqusMaterial"] # gather and verify all files search_dirs = [d for d in MAT_LIB_DIRS] if not SUPPRESS_USER_ENV: for user_mat in cfgparse("materials"): user_mat = os.path.realpath(user_mat) if user_mat not in search_dirs: search_dirs.append(user_mat) # go through each item in search_dirs and generate a list of material # interface files. if item is a directory gather all files that match rx; # if it's a file, add it to the list of material files for item in search_dirs: if os.path.isfile(item): d, files = os.path.split(os.path.realpath(item)) files = [files] elif os.path.isdir(item): d = item files = [f for f in os.listdir(item) if rx.search(f)] else: logger.warn("{0} no such directory or file, skipping".format(d), report_who=1) continue files = [f for f in files if f.endswith(".py")] if not files: logger.warn("{0}: no mat files found".format(d), report_who=1) # go through files and determine if it's an interface file. if it is, # load it and add it to mat_libs for f in files: module = f[:-3] try: libs = xpyclbr.readmodule(module, [d], ancestors=a) except AttributeError as e: errors.append(e.args[0]) logger.error(e.args[0]) continue for lib in libs: if lib in mat_libs: logger.error("{0}: duplicate material".format(lib)) errors.append(lib) continue module = load_file(libs[lib].file) mat_class = getattr(module, libs[lib].class_name) if not mat_class.name: raise AFEPYError("{0}: material name attribute " "not defined".format(lib)) libs[lib].mat_class = mat_class mat_libs.update({mat_class.name.lower(): libs[lib]}) if errors: raise AFEPYError(", ".join(errors)) return mat_libs
def install_docker(self): Logger.warn('暂不支持, 请等待后续支持')
def upgrade_python3(self): self.get_python_version() Logger.warn('暂不支持, 请等待后续支持')