Python win32api 模块,GetFullPathName() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用win32api.GetFullPathName()

项目:purelove    作者:hucmosin    | 项目源码 | 文件源码
def GetServiceClassString(cls, argv = None):
    if argv is None:
        argv = sys.argv
    import pickle
    modName = pickle.whichmodule(cls, cls.__name__)
    if modName == '__main__':
        try:
            fname = win32api.GetFullPathName(argv[0])
            path = os.path.split(fname)[0]
            # Eaaaahhhh - sometimes this will be a short filename, which causes
            # problems with 1.5.1 and the silly filename case rule.
            # Get the long name
            fname = os.path.join(path, win32api.FindFiles(fname)[0][8])
        except win32api.error:
            raise error("Could not resolve the path name '%s' to a full path" % (argv[0]))
        modName = os.path.splitext(fname)[0]
    return modName + "." + cls.__name__
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def checkextensions(unknown, extra_inis, prefix):
    # Create a table of frozen extensions

    defaultMapName = os.path.join( os.path.split(sys.argv[0])[0], "extensions_win32.ini")
    if not os.path.isfile(defaultMapName):
        sys.stderr.write("WARNING: %s can not be found - standard extensions may not be found\n" % defaultMapName)
    else:
        # must go on end, so other inis can override.
        extra_inis.append(defaultMapName)

    ret = []
    for mod in unknown:
        for ini in extra_inis:
#                       print "Looking for", mod, "in", win32api.GetFullPathName(ini),"...",
            defn = get_extension_defn( mod, ini, prefix )
            if defn is not None:
#                               print "Yay - found it!"
                ret.append( defn )
                break
#                       print "Nope!"
        else: # For not broken!
            sys.stderr.write("No definition of module %s in any specified map file.\n" % (mod))

    return ret
项目:oil    作者:oilshell    | 项目源码 | 文件源码
def parse_dsp(dsp):
#       print "Processing", dsp
    # For now, only support
    ret = []
    dsp_path, dsp_name = os.path.split(dsp)
    try:
        lines = open(dsp, "r").readlines()
    except IOError, msg:
        sys.stderr.write("%s: %s\n" % (dsp, msg))
        return None
    for line in lines:
        fields = line.strip().split("=", 2)
        if fields[0]=="SOURCE":
            if os.path.splitext(fields[1])[1].lower() in ['.cpp', '.c']:
                ret.append( win32api.GetFullPathName(os.path.join(dsp_path, fields[1] ) ) )
    return ret
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def checkextensions(unknown, extra_inis, prefix):
    # Create a table of frozen extensions

    defaultMapName = os.path.join( os.path.split(sys.argv[0])[0], "extensions_win32.ini")
    if not os.path.isfile(defaultMapName):
        sys.stderr.write("WARNING: %s can not be found - standard extensions may not be found\n" % defaultMapName)
    else:
        # must go on end, so other inis can override.
        extra_inis.append(defaultMapName)

    ret = []
    for mod in unknown:
        for ini in extra_inis:
#                       print "Looking for", mod, "in", win32api.GetFullPathName(ini),"...",
            defn = get_extension_defn( mod, ini, prefix )
            if defn is not None:
#                               print "Yay - found it!"
                ret.append( defn )
                break
#                       print "Nope!"
        else: # For not broken!
            sys.stderr.write("No definition of module %s in any specified map file.\n" % (mod))

    return ret
项目:python2-tracer    作者:extremecoders-re    | 项目源码 | 文件源码
def parse_dsp(dsp):
#       print "Processing", dsp
    # For now, only support
    ret = []
    dsp_path, dsp_name = os.path.split(dsp)
    try:
        lines = open(dsp, "r").readlines()
    except IOError, msg:
        sys.stderr.write("%s: %s\n" % (dsp, msg))
        return None
    for line in lines:
        fields = line.strip().split("=", 2)
        if fields[0]=="SOURCE":
            if os.path.splitext(fields[1])[1].lower() in ['.cpp', '.c']:
                ret.append( win32api.GetFullPathName(os.path.join(dsp_path, fields[1] ) ) )
    return ret
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def __init__(self, module):
        self.module = module
        if hasattr(module, '__file__'):
            fname = self.module.__file__
            # Check for .pyc or .pyo or even .pys!
            if fname[-1] in ['O','o','C','c', 'S', 's']: fname = fname[:-1]
            try:
                fname = win32api.GetFullPathName(fname)
            except win32api.error:
                pass
        else:
            if module.__name__=='__main__' and len(sys.argv)>0:
                fname = sys.argv[0]
            else:
                fname = "<Unknown!>"
        SourceCodeContainer.__init__(self, None, fname)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def GetName(self, dnt):
        name = self.module.__name__
        try:
            fname = win32api.GetFullPathName(self.module.__file__)
        except win32api.error:
            fname = self.module.__file__
        except AttributeError:
            fname = name
        if dnt==axdebug.DOCUMENTNAMETYPE_APPNODE:
            return name.split(".")[-1]
        elif dnt==axdebug.DOCUMENTNAMETYPE_TITLE:
            return fname
        elif dnt==axdebug.DOCUMENTNAMETYPE_FILE_TAIL:
            return os.path.split(fname)[1]
        elif dnt==axdebug.DOCUMENTNAMETYPE_URL:
            return "file:%s" % fname
        else:
            raise Exception(scode=winerror.E_UNEXPECTED)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def GetServiceClassString(cls, argv = None):
    if argv is None:
        argv = sys.argv
    import pickle
    modName = pickle.whichmodule(cls, cls.__name__)
    if modName == '__main__':
        try:
            fname = win32api.GetFullPathName(argv[0])
            path = os.path.split(fname)[0]
            # Eaaaahhhh - sometimes this will be a short filename, which causes
            # problems with 1.5.1 and the silly filename case rule.
            # Get the long name
            fname = os.path.join(path, win32api.FindFiles(fname)[0][8])
        except win32api.error:
            raise error("Could not resolve the path name '%s' to a full path" % (argv[0]))
        modName = os.path.splitext(fname)[0]
    return modName + "." + cls.__name__
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def __init__(self, module):
        self.module = module
        if hasattr(module, '__file__'):
            fname = self.module.__file__
            # Check for .pyc or .pyo or even .pys!
            if fname[-1] in ['O','o','C','c', 'S', 's']: fname = fname[:-1]
            try:
                fname = win32api.GetFullPathName(fname)
            except win32api.error:
                pass
        else:
            if module.__name__=='__main__' and len(sys.argv)>0:
                fname = sys.argv[0]
            else:
                fname = "<Unknown!>"
        SourceCodeContainer.__init__(self, None, fname)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def GetName(self, dnt):
        name = self.module.__name__
        try:
            fname = win32api.GetFullPathName(self.module.__file__)
        except win32api.error:
            fname = self.module.__file__
        except AttributeError:
            fname = name
        if dnt==axdebug.DOCUMENTNAMETYPE_APPNODE:
            return name.split(".")[-1]
        elif dnt==axdebug.DOCUMENTNAMETYPE_TITLE:
            return fname
        elif dnt==axdebug.DOCUMENTNAMETYPE_FILE_TAIL:
            return os.path.split(fname)[1]
        elif dnt==axdebug.DOCUMENTNAMETYPE_URL:
            return "file:%s" % fname
        else:
            raise Exception(scode=winerror.E_UNEXPECTED)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def SubstituteVSSInFile(projectName, inName, outName):
    import win32api
    if win32api.GetFullPathName(inName)==win32api.GetFullPathName(outName):
        raise RuntimeError("The input and output filenames can not be the same")
    sourceSafe=GetSS()
    project = sourceSafe.VSSItem(projectName)
    # Find the last label
    label = None
    for version in project.Versions:
        if version.Label:
            break
    else:
        print("Couldnt find a label in the sourcesafe project!")
        return
    # Setup some local helpers for the conversion strings.
    vss_label = version.Label
    vss_date = time.asctime(time.localtime(int(version.Date)))
    now = time.asctime(time.localtime(time.time()))
    SubstituteInFile(inName, outName, (locals(),globals()))
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def GetServiceClassString(cls, argv = None):
    if argv is None:
        argv = sys.argv
    import pickle
    modName = pickle.whichmodule(cls, cls.__name__)
    if modName == '__main__':
        try:
            fname = win32api.GetFullPathName(argv[0])
            path = os.path.split(fname)[0]
            # Eaaaahhhh - sometimes this will be a short filename, which causes
            # problems with 1.5.1 and the silly filename case rule.
            # Get the long name
            fname = os.path.join(path, win32api.FindFiles(fname)[0][8])
        except win32api.error:
            raise error("Could not resolve the path name '%s' to a full path" % (argv[0]))
        modName = os.path.splitext(fname)[0]
    return modName + "." + cls.__name__
项目:purelove    作者:hucmosin    | 项目源码 | 文件源码
def LocatePythonServiceExe(exeName = None):
    if not exeName and hasattr(sys, "frozen"):
        # If py2exe etc calls this with no exeName, default is current exe.
        return sys.executable

    # Try and find the specified EXE somewhere.  If specifically registered,
    # use it.  Otherwise look down sys.path, and the global PATH environment.
    if exeName is None:
        if os.path.splitext(win32service.__file__)[0].endswith("_d"):
            exeName = "PythonService_d.exe"
        else:
            exeName = "PythonService.exe"
    # See if it exists as specified
    if os.path.isfile(exeName): return win32api.GetFullPathName(exeName)
    baseName = os.path.splitext(os.path.basename(exeName))[0]
    try:
        exeName = win32api.RegQueryValue(win32con.HKEY_LOCAL_MACHINE,
                                         "Software\\Python\\%s\\%s" % (baseName, sys.winver))
        if os.path.isfile(exeName):
            return exeName
        raise RuntimeError("The executable '%s' is registered as the Python " \
                           "service exe, but it does not exist as specified" \
                           % exeName)
    except win32api.error:
        # OK - not there - lets go a-searchin'
        for path in [sys.prefix] + sys.path:
            look = os.path.join(path, exeName)
            if os.path.isfile(look):
                return win32api.GetFullPathName(look)
        # Try the global Path.
        try:
            return win32api.SearchPath(None, exeName)[0]
        except win32api.error:
            msg = "%s is not correctly registered\nPlease locate and run %s, and it will self-register\nThen run this service registration process again." % (exeName, exeName)
            raise error(msg)
项目:Email_My_PC    作者:Jackeriss    | 项目源码 | 文件源码
def get_schema_fname():
    me = win32api.GetFullPathName(__file__)
    sc = os.path.splitext(me)[0] + ".propdesc"
    assert os.path.isfile(sc), sc
    return sc
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def setUp(self):
        file = win32api.GetFullPathName(os.path.join(win32com.axscript.client.__path__[0], "pyscript.py"))
        from win32com.test.util import RegisterPythonServer
        self.verbose = verbose
        RegisterPythonServer(file, 'python', verbose=self.verbose)
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def testHost(self):
        file = win32api.GetFullPathName(os.path.join(win32com.axscript.__path__[0], "test\\testHost.py"))
        cmd = '%s "%s"' % (win32api.GetModuleFileName(0), file)
        if verbose:
            print "Testing Python Scripting host"
        win32com.test.util.ExecuteShellCommand(cmd, self)
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def testCScript(self):
        file = win32api.GetFullPathName(os.path.join(win32com.axscript.__path__[0], "Demos\\Client\\wsh\\test.pys"))
        cmd = 'cscript.exe "%s"' % (file)
        if verbose:
            print "Testing Windows Scripting host with Python script"
        win32com.test.util.ExecuteShellCommand(cmd, self)
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def GetGenPath():
    import win32api
    return os.path.join(win32api.GetFullPathName(win32com.test.__path__[0]), genDir)
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def TestExplorer(iexplore):
    if not iexplore.Visible: iexplore.Visible = -1
    iexplore.Navigate(win32api.GetFullPathName('..\\readme.htm'))
    win32api.Sleep(1000)
    TestObjectFromWindow()
    win32api.Sleep(3000)
    try:
        iexplore.Quit()
    except (AttributeError, pythoncom.com_error):
        # User got sick of waiting :)
        pass
项目:OSPTF    作者:xSploited    | 项目源码 | 文件源码
def TestExplorerEvents():
    iexplore = win32com.client.DispatchWithEvents(
        "InternetExplorer.Application", ExplorerEvents)

    thread = win32api.GetCurrentThreadId()
    print 'TestExplorerEvents created IE object on thread %d'%thread

    iexplore.Visible = 1
    try:
        iexplore.Navigate(win32api.GetFullPathName('..\\readme.htm'))
    except pythoncom.com_error, details:
        print "Warning - could not open the test HTML file", details

    # In this free-threaded example, we can simply wait until an event has 
    # been set - we will give it 2 seconds before giving up.
    rc = win32event.WaitForSingleObject(iexplore.event, 2000)
    if rc != win32event.WAIT_OBJECT_0:
        print "Document load event FAILED to fire!!!"

    iexplore.Quit()
    # Now we can do the same thing to wait for exit!
    # Although Quit generates events, in this free-threaded world we
    # do *not* need to run any message pumps.

    rc = win32event.WaitForSingleObject(iexplore.event, 2000)
    if rc != win32event.WAIT_OBJECT_0:
        print "OnQuit event FAILED to fire!!!"

    iexplore = None
    print "Finished the IE event sample!"
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def setUp(self):
        file = win32api.GetFullPathName(os.path.join(win32com.axscript.client.__path__[0], "pyscript.py"))
        from win32com.test.util import RegisterPythonServer
        self.verbose = verbose
        RegisterPythonServer(file, 'python', verbose=self.verbose)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def testHost(self):
        file = win32api.GetFullPathName(os.path.join(win32com.axscript.__path__[0], "test\\testHost.py"))
        cmd = '%s "%s"' % (win32api.GetModuleFileName(0), file)
        if verbose:
            print "Testing Python Scripting host"
        win32com.test.util.ExecuteShellCommand(cmd, self)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def testCScript(self):
        file = win32api.GetFullPathName(os.path.join(win32com.axscript.__path__[0], "Demos\\Client\\wsh\\test.pys"))
        cmd = 'cscript.exe "%s"' % (file)
        if verbose:
            print "Testing Windows Scripting host with Python script"
        win32com.test.util.ExecuteShellCommand(cmd, self)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def GetGenPath():
    import win32api
    return os.path.join(win32api.GetFullPathName(win32com.test.__path__[0]), genDir)
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def TestExplorer(iexplore):
    if not iexplore.Visible: iexplore.Visible = -1
    iexplore.Navigate(win32api.GetFullPathName('..\\readme.htm'))
    win32api.Sleep(1000)
    TestObjectFromWindow()
    win32api.Sleep(3000)
    try:
        iexplore.Quit()
    except (AttributeError, pythoncom.com_error):
        # User got sick of waiting :)
        pass
项目:pupy    作者:ru-faraon    | 项目源码 | 文件源码
def TestExplorerEvents():
    iexplore = win32com.client.DispatchWithEvents(
        "InternetExplorer.Application", ExplorerEvents)

    thread = win32api.GetCurrentThreadId()
    print 'TestExplorerEvents created IE object on thread %d'%thread

    iexplore.Visible = 1
    try:
        iexplore.Navigate(win32api.GetFullPathName('..\\readme.htm'))
    except pythoncom.com_error, details:
        print "Warning - could not open the test HTML file", details

    # In this free-threaded example, we can simply wait until an event has 
    # been set - we will give it 2 seconds before giving up.
    rc = win32event.WaitForSingleObject(iexplore.event, 2000)
    if rc != win32event.WAIT_OBJECT_0:
        print "Document load event FAILED to fire!!!"

    iexplore.Quit()
    # Now we can do the same thing to wait for exit!
    # Although Quit generates events, in this free-threaded world we
    # do *not* need to run any message pumps.

    rc = win32event.WaitForSingleObject(iexplore.event, 2000)
    if rc != win32event.WAIT_OBJECT_0:
        print "OnQuit event FAILED to fire!!!"

    iexplore = None
    print "Finished the IE event sample!"
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def get_schema_fname():
    me = win32api.GetFullPathName(__file__)
    sc = os.path.splitext(me)[0] + ".propdesc"
    assert os.path.isfile(sc), sc
    return sc
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def GetGoodFileName(fname):
    if fname[0] != "<":
        return win32api.GetFullPathName(fname)
    return fname
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def BuildFileList(spec, local, recurse, filter, filter_args, recursed_path = ""):
    files = []
    if isdir(spec, local):
        path = spec
        raw_spec = "*"
    else:
        path, raw_spec = os.path.split(spec)
    if recurse:
        # Need full scan, to get sub-direcetories.
        infos = FindFiles(os.path.join(path, "*"), local)
    else:
        infos = FindFiles(os.path.join(path, raw_spec), local)
    for info in infos:
        src_name = str(info[8])
        full_src_name = os.path.join(path, src_name)
        if local: # Can't do this for CE!
            full_src_name = win32api.GetFullPathName(full_src_name)
        if isdir(full_src_name, local) :
            if recurse and src_name not in ['.','..']:
                new_spec = os.path.join(full_src_name, raw_spec)
                files = files + BuildFileList(new_spec, local, 1, filter, filter_args, os.path.join(recursed_path, src_name))
        if fnmatch.fnmatch(src_name, raw_spec):
            rel_name = os.path.join(recursed_path, src_name)
            filter_data = filter( full_src_name, rel_name, info, local, filter_args )
            if filter_data is not None:
                files.append( (full_src_name, info, filter_data) )
    return files
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def BrandProject(vssProjectName, descFile, stampPath, filesToSubstitute, buildDesc = None, auto=0, bRebrand = 0):
    # vssProjectName -- The name of the VSS project to brand.
    # descFile -- A test file containing descriptions of the files in the release.
    # stampPath -- The full path to where the files referenced in descFile can be found.
    path=win32api.GetFullPathName(stampPath)

    build = vssutil.MakeNewBuildNo(vssProjectName, buildDesc, auto, bRebrand)
    if build is None:
        print "Cancelled"
        return

    bulkstamp.scan( build, stampPath, descFile )
    for infile, outfile in filesToSubstitute:
        SubstituteVSSInFile(vssProjectName, infile, outfile)
    return 1
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def Demo():
 url = None
 if len(sys.argv)>1:
  url = win32api.GetFullPathName(sys.argv[1])
 f = BrowserFrame(url)
 f.Create("Flash Player")
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def Demo(url=None):
    if url is None and len(sys.argv)>1:
        url = win32api.GetFullPathName(sys.argv[1])
    f = BrowserFrame(url)
    f.Create("Web Browser")
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def Demo():
    import sys, win32api
    docName = None
    if len(sys.argv)>1:
        docName = win32api.GetFullPathName(sys.argv[1])
    OleTemplate().OpenDocumentFile(None)
#   f = WordFrame(docName)
#   f.Create("Microsoft Office")
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def LocatePythonServiceExe(exeName = None):
    if not exeName and hasattr(sys, "frozen"):
        # If py2exe etc calls this with no exeName, default is current exe.
        return sys.executable

    # Try and find the specified EXE somewhere.  If specifically registered,
    # use it.  Otherwise look down sys.path, and the global PATH environment.
    if exeName is None:
        if os.path.splitext(win32service.__file__)[0].endswith("_d"):
            exeName = "PythonService_d.exe"
        else:
            exeName = "PythonService.exe"
    # See if it exists as specified
    if os.path.isfile(exeName): return win32api.GetFullPathName(exeName)
    baseName = os.path.splitext(os.path.basename(exeName))[0]
    try:
        exeName = win32api.RegQueryValue(win32con.HKEY_LOCAL_MACHINE,
                                         "Software\\Python\\%s\\%s" % (baseName, sys.winver))
        if os.path.isfile(exeName):
            return exeName
        raise RuntimeError("The executable '%s' is registered as the Python " \
                           "service exe, but it does not exist as specified" \
                           % exeName)
    except win32api.error:
        # OK - not there - lets go a-searchin'
        for path in [sys.prefix] + sys.path:
            look = os.path.join(path, exeName)
            if os.path.isfile(look):
                return win32api.GetFullPathName(look)
        # Try the global Path.
        try:
            return win32api.SearchPath(None, exeName)[0]
        except win32api.error:
            msg = "%s is not correctly registered\nPlease locate and run %s, and it will self-register\nThen run this service registration process again." % (exeName, exeName)
            raise error(msg)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def setUp(self):
        file = win32api.GetFullPathName(os.path.join(win32com.axscript.client.__path__[0], "pyscript.py"))
        from win32com.test.util import RegisterPythonServer
        self.verbose = verbose
        RegisterPythonServer(file, 'python', verbose=self.verbose)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def testHost(self):
        file = win32api.GetFullPathName(os.path.join(win32com.axscript.__path__[0], "test\\testHost.py"))
        cmd = '%s "%s"' % (win32api.GetModuleFileName(0), file)
        if verbose:
            print "Testing Python Scripting host"
        win32com.test.util.ExecuteShellCommand(cmd, self)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def GetGenPath():
    import win32api
    return os.path.join(win32api.GetFullPathName(win32com.test.__path__[0]), genDir)
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def TestExplorer(iexplore):
    if not iexplore.Visible: iexplore.Visible = -1
    iexplore.Navigate(win32api.GetFullPathName('..\\readme.htm'))
    win32api.Sleep(1000)
    TestObjectFromWindow()
    win32api.Sleep(3000)
    try:
        iexplore.Quit()
    except (AttributeError, pythoncom.com_error):
        # User got sick of waiting :)
        pass
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def TestExplorerEvents():
    iexplore = win32com.client.DispatchWithEvents(
        "InternetExplorer.Application", ExplorerEvents)

    thread = win32api.GetCurrentThreadId()
    print 'TestExplorerEvents created IE object on thread %d'%thread

    iexplore.Visible = 1
    try:
        iexplore.Navigate(win32api.GetFullPathName('..\\readme.htm'))
    except pythoncom.com_error, details:
        print "Warning - could not open the test HTML file", details

    # Wait for the event to be signalled while pumping messages.
    if not WaitWhileProcessingMessages(iexplore.event):
        print "Document load event FAILED to fire!!!"

    iexplore.Quit()
    #
    # Give IE a chance to shutdown, else it can get upset on fast machines.
    # Note, Quit generates events.  Although this test does NOT catch them
    # it is NECESSARY to pump messages here instead of a sleep so that the Quit
    # happens properly!
    if not WaitWhileProcessingMessages(iexplore.event):
        print "OnQuit event FAILED to fire!!!"

    iexplore = None
项目:remoteControlPPT    作者:htwenning    | 项目源码 | 文件源码
def TestExplorerEvents():
    iexplore = win32com.client.DispatchWithEvents(
        "InternetExplorer.Application", ExplorerEvents)

    thread = win32api.GetCurrentThreadId()
    print 'TestExplorerEvents created IE object on thread %d'%thread

    iexplore.Visible = 1
    try:
        iexplore.Navigate(win32api.GetFullPathName('..\\readme.htm'))
    except pythoncom.com_error, details:
        print "Warning - could not open the test HTML file", details

    # In this free-threaded example, we can simply wait until an event has 
    # been set - we will give it 2 seconds before giving up.
    rc = win32event.WaitForSingleObject(iexplore.event, 2000)
    if rc != win32event.WAIT_OBJECT_0:
        print "Document load event FAILED to fire!!!"

    iexplore.Quit()
    # Now we can do the same thing to wait for exit!
    # Although Quit generates events, in this free-threaded world we
    # do *not* need to run any message pumps.

    rc = win32event.WaitForSingleObject(iexplore.event, 2000)
    if rc != win32event.WAIT_OBJECT_0:
        print "OnQuit event FAILED to fire!!!"

    iexplore = None
    print "Finished the IE event sample!"
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def get_schema_fname():
    me = win32api.GetFullPathName(__file__)
    sc = os.path.splitext(me)[0] + ".propdesc"
    assert os.path.isfile(sc), sc
    return sc
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def GetGoodFileName(fname):
    if fname[0] != "<":
        return win32api.GetFullPathName(fname)
    return fname
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def Demo(url=None):
    if url is None and len(sys.argv)>1:
        url = win32api.GetFullPathName(sys.argv[1])
    f = BrowserFrame(url)
    f.Create("Web Browser")
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def Demo():
    import sys, win32api
    docName = None
    if len(sys.argv)>1:
        docName = win32api.GetFullPathName(sys.argv[1])
    OleTemplate().OpenDocumentFile(None)
#   f = WordFrame(docName)
#   f.Create("Microsoft Office")
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def GetSubList(self):
        ret = MakePathSubList(self.path)
        if os.path.split(self.path)[1] == "win32com": # Complete and utter hack for win32com.
            try:
                path = win32api.GetFullPathName(os.path.join(self.path, "..\\win32comext"))
                ret = ret + MakePathSubList(path)
            except win32ui.error:
                pass
        return ret
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def BuildFileList(spec, local, recurse, filter, filter_args, recursed_path = ""):
    files = []
    if isdir(spec, local):
        path = spec
        raw_spec = "*"
    else:
        path, raw_spec = os.path.split(spec)
    if recurse:
        # Need full scan, to get sub-direcetories.
        infos = FindFiles(os.path.join(path, "*"), local)
    else:
        infos = FindFiles(os.path.join(path, raw_spec), local)
    for info in infos:
        src_name = str(info[8])
        full_src_name = os.path.join(path, src_name)
        if local: # Can't do this for CE!
            full_src_name = win32api.GetFullPathName(full_src_name)
        if isdir(full_src_name, local) :
            if recurse and src_name not in ['.','..']:
                new_spec = os.path.join(full_src_name, raw_spec)
                files = files + BuildFileList(new_spec, local, 1, filter, filter_args, os.path.join(recursed_path, src_name))
        if fnmatch.fnmatch(src_name, raw_spec):
            rel_name = os.path.join(recursed_path, src_name)
            filter_data = filter( full_src_name, rel_name, info, local, filter_args )
            if filter_data is not None:
                files.append( (full_src_name, info, filter_data) )
    return files
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def LocatePythonServiceExe(exeName = None):
    if not exeName and hasattr(sys, "frozen"):
        # If py2exe etc calls this with no exeName, default is current exe.
        return sys.executable

    # Try and find the specified EXE somewhere.  If specifically registered,
    # use it.  Otherwise look down sys.path, and the global PATH environment.
    if exeName is None:
        if os.path.splitext(win32service.__file__)[0].endswith("_d"):
            exeName = "PythonService_d.exe"
        else:
            exeName = "PythonService.exe"
    # See if it exists as specified
    if os.path.isfile(exeName): return win32api.GetFullPathName(exeName)
    baseName = os.path.splitext(os.path.basename(exeName))[0]
    try:
        exeName = win32api.RegQueryValue(win32con.HKEY_LOCAL_MACHINE,
                                         "Software\\Python\\%s\\%s" % (baseName, sys.winver))
        if os.path.isfile(exeName):
            return exeName
        raise RuntimeError("The executable '%s' is registered as the Python " \
                           "service exe, but it does not exist as specified" \
                           % exeName)
    except win32api.error:
        # OK - not there - lets go a-searchin'
        for path in [sys.prefix] + sys.path:
            look = os.path.join(path, exeName)
            if os.path.isfile(look):
                return win32api.GetFullPathName(look)
        # Try the global Path.
        try:
            return win32api.SearchPath(None, exeName)[0]
        except win32api.error:
            msg = "%s is not correctly registered\nPlease locate and run %s, and it will self-register\nThen run this service registration process again." % (exeName, exeName)
            raise error(msg)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def setUp(self):
        file = win32api.GetFullPathName(os.path.join(win32com.axscript.client.__path__[0], "pyscript.py"))
        from win32com.test.util import RegisterPythonServer
        self.verbose = verbose
        RegisterPythonServer(file, 'python', verbose=self.verbose)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def testHost(self):
        file = win32api.GetFullPathName(os.path.join(win32com.axscript.__path__[0], "test\\testHost.py"))
        cmd = '%s "%s"' % (win32api.GetModuleFileName(0), file)
        if verbose:
            print("Testing Python Scripting host")
        win32com.test.util.ExecuteShellCommand(cmd, self)
项目:CodeReader    作者:jasonrbr    | 项目源码 | 文件源码
def GetGenPath():
    import win32api
    return os.path.join(win32api.GetFullPathName(win32com.test.__path__[0]), genDir)