+def runShellCommand(cmd,ptimeout,stdinput,user,args=[]):
+ global uwscfg
+ cmd = cmd.replace("%ARG%"," ".join(args)).replace("%USER%", user)
+ if ptimeout is None or float(ptimeout) > 45:
+ ptimeout = 45
+ else:
+ ptimeout = int(float(ptimeout))
+ popenTimeout2(cmd,stdinput,ptimeout=ptimeout)
+
+def executeAction(action_name, user, args=[]):
+ if action_name is None:
+ logging.error("executeAction: action_name is None")
+ return False
+ action_type = uwscfg.getValue(action_name+"_type")
+ if action_type is None:
+ logging.error("executeAction: action %s not found or has no type" % action_name)
+ return False
+ action_delay=uwscfg.getValue(action_name+"_delay")
+ logging.info("executeAction %s of type %s for user %s with delay %s" % (action_name,action_type,user,action_delay))
+ if not action_delay is None:
+ time.sleep(float(action_delay))
+
+ action_arg = uwscfg.getValue(action_name+"_arg")
+ if not action_arg is None:
+ args += [action_arg]
+
+ #"registered" actions
+ if action_type == "remotecmd":
+ return runRemoteCommand(uwscfg.getSectionValue(action_name,"remote_host"), uwscfg.getSectionValue(action_name,"remote_shell"), user=user, args=args)
+ elif action_type == "shellcmd":
+ return runShellCommand(cmd=uwscfg.getSectionValue(action_name,"cmd"), ptimeout=uwscfg.getSectionValue(action_name,"timeout"), stdinput=uwscfg.getSectionValue(action_name,"stdinput"), user=user, args=args)
+ elif action_type == "nothing":
+ return True
+ elif action_type == "random":
+ return runRandomAction(action_list=uwscfg.getSectionValue(action_name,"one_of").split(" "),user=user,args=args)
+ else:
+ return executeAction(action_type,user=user,args=args)
+
+def playThemeOf(user,fallback_default):