(self, base_options=None, open_content=None)
return response
Send an open message to the WSMan host

        :param base_options: Any OptionSet options to pass along to the Open
            message
        :param open_content: Any extra XML elements to add to the Open message
        :return: The raw WSMan body response
Send an open message to the WSMan host
Send an open message to the WSMan host
def open(self, base_options=None, open_content=None):
        """
        Send an open message to the WSMan host

        :param base_options: Any OptionSet options to pass along to the Open
            message
        :param open_content: Any extra XML elements to add to the Open message
        :return: The raw WSMan body response
        """
        if self.opened:
            return

        rsp = NAMESPACES['rsp']

        shell = ET.Element("{%s}Shell" % rsp)
        if self.id is not None:
            shell.attrib['ShellId'] = self.id

        ET.SubElement(shell, "{%s}InputStreams" % rsp).text = \
            self.input_streams
        ET.SubElement(shell, "{%s}OutputStreams" % rsp).text = \
            self.output_streams
        if self.environment is not None:
            env = ET.SubElement(shell, "{%s}Environment" % rsp)
            for key, value in self.environment.items():
                ET.SubElement(env, "{%s}Variable" % rsp,
                              Name=str(key)).text = str(value)

        if self.idle_time_out is not None:
            ET.SubElement(shell, "{%s}IdleTimeOut" % rsp).text = \
                "PT%sS" % str(self.idle_time_out)

        if self.lifetime is not None:
            ET.SubElement(shell, "{%s}Lifetime" % rsp).text = \
                "PT%sS" % self.lifetime

        if self.name is not None:
            ET.SubElement(shell, "{%s}Name" % rsp).text = self.name

        if self.working_directory is not None:
            ET.SubElement(shell, "{%s}WorkingDirectory" % rsp).text = \
                self.working_directory

        if open_content is not None:
            shell.append(open_content)

        # inherit the base options if it was passed in, otherwise use an empty
        # option set
        options = OptionSet() if base_options is None else base_options
        if self.no_profile is not None:
            options.add_option('WINRS_NOPROFILE', self.no_profile)
        if self.codepage is not None:
            options.add_option('WINRS_CODEPAGE', self.codepage)

        if len(options.values) == 0:
            # set options back to None if nothing was actually set
            options = None

        response = self.wsman.create(self.resource_uri, shell,
                                     option_set=options)
        self._parse_shell_create(response)
        self.opened = True

        return response
def open ( self , base_options = None , open_content = None ) : if self . opened : return rsp = NAMESPACES [ 'rsp' ] shell = ET . Element ( "{%s}Shell" % rsp ) if self . id is not None : shell . attrib [ 'ShellId' ] = self . id ET . SubElement ( shell , "{%s}InputStreams" % rsp ) . text = self . input_streams ET . SubElement ( shell , "{%s}OutputStreams" % rsp ) . text = self . output_streams if self . environment is not None : env = ET . SubElement ( shell , "{%s}Environment" % rsp ) for key , value in self . environment . items ( ) : ET . SubElement ( env , "{%s}Variable" % rsp , Name = str ( key ) ) . text = str ( value ) if self . idle_time_out is not None : ET . SubElement ( shell , "{%s}IdleTimeOut" % rsp ) . text = "PT%sS" % str ( self . idle_time_out ) if self . lifetime is not None : ET . SubElement ( shell , "{%s}Lifetime" % rsp ) . text = "PT%sS" % self . lifetime if self . name is not None : ET . SubElement ( shell , "{%s}Name" % rsp ) . text = self . name if self . working_directory is not None : ET . SubElement ( shell , "{%s}WorkingDirectory" % rsp ) . text = self . working_directory if open_content is not None : shell . append ( open_content ) # inherit the base options if it was passed in, otherwise use an empty # option set options = OptionSet ( ) if base_options is None else base_options if self . no_profile is not None : options . add_option ( 'WINRS_NOPROFILE' , self . no_profile ) if self . codepage is not None : options . add_option ( 'WINRS_CODEPAGE' , self . codepage ) if len ( options . values ) == 0 : # set options back to None if nothing was actually set options = None response = self . wsman . create ( self . resource_uri , shell , option_set = options ) self . _parse_shell_create ( response ) self . opened = True return response