def stop_service_local(action_args, user_args): modules = user_args["modules"].strip().split(",") nick = get_from_cache('terminal') password = get_from_cache(nick + '_sudo_password') for module in modules: command_args = {"mod_password": password, "module": module.strip()} user_args["command_args"] = json.dumps(command_args) user_args["command_file"] = "base/stop_base" exec_command(action_args, user_args)
def ssh_logout_all(action_args, user_args): terminals = get_from_cache('terminals', []) print "Closing these terminals %s" % terminals for my_nick in list(terminals): #print "Closing %s" %my_nick new_dict = {'nick': my_nick} ssh_logout(action_args, new_dict)
def ssh_logout(action_args, user_args): nick = user_args.get('nick') #print "Got Nick %s" %nick if nick is None: nick = get_from_cache('terminal') terminal = get_from_cache(nick.strip()) if terminal is not None: #from komey.util.bcolors import bcolors #print "Logging out from %s" % nick terminal.logout() put_in_cache('terminal', None) else: #from komey.util.bcolors import bcolors print "%sWARNING - No such terminal %s%s" % (bcolors.WARNING, nick, bcolors.ENDC) if nick is not None: remove_terminal_from_list(nick) remove_from_cache(nick)
def set_exit_command(action_args, user_args): files = get_from_cache('files', []) input_file = files[-1] put_in_cache( input_file + '_exit_command', os.getcwd() + '/commands/' + user_args['exit_command'].strip())