当前位置: 首页>>代码示例>>Python>>正文


Python client.GetObject方法代码示例

本文整理汇总了Python中win32com.client.GetObject方法的典型用法代码示例。如果您正苦于以下问题:Python client.GetObject方法的具体用法?Python client.GetObject怎么用?Python client.GetObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在win32com.client的用法示例。


在下文中一共展示了client.GetObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: LocateWebServerPath

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def LocateWebServerPath(description):
    """
    Find an IIS web server whose name or comment matches the provided
    description (case-insensitive).
    
    >>> LocateWebServerPath('Default Web Site') # doctest: +SKIP
    
    or
    
    >>> LocateWebServerPath('1') #doctest: +SKIP
    """
    assert len(description) >= 1, "Server name or comment is required"
    iis = GetObject(_IIS_OBJECT)
    description = description.lower().strip()
    for site in iis:
        # Name is generally a number, but no need to assume that.
        site_attributes = [getattr(site, attr, "").lower().strip()
            for attr in ("Name", "ServerComment")]
        if description in site_attributes:
            return site.AdsPath
    msg = "No web sites match the description '%s'" % description
    raise ItemNotFound(msg) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:24,代码来源:install.py

示例2: CreateISAPIFilter

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def CreateISAPIFilter(filterParams, options):
    server = FindWebServer(options, filterParams.Server)
    _CallHook(filterParams, "PreInstall", options)
    try:
        filters = GetObject(server+"/Filters")
    except pythoncom.com_error, exc:
        # Brand new sites don't have the '/Filters' collection - create it.
        # Any errors other than 'not found' we shouldn't ignore.
        if winerror.HRESULT_FACILITY(exc.hresult) != winerror.FACILITY_WIN32 or \
           winerror.HRESULT_CODE(exc.hresult) != winerror.ERROR_PATH_NOT_FOUND:
            raise
        server_ob = GetObject(server)
        filters = server_ob.Create(_IIS_FILTERS, "Filters")
        filters.FilterLoadOrder = ""
        filters.SetInfo()

    # As for VirtualDir, delete an existing one. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:install.py

示例3: Registry

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def Registry(
        computer=None,
        impersonation_level="Impersonate",
        authentication_level="Default",
        authority=None,
        privileges=None,
        moniker=None
):
    warnings.warn("This function can be implemented using wmi.WMI (namespace='DEFAULT').StdRegProv", DeprecationWarning)
    if not moniker:
        moniker = construct_moniker(
            computer=computer,
            impersonation_level=impersonation_level,
            authentication_level=authentication_level,
            authority=authority,
            privileges=privileges,
            namespace="default",
            suffix="StdRegProv"
        )
    
    try:
        return _wmi_object(GetObject(moniker))
    
    except pywintypes.com_error:
        handle_com_error() 
开发者ID:naparuba,项目名称:opsbro,代码行数:27,代码来源:wmi.py

示例4: LoadWebServer

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def LoadWebServer(path):
    try:
        server = GetObject(path)
    except pythoncom.com_error, details:
        msg = details.strerror
        if exc.excepinfo and exc.excepinfo[2]:
            msg = exc.excepinfo[2]
        msg = "WebServer %s: %s" % (path, msg)
        raise ItemNotFound(msg) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:11,代码来源:install.py

示例5: CreateDirectory

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def CreateDirectory(params, options):
    _CallHook(params, "PreInstall", options)
    if not params.Name:
        raise ConfigurationError("No Name param")
    parent, name = params.split_path()
    target_dir = GetObject(FindPath(options, params.Server, parent))

    if not params.is_root():
        target_dir = _CreateDirectory(target_dir, name, params)

    AssignScriptMaps(params.ScriptMaps, target_dir, params.ScriptMapUpdate)
    
    _CallHook(params, "PostInstall", options, target_dir)
    log(1, "Configured Virtual Directory: %s" % (params.Name,))
    return target_dir 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:17,代码来源:install.py

示例6: DeleteISAPIFilter

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def DeleteISAPIFilter(filterParams, options):
    _CallHook(filterParams, "PreRemove", options)
    server = FindWebServer(options, filterParams.Server)
    ob_path = server+"/Filters"
    try:
        filters = GetObject(ob_path)
    except pythoncom.com_error, details:
        # failure to open the filters just means a totally clean IIS install
        # (IIS5 at least has no 'Filters' key when freshly installed).
        log(2, "ISAPI filter path '%s' did not exist." % (ob_path,))
        return 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:install.py

示例7: _DeleteExtensionFileRecord

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def _DeleteExtensionFileRecord(module, options):
    try:
        ob = GetObject(_IIS_OBJECT)
        ob.DeleteExtensionFileRecord(module)
        log(2, "Deleted extension file record for '%s'" % module)
    except (pythoncom.com_error, AttributeError), details:
        log(2, "Failed to remove extension file '%s': %s" % (module, details)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:install.py

示例8: RemoveDirectory

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def RemoveDirectory(params, options):
    if params.is_root():
        return
    try:
        directory = GetObject(FindPath(options, params.Server, params.Name))
    except pythoncom.com_error, details:
        rc = _GetWin32ErrorCode(details)
        if rc != winerror.ERROR_PATH_NOT_FOUND:
            raise
        log(2, "VirtualDirectory '%s' did not exist" % params.Name)
        directory = None 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:13,代码来源:install.py

示例9: RemoveScriptMaps

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def RemoveScriptMaps(vd_params, options):
    "Remove script maps from the already installed virtual directory"
    parent, name = vd_params.split_path()
    target_dir = GetObject(FindPath(options, vd_params.Server, parent))
    installed_maps = list(target_dir.ScriptMaps)
    for _map in map(str, vd_params.ScriptMaps):
        if _map in installed_maps:
            installed_maps.remove(_map)
    target_dir.ScriptMaps = installed_maps
    target_dir.SetInfo() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:12,代码来源:install.py

示例10: testit

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def testit(self):
        cses = GetObject("WinMgMts:").InstancesOf("Win32_Process")
        vals = []
        for cs in cses:
            val = cs.Properties_("Caption").Value
            vals.append(val)
        self.failIf(len(vals)<5, "We only found %d processes!" % len(vals)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:9,代码来源:testWMI.py

示例11: isRunning

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def isRunning(app):
    WMI = GetObject('winmgmts:')
    app = replace(app,"\\","\\\\")
    return(len(WMI.ExecQuery('select * from Win32_Process where ExecutablePath="%s"'%app))!=0) 
开发者ID:ActiveState,项目名称:code,代码行数:6,代码来源:recipe-576730.py

示例12: killAll

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def killAll(appList):
    WMI = GetObject('winmgmts:')
    for app in appList:
        app = replace(app,"\\","\\\\")
        processes = WMI.ExecQuery('select * from Win32_Process where ExecutablePath="%s"'%app)
        for process in processes:
            try:
                process.Terminate()
            except TypeError:
                raise 
开发者ID:ActiveState,项目名称:code,代码行数:12,代码来源:recipe-576730.py

示例13: __init__

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def __init__(self, namespace, wmi_class):
        _wmi_object.__init__(self, wmi_class)
        _set(self, "_class_name", wmi_class.Path_.Class)
        if namespace:
            _set(self, "_namespace", namespace)
        else:
            class_moniker = wmi_class.Path_.DisplayName
            winmgmts, namespace_moniker, class_name = class_moniker.split(":")
            namespace = _wmi_namespace(GetObject(winmgmts + ":" + namespace_moniker), False)
            _set(self, "_namespace", namespace) 
开发者ID:naparuba,项目名称:opsbro,代码行数:12,代码来源:wmi.py

示例14: GetPids

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def GetPids(processName = None, hwnd = None):
    if processName:
        pass
    elif hwnd:
        return PyGetWindowThreadProcessId(hwnd)[::-1]
    else:
        return False

    try:
        pids = []
        for proc in GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_Process WHERE Name = '" + str(processName.replace("'", "\\'")) + "'"):
            pids.append(proc.ProcessID)
        return pids
    except:
        return False

# now implemented as C function in cFunctions.pyd
#def GetProcessName(pid):
#    # See http://msdn2.microsoft.com/en-us/library/ms686701.aspx
#    hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
#    pe32 = PROCESSENTRY32()
#    pe32.dwSize = sizeof(PROCESSENTRY32)
#    try:
#        if Process32First(hProcessSnap, byref(pe32)) == 0:
#            print >> sys.stderr, "Failed getting first process."
#            return "<not found>"
#        while True:
#            if pe32.th32ProcessID == pid:
#                return pe32.szExeFile
#            if Process32Next(hProcessSnap, byref(pe32)) == 0:
#                break
#        return "<not found>"
#    finally:
#        CloseHandle(hProcessSnap) 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:36,代码来源:Utils.py

示例15: GetProcessNameEx

# 需要导入模块: from win32com import client [as 别名]
# 或者: from win32com.client import GetObject [as 别名]
def GetProcessNameEx(pid = None, hwnd = None, fullPath = False):
    if pid:
        pass
    elif hwnd:
        pid = PyGetWindowThreadProcessId(hwnd)[-1]
    else:
        return False

    try:
        result = GetObject("winmgmts:").ExecQuery("SELECT * FROM Win32_Process WHERE ProcessID = '" + str(int(pid)) + "'")[0]
        return result.ExecutablePath.strip('"') if fullPath else result.Name
    except:
        return False 
开发者ID:EventGhost,项目名称:EventGhost,代码行数:15,代码来源:Utils.py


注:本文中的win32com.client.GetObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。