diff options
author | Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> | 2024-07-31 20:06:38 +0300 |
---|---|---|
committer | Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org> | 2024-08-01 08:14:35 +0200 |
commit | 817164a9de1bf497954446afe5ca5448f4a1c090 (patch) | |
tree | 40dfcf0763f15a7fe32f86ec173be7c0866f0f01 /scripting/source | |
parent | 9dfcb5f6b61b67596a86facd35806e38da16e12b (diff) |
scripting: fix issues found by Ruff linter
Change-Id: I104f1b1e1d907fbd01feeb37e3fc69ee3e2fc121
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171332
Reviewed-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Tested-by: Jenkins
Tested-by: Ilmari Lauhakangas <ilmari.lauhakangas@libreoffice.org>
Diffstat (limited to 'scripting/source')
-rw-r--r-- | scripting/source/pyprov/pythonscript.py | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/scripting/source/pyprov/pythonscript.py b/scripting/source/pyprov/pythonscript.py index 3b21e3283b0b..77d554920a7e 100644 --- a/scripting/source/pyprov/pythonscript.py +++ b/scripting/source/pyprov/pythonscript.py @@ -77,7 +77,7 @@ def getLogTarget(): if len( userInstallation ) > 0: systemPath = uno.fileUrlToSystemPath( userInstallation + "/Scripts/python/log.txt" ) ret = open( systemPath , "a" ) - except: + except Exception: print("Exception during creation of pythonscript logfile: "+ lastException2String() + "\n, delegating log to stdout\n") return ret @@ -110,7 +110,7 @@ class Logger(LogLevel): msg + "\n" ) self.target.flush() - except: + except Exception: print("Error during writing to stdout: " +lastException2String() + "\n") log = Logger( getLogTarget() ) @@ -424,7 +424,7 @@ class ProviderContext: try: code = ast.parse( src ) - except: + except Exception: log.isDebugLevel() and log.debug( "pythonscript: getFuncsByUrl: exception while parsing: " + lastException2String()) raise @@ -532,7 +532,7 @@ class ScriptBrowseNode( unohelper.Base, XBrowseNode , XPropertySet, XInvocation, ret = not self.provCtx.sfa.isReadOnly( self.uri ) log.debug( "ScriptBrowseNode.getPropertyValue called for " + name + ", returning " + str(ret) ) - except: + except Exception: log.error( "ScriptBrowseNode.getPropertyValue error " + lastException2String()) raise @@ -600,7 +600,7 @@ class ScriptBrowseNode( unohelper.Base, XBrowseNode , XPropertySet, XInvocation, # log.debug("Save is not implemented yet") # text = self.editor.getControl("EditorTextField").getText() # log.debug("Would save: " + text) - except: + except Exception: # TODO: add an error box here! log.error( lastException2String() ) @@ -641,7 +641,7 @@ class FileBrowseNode( unohelper.Base, XBrowseNode ): self.provCtx, self.uri, self.name, i )) ret = tuple( scriptNodeList ) log.debug( "returning " +str(len(ret)) + " ScriptChildNodes on " + self.uri ) - except: + except Exception: text = lastException2String() log.error( "Error while evaluating " + self.uri + ":" + text ) raise @@ -650,7 +650,7 @@ class FileBrowseNode( unohelper.Base, XBrowseNode ): def hasChildNodes(self): try: return len(self.getChildNodes()) > 0 - except: + except Exception: return False def getType( self): @@ -1059,7 +1059,7 @@ class PythonScriptProvider( unohelper.Base, XBrowseNode, XScriptProvider, XNameC log.debug( "got func " + str( func ) ) return PythonScript( func, mod, funcArgs ) - except: + except Exception: text = lastException2String() log.error( text ) raise ScriptFrameworkErrorException( text, self, scriptUri, LANGUAGENAME, 0 ) @@ -1091,7 +1091,7 @@ class PythonScriptProvider( unohelper.Base, XBrowseNode, XScriptProvider, XNameC ret = self.provCtx.isUrlInPackage( uri ) log.debug( "hasByName " + uri + " " +str( ret ) ) return ret - except: + except Exception: text = lastException2String() log.debug( "Error in hasByName:" + text ) return False |