diff options
author | Kurt Zenker <kz@openoffice.org> | 2008-05-20 13:32:05 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2008-05-20 13:32:05 +0000 |
commit | e58d0f6e03b90b1f08d1568fd50ee3abfda811a4 (patch) | |
tree | f6cf4e2964fb6981c05d5ce4eaeded8ceaf6cb4e /scripting | |
parent | c1ec81b8dc6f459fa35ec42979e7ba03673f9a5b (diff) |
INTEGRATION: CWS pyunosystempaths_DEV300 (1.6.32); FILE MERGED
2008/04/23 06:30:40 fs 1.6.32.1: #i86251# committing on behalf of jbu@openoffice.org - proper system path encodings
Diffstat (limited to 'scripting')
-rw-r--r-- | scripting/source/pyprov/pythonscript.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/scripting/source/pyprov/pythonscript.py b/scripting/source/pyprov/pythonscript.py index f06c98878c6a..bcc6f6c85541 100644 --- a/scripting/source/pyprov/pythonscript.py +++ b/scripting/source/pyprov/pythonscript.py @@ -20,6 +20,9 @@ LOG_STDOUT = True # True, writes to stdout (difficult ENABLE_EDIT_DIALOG=False # offers a minimal editor for editing. #------------------------------------------------------------------- +def encfile(uni): + return uni.encode( sys.getfilesystemencoding()) + def lastException2String(): (excType,excInstance,excTraceback) = sys.exc_info() ret = str(excType) + ": "+str(excInstance) + "\n" + \ @@ -74,7 +77,7 @@ class Logger(LogLevel): " [" + logLevel2String( level ) + "] " + - msg + + encfile(msg) + "\n" ) self.target.flush() except Exception,e: @@ -142,17 +145,18 @@ def ensureSourceState( code ): code = code.replace( "\r", "" ) return code + def checkForPythonPathBesideScript( url ): if url.startswith( "file:" ): path = unohelper.fileUrlToSystemPath( url+"/pythonpath.zip" ); log.log( LogLevel.DEBUG, "checking for existence of " + path ) - if 1 == os.access( path, os.F_OK) and not path in sys.path: + if 1 == os.access( encfile(path), os.F_OK) and not path in sys.path: log.log( LogLevel.DEBUG, "adding " + path + " to sys.path" ) sys.path.append( path ) path = unohelper.fileUrlToSystemPath( url+"/pythonpath" ); log.log( LogLevel.DEBUG, "checking for existence of " + path ) - if 1 == os.access( path, os.F_OK) and not path in sys.path: + if 1 == os.access( encfile(path), os.F_OK) and not path in sys.path: log.log( LogLevel.DEBUG, "adding " + path + " to sys.path" ) sys.path.append( path ) @@ -295,7 +299,7 @@ class ProviderContext: code = None if url.startswith( "file:" ): - code = compile( src, uno.fileUrlToSystemPath( url ), "exec" ) + code = compile( src, encfile(uno.fileUrlToSystemPath( url ) ), "exec" ) else: code = compile( src, url, "exec" ) exec code in entry.module.__dict__ |