a_frame/utils/action_providers/ShellExecution.py
def execute_template(self, template):
        """
        writes the template to a tmp file and executes it on the server.
        Potentially very dangerous. You probably shouldn"t do this!

        If you do want to do this ( you shouldn"t ), your script should
        look for the device endpoint parameters stored in the env as
        ENDPOINT_USERNAME
        ENDPOINT_PASSWORD
        ENDPOINT_IP

        :param template: some sort of executable script
        :return: String results from the output of the script
        """

        cleaned_template = template.replace('\r\n', '\n')
        path = "/tmp/" + str(uuid.uuid4())
        f = open(path, "w+")
        f.write(cleaned_template)
        f.flush()
        time.sleep(.5)
        filename = f.name
        os.chmod(filename, 0700)
        f.close()
        env = os.environ.copy()

        env["ENDPOINT_USERNAME"] = self.endpoint_username
        env["ENDPOINT_PASSWORD"] = self.endpoint_password
        env["ENDPOINT_IP"] = self.endpoint_ip

        print self.endpoint_ip

        try:
            output = subprocess.check_output(filename, shell=True, env=env)
            print output
            return output
        except CalledProcessError as cpe:
            o = "Error calling local script"
            o += subprocess.check_output('cat %s' % filename, shell=True, env=env)
            o += "\n-----------------------------\n"
            o += str(cpe)
            o += "\n-----------------------------\n"
            print o
            return o

        writes the template to a tmp file and executes it on the server.
        Potentially very dangerous. You probably shouldn"t do this!

        If you do want to do this ( you shouldn"t ), your script should
        look for the device endpoint parameters stored in the env as
        ENDPOINT_USERNAME
        ENDPOINT_PASSWORD
        ENDPOINT_IP

        :param template: some sort of executable script
        :return: String results from the output of the script
        
writes the template to a tmp file and executes it on the server.
Potentially very dangerous. You probably shouldn"t do this!

If you do want to do this ( you shouldn"t ), your script should
look for the device endpoint parameters stored in the env as
ENDPOINT_USERNAME
ENDPOINT_PASSWORD
ENDPOINT_IP
writes the template to a tmp file and executes it on the server . Potentially very dangerous . You probably shouldn " t do this! If you do want to do this ( you shouldn " t ) your script should look for the device endpoint parameters stored in the env as ENDPOINT_USERNAME ENDPOINT_PASSWORD ENDPOINT_IP
def execute_template(self, template):
        cleaned_template = template.replace('\r\n', '\n')
        path = "/tmp/" + str(uuid.uuid4())
        f = open(path, "w+")
        f.write(cleaned_template)
        f.flush()
        time.sleep(.5)
        filename = f.name
        os.chmod(filename, 0700)
        f.close()
        env = os.environ.copy()
        env["ENDPOINT_USERNAME"] = self.endpoint_username
        env["ENDPOINT_PASSWORD"] = self.endpoint_password
        env["ENDPOINT_IP"] = self.endpoint_ip
        print self.endpoint_ip
        try:
            output = subprocess.check_output(filename, shell=True, env=env)
            print output
            return output
        except CalledProcessError as cpe:
            o = "Error calling local script"
            o += subprocess.check_output('cat %s' % filename, shell=True, env=env)
            o += "\n-----------------------------\n"
            o += str(cpe)
            o += "\n-----------------------------\n"
            print o
            return o
def execute_template ( self , template ) : cleaned_template = template . replace ( '\r\n' , '\n' ) path = "/tmp/" + str ( uuid . uuid4 ( ) ) f = open ( path , "w+" ) f . write ( cleaned_template ) f . flush ( ) time . sleep ( .5 ) filename = f . name os . chmod ( filename , 0700 ) f . close ( ) env = os . environ . copy ( ) env [ "ENDPOINT_USERNAME" ] = self . endpoint_username env [ "ENDPOINT_PASSWORD" ] = self . endpoint_password env [ "ENDPOINT_IP" ] = self . endpoint_ip print self . endpoint_ip try : output = subprocess . check_output ( filename , shell = True , env = env ) print output return output except CalledProcessError as cpe : o = "Error calling local script" o += subprocess . check_output ( 'cat %s' % filename , shell = True , env = env ) o += "\n-----------------------------\n" o += str ( cpe ) o += "\n-----------------------------\n" print o return o
writes the template to a tmp file and executes it on the server.
writes the template to a tmp file and executes it on the server .
"""
        writes the template to a tmp file and executes it on the server.
        Potentially very dangerous. You probably shouldn"t do this!

        If you do want to do this ( you shouldn"t ), your script should
        look for the device endpoint parameters stored in the env as
        ENDPOINT_USERNAME
        ENDPOINT_PASSWORD
        ENDPOINT_IP

        :param template: some sort of executable script
        :return: String results from the output of the script
        """
String results from the output of the script
String results from the output of the script
self
template
some sort of executable script
some sort of executable script