(self)
return connection
Create a new WMI connection
Create a new WMI connection
Create a new WMI connection
def get_connection(self):
        """
        Create a new WMI connection
        """
        self.logger.debug(
            u"Connecting to WMI server (host=%s, namespace=%s, provider=%s, username=%s).",
            self.host,
            self.namespace,
            self.provider,
            self.username,
        )

        additional_args = []

        if self.provider != ProviderArchitecture.DEFAULT:
            context = Dispatch("WbemScripting.SWbemNamedValueSet")
            context.Add("__ProviderArchitecture", self.provider)
            additional_args = [None, "", 128, context]

        locator = Dispatch("WbemScripting.SWbemLocator")
        connection = locator.ConnectServer(self.host, self.namespace, self.username, self.password, *additional_args)

        return connection
def get_connection ( self ) : self . logger . debug ( u"Connecting to WMI server (host=%s, namespace=%s, provider=%s, username=%s)." , self . host , self . namespace , self . provider , self . username , ) additional_args = [ ] if self . provider != ProviderArchitecture . DEFAULT : context = Dispatch ( "WbemScripting.SWbemNamedValueSet" ) context . Add ( "__ProviderArchitecture" , self . provider ) additional_args = [ None , "" , 128 , context ] locator = Dispatch ( "WbemScripting.SWbemLocator" ) connection = locator . ConnectServer ( self . host , self . namespace , self . username , self . password , * additional_args ) return connection