def thread_import_settings(tmp_folder): # Upgrade database cmd = "{pth}/mycodo/scripts/mycodo_wrapper " \ "upgrade_database".format( pth=INSTALL_DIRECTORY) _, _, _ = cmd_output(cmd) # Install/update dependencies (could take a while) cmd = "{pth}/mycodo/scripts/mycodo_wrapper update_dependencies" \ " | ts '[%Y-%m-%d %H:%M:%S]' >> {log} 2>&1".format( pth=INSTALL_DIRECTORY, log=DEPENDENCY_LOG_FILE) _, _, _ = cmd_output(cmd) # Initialize cmd = "{pth}/mycodo/scripts/mycodo_wrapper " \ "initialize".format( pth=INSTALL_DIRECTORY) _, _, _ = cmd_output(cmd) # Generate widget HTML generate_widget_html() # Start Mycodo daemon (backend) cmd = "{pth}/mycodo/scripts/mycodo_wrapper " \ "daemon_start".format( pth=INSTALL_DIRECTORY) _, _, _ = cmd_output(cmd) # Delete tmp directory if it exists if os.path.isdir(tmp_folder): shutil.rmtree(tmp_folder)
def thread_import_settings(tmp_folder): logger.info("Finishing up settings import") try: # Upgrade database cmd = "{pth}/mycodo/scripts/mycodo_wrapper " \ "upgrade_database".format( pth=INSTALL_DIRECTORY) _, _, _ = cmd_output(cmd) # Install/update dependencies (could take a while) cmd = "{pth}/mycodo/scripts/mycodo_wrapper update_dependencies" \ " | ts '[%Y-%m-%d %H:%M:%S]' >> {log} 2>&1".format( pth=INSTALL_DIRECTORY, log=DEPENDENCY_LOG_FILE) _, _, _ = cmd_output(cmd) # Initialize cmd = "{pth}/mycodo/scripts/mycodo_wrapper " \ "initialize".format( pth=INSTALL_DIRECTORY) _, _, _ = cmd_output(cmd) # Generate widget HTML generate_widget_html() if DOCKER_CONTAINER: subprocess.Popen('docker start mycodo_daemon 2>&1', shell=True) else: # Start Mycodo daemon (backend) cmd = "{pth}/mycodo/scripts/mycodo_wrapper " \ "daemon_start".format( pth=INSTALL_DIRECTORY) _, _, _ = cmd_output(cmd) # Delete tmp directory if it exists if os.path.isdir(tmp_folder): shutil.rmtree(tmp_folder) except: logger.exception("thread_import_settings()") logger.info("Settings import complete")
print( daemon.pid_set(args.pid_set_integrator[0], 'integrator', args.pid_set_integrator[1])) elif args.pid_set_derivator: print( daemon.pid_set(args.pid_set_derivator[0], 'derivator', args.pid_set_derivator[1])) elif args.pid_set_kp: print(daemon.pid_set(args.pid_set_kp[0], 'kp', args.pid_set_kp[1])) elif args.pid_set_ki: print(daemon.pid_set(args.pid_set_ki[0], 'ki', args.pid_set_ki[1])) elif args.pid_set_kd: print(daemon.pid_set(args.pid_set_kd[0], 'kd', args.pid_set_kd[1])) elif args.trigger_action: print(daemon.trigger_action(args.trigger_action)) elif args.trigger_all_actions: print(daemon.trigger_all_actions(args.trigger_all_actions)) elif args.gen_widget_html: generate_widget_html() elif args.terminate: logger.info("[Remote command] Terminate daemon...") if daemon.terminate_daemon(): logger.info("Daemon response: Terminated.") else: logger.info("Unknown daemon response.") sys.exit(0)