amazon_dash/execute.py
def execute(self, root_allowed=False):
        """Execute using self.data

        :param bool root_allowed: Allow execute as root commands
        :return:
        """
        if self.user == ROOT_USER and not root_allowed and not self.data.get('ssh'):
            raise SecurityException('For security, execute commands as root is not allowed. '
                                    'Use --root-allowed to allow executing commands as root. '
                                    ' It is however recommended to add a user to the configuration '
                                    'of the device (device: {})'.format(self.name))
        if self.data.get('user') and self.data.get('ssh'):
            raise InvalidConfig('User option is unsupported in ssh mode. The ssh user must be defined in '
                                'the ssh option. For example: user@machine')
        if self.data.get('ssh'):
            cmd = execute_over_ssh(self.data['cmd'], self.data['ssh'], self.data.get('cwd'))
            output = execute_cmd(cmd)
        else:
            cmd = run_as_cmd(self.data['cmd'], self.user)
            output = execute_cmd(cmd, self.data.get('cwd'))
        if output:
            return output[0]
def execute(self, root_allowed=False):
        """Execute using self.data

        :param bool root_allowed: Allow execute as root commands
        :return:
        """
        if self.user == ROOT_USER and not root_allowed and not self.data.get('ssh'):
            raise SecurityException('For security, execute commands as root is not allowed. '
                                    'Use --root-allowed to allow executing commands as root. '
                                    ' It is however recommended to add a user to the configuration '
                                    'of the device (device: {})'.format(self.name))
        if self.data.get('user') and self.data.get('ssh'):
            raise InvalidConfig('User option is unsupported in ssh mode. The ssh user must be defined in '
                                'the ssh option. For example: user@machine')
        if self.data.get('ssh'):
            cmd = execute_over_ssh(self.data['cmd'], self.data['ssh'], self.data.get('cwd'))
            output = execute_cmd(cmd)
        else:
            cmd = run_as_cmd(self.data['cmd'], self.user)
            output = execute_cmd(cmd, self.data.get('cwd'))
        if output:
            return output[0]
def execute ( self , root_allowed = False ) : if self . user == ROOT_USER and not root_allowed and not self . data . get ( 'ssh' ) : raise SecurityException ( 'For security, execute commands as root is not allowed. ' 'Use --root-allowed to allow executing commands as root. ' ' It is however recommended to add a user to the configuration ' 'of the device (device: {})' . format ( self . name ) ) if self . data . get ( 'user' ) and self . data . get ( 'ssh' ) : raise InvalidConfig ( 'User option is unsupported in ssh mode. The ssh user must be defined in ' 'the ssh option. For example: user@machine' ) if self . data . get ( 'ssh' ) : cmd = execute_over_ssh ( self . data [ 'cmd' ] , self . data [ 'ssh' ] , self . data . get ( 'cwd' ) ) output = execute_cmd ( cmd ) else : cmd = run_as_cmd ( self . data [ 'cmd' ] , self . user ) output = execute_cmd ( cmd , self . data . get ( 'cwd' ) ) if output : return output [ 0 ]
Execute using self.data

        :param bool root_allowed: Allow execute as root commands
        :return:
Execute using self . data