]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Do not use bare "except:" instruction
authorGilles DAVID <gilles-g.david@edf.fr>
Thu, 3 Jun 2021 14:31:58 +0000 (16:31 +0200)
committerGilles DAVID <gilles-g.david@edf.fr>
Fri, 21 Jan 2022 09:24:13 +0000 (10:24 +0100)
We are in python3: no more need to inherite classes from object.

35 files changed:
bin/PortManager.py
bin/addToKillList.py
bin/appli_gen.py
bin/appliskel/salome_tester/salome_instance.py
bin/appliskel/salome_tester/salome_test_driver.py
bin/appliskel/salome_tester/salome_test_driver_gui.py
bin/launchConfigureParser.py
bin/nameserver.py
bin/orbmodule.py
bin/runSalome.py
bin/runSession.py
bin/salomeContext.py
bin/salomeContextUtils.py.in
bin/searchFreePort.py
bin/server.py
bin/setenv.py
doc/salome/tui/pythfilter.py
salome_adm/prepare_generating_doc.py
src/Container/SALOME_Container.py
src/Container/SALOME_ContainerPy.py
src/Container/SALOME_PyNode.py
src/KERNEL_PY/__init__.py
src/KERNEL_PY/kernel/enumerate.py
src/KERNEL_PY/kernel/studyedit.py
src/KERNEL_PY/kernel/testdata.py
src/KERNEL_PY/salome_iapp.py
src/KERNEL_PY/salome_notebook.py
src/KERNEL_PY/salome_version.py
src/Launcher/launcher_proxy.py
src/Logger/Test/TestKiller.py
src/NamingService/SALOME_NamingServicePy.py
src/SALOMEDS/SALOME_DriverPy.py
src/SALOMESDS/SALOMEGlobalVarHelper.py
src/SALOMESDS/SalomeSDSClt.py
src/Utils/Utils_Identity.py

index 539a3594205b7ec2c8ca11a00e511e62d263397a..61289e6c18c094a4b4bb741e80a5364902fb7870 100644 (file)
@@ -29,7 +29,7 @@ from socket import AF_INET, SOCK_STREAM
 
 try:
   import cPickle as pickle #@UnusedImport
-except:
+except ImportError:
   import pickle #@Reimport
 
 __PORT_MIN_NUMBER = 2810
@@ -126,7 +126,7 @@ def getPort(preferredPort=None):
     try:
       with open(config_file, 'rb') as f:
         config = pickle.load(f)
-    except:
+    except Exception:
       logger.debug("Problem loading PortManager file: %s"%config_file)
       # In this case config dictionary is reset
 
index ca31fface9fc43522a41a03a4e1f88ff1bfdc5e9..3f892e77283ea9441fb1ef3a4050bd8588eaedbd 100755 (executable)
@@ -55,7 +55,7 @@ def addToKillList(command_pid, command, port=None):
     try:
         with open(filedict, 'rb') as fpid:
             process_ids=pickle.load(fpid)
-    except:
+    except Exception:
         process_ids=[]
         pass
     # check if PID is already in dictionary
@@ -81,7 +81,7 @@ def addToKillList(command_pid, command, port=None):
             if not os.path.exists(dir): os.makedirs(dir, 0o777)
             with open(filedict,'wb') as fpid:
                 pickle.dump(process_ids, fpid)
-        except:
+        except Exception:
             if verbose(): print("addToKillList: can not add command %s : %s to the kill list" % ( str(command_pid), command ))
             pass
         pass
@@ -105,7 +105,7 @@ def killList(port=None):
     try:
         with open(filedict, 'rb') as fpid:
             process_ids=pickle.load(fpid)
-    except:
+    except Exception:
         process_ids=[]
         pass
     # kill processes
@@ -114,7 +114,7 @@ def killList(port=None):
         for pid, cmd in list(process_id.items()):
             try:
                 os.kill(int(pid),signal.SIGKILL)
-            except:
+            except Exception:
                 print("  ------------------ process %s : %s inexistant"% (pid, cmd[0]))
                 pass
             pass
index a6f610709e9f84821051114f6a3e26af1138d423..b01e789b0e466a90a97d389c023be2c26c044562 100755 (executable)
@@ -210,7 +210,7 @@ def install(prefix, config_file, verbose=0):
         print(inst.args)
         print("Configure parser: error in configuration file %s" % filename)
         pass
-    except:
+    except Exception:
         print("Configure parser: Error : can not read configuration file %s, check existence and rights" % filename)
         pass
 
@@ -223,7 +223,7 @@ def install(prefix, config_file, verbose=0):
     try:
       ctest_file = os.path.join(home_dir, 'bin', 'salome', 'test', "CTestTestfile.cmake")
       os.remove(ctest_file)
-    except:
+    except Exception:
       pass
 
     for module in _config.get("modules", []):
index e75d240832fab24089ed9c9610d8b47eb1be43f5..2eaf70d3ef976b41b1c5c6f3b7ba18f2766c51f5 100755 (executable)
@@ -24,7 +24,7 @@ import os
 # Example of args:
 #      args=["--gui", "--show-desktop=1", "--splash=0"]
 #      args=["--terminal","--modules=FIELDS,PARAVIS,GUI"]
-class SalomeInstance(object):
+class SalomeInstance:
 
   def __init__(self):
     self.port = None
@@ -53,7 +53,7 @@ class SalomeInstance(object):
       with open(port_log) as f:
         salome_instance.port = int(f.readline())
       os.remove(port_log)
-    except:
+    except Exception:
       pass
 
     return salome_instance
index df34662fe604db818e020988ce1c5413126e700c..38888491f25b60e670d4fddb0d65594291b6b54a 100755 (executable)
@@ -133,14 +133,14 @@ if __name__ == "__main__":
     res = processResult(res, out, err)
   except TimeoutException:
     print("FAILED : timeout(%s) is reached"%timeout_delay)
-  except:
+  except Exception:
     import traceback
     traceback.print_exc()
     pass
   try:
     salome_instance.stop()
     os.kill(pid, signal.SIGTERM)
-  except:
+  except Exception:
     pass
   if sys.platform == 'win32':
     timer.cancel()
index bdaf2db6b75eebe8e473a1ff814461059feaf545..b43a5336103bf9643f5618383e38cbd5e118a8f1 100755 (executable)
@@ -68,13 +68,13 @@ if __name__ == "__main__":
     salome_instance = SalomeInstance.start(with_gui=True, args=test_and_args)
   except TimeoutException:
     print("FAILED : timeout(%s) is reached"%timeout_delay)
-  except:
+  except Exception:
     import traceback
     traceback.print_exc()
     pass
   try:
     salome_instance.stop()
-  except:
+  except Exception:
     pass
   if sys.platform == 'win32':
     timer.cancel()
index 23dd6983c2f3e03dfe112f662080c3bd9bcc94f4..c7eb5157c304bbb69e3f986180d6a6944ae64efb 100644 (file)
@@ -119,7 +119,7 @@ def version():
             match = re.search( r':\s+([a-zA-Z0-9.]+)\s*$', v )
             if match :
                 return match.group( 1 )
-    except:
+    except Exception:
         pass
     return ''
 
@@ -325,7 +325,7 @@ class xml_parser:
             else:
                 if isinstance( strloc, bytes):
                     strloc = strloc.decode().strip()
-        except:
+        except Exception:
             pass
         return strloc
 
@@ -435,7 +435,7 @@ class xml_parser:
                     pass
                 pass
             pass
-        except:
+        except Exception:
             if verbose(): print("Configure parser: Error : can not read configuration file %s" % absfname)
         pass
 
@@ -912,7 +912,7 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvi
 
     try:
         dirs.remove('') # to remove empty dirs if the variable terminate by ":" or if there are "::" inside
-    except:
+    except Exception:
         pass
 
     _opts = {} # associative array of options to be filled
@@ -926,7 +926,7 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvi
             try:
                 p = xml_parser(filename, _opts, [])
                 _opts = p.opts
-            except:
+            except Exception:
                 if verbose(): print("Configure parser: Error : can not read configuration file %s" % filename)
             pass
 
@@ -944,7 +944,7 @@ def get_env(appname=salomeappname, cfgname=salomecfgname, exeName=None, keepEnvi
         try:
             p = xml_parser(user_config, _opts, [])
             _opts = p.opts
-        except:
+        except Exception:
             if verbose(): print('Configure parser: Error : can not read user configuration file')
             user_config = ""
 
index 0b8e41c65be5762e3c70de7258abbb2b14486b34..77d04f802053a3b4690884eee13049e1477f7c04 100644 (file)
@@ -63,7 +63,7 @@ class NamingServer(Server):
         upath = os.path.join(upath, "omniNames_%s"%(aPort))
         try:
           os.mkdir(upath)
-        except:
+        except Exception:
           # print("Can't create " + upath)
           pass
 
@@ -71,7 +71,7 @@ class NamingServer(Server):
         for fname in os.listdir(upath):
           try:
             os.remove(upath + "/" + fname)
-          except:
+          except Exception:
             pass
         #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
 
index bf4a22c367f2e6bd2ed459404eaaf3d446e456e3..34456fb729c6e12efc508839e00f2bb1ea9ebb4b 100755 (executable)
@@ -179,7 +179,7 @@ class client:
         while(1):
           try:
             os.kill(thePID,0)
-          except:
+          except Exception:
             raise RuntimeError("Process %d for %s not found" % (thePID,theName))
           aCount += 1
           anObj = self.Resolve(theName)
index 518e0c502a449ec4ce37b89fc46906a7cc12716c..619f4dc3b8ce12f64402a104718f3112f480d77c 100755 (executable)
@@ -50,7 +50,7 @@ def killLocalPort():
     my_port=str(args['port'])
     try:
         killMyPort(my_port)
-    except:
+    except Exception:
         print("problem in killLocalPort()")
         pass
     pass
@@ -65,7 +65,7 @@ def givenPortKill(port):
     my_port=port
     try:
         killMyPort(my_port)
-    except:
+    except Exception:
         print("problem in LocalPortKill(), killMyPort(%s)"%port)
         pass
     pass
@@ -655,7 +655,7 @@ def startSalome(args, modules_list, modules_root_dir):
     try:
         if 'interp' in args:
             nbaddi = args['interp']
-    except:
+    except Exception:
         import traceback
         traceback.print_exc()
         print("-------------------------------------------------------------")
@@ -692,7 +692,7 @@ def useSalome(args, modules_list, modules_root_dir):
     clt=None
     try:
         clt = startSalome(args, modules_list, modules_root_dir)
-    except:
+    except Exception:
         import traceback
         traceback.print_exc()
         print()
@@ -736,7 +736,7 @@ def useSalome(args, modules_list, modules_root_dir):
 
         if not args['gui'] or not args['session_gui']:
             if args['shutdown_servers']:
-                class __utils__(object):
+                class __utils__:
                     def __init__(self, port):
                         self.port = port
                         import killSalomeWithPort
@@ -877,7 +877,7 @@ def foreGround(clt, args):
             status = session.GetStatSession()
             gui_detected = status.activeGUI
             session_pid = session.getPID()
-        except:
+        except Exception:
             pass
         if gui_detected:
             break
@@ -908,7 +908,7 @@ def foreGround(clt, args):
             try:
                 status = session.GetStatSession()
                 assert status.activeGUI
-            except:
+            except Exception:
                 break
             from time import sleep
             sleep(dt)
@@ -937,7 +937,7 @@ def runSalome():
         from ctypes import POINTER, c_int, cast, pythonapi
         iflag_ptr = cast(pythonapi.Py_InteractiveFlag, POINTER(c_int))
         test = test and not iflag_ptr.contents.value
-    except:
+    except Exception:
         pass
     # --
 #    test = test and os.getenv("SALOME_TEST_MODE", "0") != "1"
index c83cf502f87d182ccc7f42ad8bdf7cae8d41c550..12ece0b7b6660d3feae50f9550132b83f7323a8d 100644 (file)
@@ -153,7 +153,7 @@ User "myself" connects to remotemachine to run the script concatenate.py in
         try:
             # keep short name for host, for a correct comparison with getShortHostName() later
             host=host.split('.')[0]
-        except:
+        except Exception:
             pass
       else:
         # No running session
@@ -220,7 +220,7 @@ def __runLocalSession(command):
         if proc.returncode != 0:
           any_error = True
           error_code = proc.returncode
-      except:
+      except Exception:
           any_error = True
           pass
 
index 32543205e09685d7d3ac0e61f186233d0f8abf8d..be7fc03d44b69fd795ba561572ff2813f2b53a5f 100755 (executable)
@@ -111,7 +111,7 @@ class SalomeContext:
     try:
       out, err = subprocess.Popen([modulecmd, "python", "load"] + env_modules, stdout=subprocess.PIPE).communicate()
       exec(out)  # define specific environment variables
-    except:
+    except Exception:
       raise SalomeContextException("Failed to load env modules: %s ..." % ' '.join(env_modules))
       pass
   #
@@ -262,7 +262,7 @@ class SalomeContext:
       path = os.path.realpath(os.path.join(absoluteAppliPath, "bin", "salome", "appliskel"))
       add_path(path, "PYTHONPATH")
 
-    except:
+    except Exception:
       pass
 
     command, options = self.__parseArguments(args)
@@ -503,7 +503,7 @@ class SalomeContext:
           versions[software.upper()] = version
           if len(software) > max_len:
             max_len = len(software)
-        except:
+        except Exception:
           pass
         pass
       pass
index d9b33b50af2d7822179e0753f72973f3527fe899..e4ca05e7bd4d7ccc94c50f37a516f757fdb0a71e 100644 (file)
@@ -262,7 +262,7 @@ def getScriptsAndArgs(args=None, searchPathList=None):
                 break
               pass
             fn.close()
-          except:
+          except Exception:
             pass
           if not ispython and script_extension == ".py":
             currentKey = "@PYTHONBIN@ "+currentScript
@@ -335,7 +335,7 @@ def setOmniOrbUserPath():
       if not os.access(temp_dir, os.W_OK):
         raise Exception("Unable to get write access to directory: %s"%temp_dir)
       os.environ["OMNIORB_USER_PATH"] = temp_dir
-    except:
+    except Exception:
       homePath = os.path.realpath(os.path.expanduser('~'))
       #defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
       defaultOmniorbUserPath = homePath
index 28df90ba483b695d35fa635fcf8bbe96a289b47f..31705e9a753379c617d8de78db2bd7df7ddf77c4 100644 (file)
@@ -58,7 +58,7 @@ def __setup_config(nsport, args, save_config):
         os.symlink(omniorb_config, last_running_config)
         pass
       pass
-    except:
+    except Exception:
       pass
   #
 #
index 70527845c59b7688d62cf020eb65b06f3cdcd8e3..2d30b82ba856c757c2c17f5b47cbf89bd1f013ef 100644 (file)
@@ -111,7 +111,7 @@ class Server:
           try:
             os.kill(childpid,0)
             return childpid
-          except:
+          except Exception:
             return None
 
         #first child
index 6555866197cc3b0a36460a2f10bfa85f3c4f12ee..62eee95c3ff91d7880adfb20fbfe88f1fe502870 100755 (executable)
@@ -210,7 +210,7 @@ def set_env(args, modules_list, modules_root_dir, silent=False, keepEnvironment=
                         mod=__import__(module.lower()+"_setenv")
                         mod.set_env(args)
                         pass
-                    except:
+                    except Exception:
                         pass
                     pass
                 pass
index 4d63a1123e4908ce11ddf087fb063675ea3c8913..113581d934bae6183b818d51310928ca813b4187 100755 (executable)
@@ -526,12 +526,12 @@ def convert(srcpath, destpath):
         if os.path.isdir(dname):
             try:
                 shutil.rmtree(dname)
-            except:
+            except Exception:
                 print("Can't remove obsolete directory '%s'"%dname)
         else:
             try:
                 os.remove(dname)
-            except:
+            except Exception:
                 print("Can't remove obsolete file '%s'"%dname)
 
     return count
index fed5b6ee314b063f3bae81752ccd42a8ffd8ffb5..7acad293e7c79414b07b56499bf2c4145fa80b9f 100755 (executable)
@@ -45,7 +45,7 @@ def main(input_file, output_file = None):
     # open input file
     try:
         infile = open(input_file, 'rb')
-    except:
+    except Exception:
         sys.exit("File %s is not found" % input_file)
         pass
 
@@ -54,7 +54,7 @@ def main(input_file, output_file = None):
     # open output file
     try:
         outfile = open(output_file, 'wb')
-    except:
+    except Exception:
         sys.exit("File %s cannot be opened for write" % output_file)
         pass
 
index 7b0c76fd98fc14e1b49b5a775dd65d446ca8fc07..13c63fb8bf49e7e603c1b8c3d5f1f38bd4bd8a29 100644 (file)
@@ -87,10 +87,10 @@ class SALOME_Container_i:
               ret=ret+traceback.format_exc(10)
             except ImportError as ee:
               ret="ImplementationNotFound"
-            except:
+            except Exception:
               if verbose():print("error when calling find_module")
               ret="ImplementationNotFound"
-        except:
+        except Exception:
             ret="Component "+componentName+": Python implementation found but it can't be loaded\n"
             ret=ret+traceback.format_exc(10)
             if verbose():
@@ -117,7 +117,7 @@ class SALOME_Container_i:
             MESSAGE( "SALOME_Container_i::create_component_instance : OK")
             comp_o = comp_i._this()
             comp_iors = self._orb.object_to_string(comp_o)
-        except:
+        except Exception:
             ret=traceback.format_exc(10)
             traceback.print_exc()
             MESSAGE( "SALOME_Container_i::create_component_instance : NOT OK")
@@ -131,7 +131,7 @@ class SALOME_Container_i:
           comp_o = self._poa.id_to_reference(id_o)
           comp_iors = self._orb.object_to_string(comp_o)
           return 0,comp_iors
-        except:
+        except Exception:
           exc_typ,exc_val,exc_fr=sys.exc_info()
           l=traceback.format_exception(exc_typ,exc_val,exc_fr)
           return 1,"".join(l)
@@ -143,7 +143,7 @@ class SALOME_Container_i:
           comp_o = self._poa.id_to_reference(id_o)
           comp_iors = self._orb.object_to_string(comp_o)
           return 0,comp_iors
-        except:
+        except Exception:
           exc_typ,exc_val,exc_fr=sys.exc_info()
           l=traceback.format_exception(exc_typ,exc_val,exc_fr)
           return 1,"".join(l)
index d5ee4ec145b78febeae90f7302c990f7103c1eec..0dacb86b79d45a447a18801f46626586c0741a87 100755 (executable)
@@ -117,7 +117,7 @@ class SALOME_ContainerPy_Gen_i(Engines__POA.Container):
                 print(reason)
                 pass
             pass
-        except:
+        except Exception:
             import traceback
             print("cannot import %s" % componentName)
             traceback.print_exc()
@@ -157,7 +157,7 @@ class SALOME_ContainerPy_Gen_i(Engines__POA.Container):
             MESSAGE( "SALOME_Container_i::create_component_instance : OK")
             comp_o = comp_i._this()
             self._listInstances_map[instanceName] = comp_i
-        except:
+        except Exception:
             import traceback
             traceback.print_exc()
             MESSAGE( "SALOME_Container_i::create_component_instance : NOT OK")
index a4281285b9f7a6726f60df02a69d7ef20b5d3e78..49ed9e5e2e89dad3bb5c4971c39b94d871438bef 100644 (file)
@@ -87,7 +87,7 @@ class PyNode_i (Engines__POA.PyNode,Generic):
     try:
       ccode=compile(code,self.nodeName,'exec')
       exec(ccode, self.context)
-    except:
+    except Exception:
       raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"","PyScriptNode (%s) : code to be executed \"%s\"" %(self.nodeName,code),0))
 
   def execute(self,funcName,argsin):
@@ -98,7 +98,7 @@ class PyNode_i (Engines__POA.PyNode,Generic):
       argsout=func(*argsin,**kws)
       argsout=pickle.dumps(argsout,-1)
       return argsout
-    except:
+    except Exception:
       exc_typ,exc_val,exc_fr=sys.exc_info()
       l=traceback.format_exception(exc_typ,exc_val,exc_fr)
       raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyNode: %s, function: %s" % (self.nodeName,funcName),0))
@@ -134,14 +134,14 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
     try:
       ccode=compile(code,self.nodeName,'exec')
       exec(ccode, self.context)
-    except:
+    except Exception:
       raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"","PyScriptNode (%s) : code to be executed \"%s\"" %(self.nodeName,code),0))
 
   def assignNewCompiledCode(self,codeStr):
     try:
       self.code=codeStr
       self.ccode=compile(codeStr,self.nodeName,'exec')
-    except:
+    except Exception:
       raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"","PyScriptNode.assignNewCompiledCode (%s) : code to be executed \"%s\"" %(self.nodeName,codeStr),0))
 
   def execute(self,outargsname,argsin):
@@ -157,7 +157,7 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
         argsout.append(self.context[arg])
       argsout=pickle.dumps(tuple(argsout),-1)
       return argsout
-    except:
+    except Exception:
       exc_typ,exc_val,exc_fr=sys.exc_info()
       l=traceback.format_exception(exc_typ,exc_val,exc_fr)
       raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode: %s, outargsname: %s" % (self.nodeName,outargsname),0))
@@ -168,7 +168,7 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
     try:
       _,kws=pickle.loads(argsin)
       self.context.update(kws)
-    except:
+    except Exception:
       exc_typ,exc_val,exc_fr=sys.exc_info()
       l=traceback.format_exception(exc_typ,exc_val,exc_fr)
       raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode:First %s" % (self.nodeName),0))
@@ -184,7 +184,7 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
         argsout.append(self.context[arg])
       argsout=pickle.dumps(tuple(argsout),-1)
       return argsout
-    except:
+    except Exception:
       exc_typ,exc_val,exc_fr=sys.exc_info()
       l=traceback.format_exception(exc_typ,exc_val,exc_fr)
       raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode:Second %s, outargsname: %s" % (self.nodeName,outargsname),0))
@@ -192,7 +192,7 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
   def getValueOfVarInContext(self,varName):
     try:
       return pickle.dumps(self.context[varName],-1)
-    except:
+    except Exception:
       exc_typ,exc_val,exc_fr=sys.exc_info()
       l=traceback.format_exception(exc_typ,exc_val,exc_fr)
       raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode: %s" %self.nodeName,0))
@@ -201,7 +201,7 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
   def assignVarInContext(self, varName, value):
     try:
       self.context[varName][0] = pickle.loads(value)
-    except:
+    except Exception:
       exc_typ,exc_val,exc_fr=sys.exc_info()
       l=traceback.format_exception(exc_typ,exc_val,exc_fr)
       raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode: %s" %self.nodeName,0))
@@ -210,7 +210,7 @@ class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
   def callMethodOnVarInContext(self, varName, methodName, args):
     try:
       return pickle.dumps( getattr(self.context[varName][0],methodName)(*pickle.loads(args)),-1 )
-    except:
+    except Exception:
       exc_typ,exc_val,exc_fr=sys.exc_info()
       l=traceback.format_exception(exc_typ,exc_val,exc_fr)
       raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode: %s" %self.nodeName,0))
index ad8f52425290c391da1687a5cb6c3e8323bba9b1..2aa01975bdc5ba6dd057e731dc61fe403a3f316e 100644 (file)
@@ -136,7 +136,7 @@ if not flags:
         # dl module can be unavailable
         import dl
         flags = dl.RTLD_NOW | dl.RTLD_GLOBAL
-    except:
+    except Exception:
         pass
     pass
 if not flags:
@@ -144,7 +144,7 @@ if not flags:
         # DLFCN module can be unavailable
         import DLFCN
         flags = DLFCN.RTLD_NOW | DLFCN.RTLD_GLOBAL
-    except:
+    except Exception:
         pass
     pass
 if not flags:
@@ -152,7 +152,7 @@ if not flags:
         # ctypes module can be unavailable
         import ctypes
         flags = ctypes.RTLD_GLOBAL
-    except:
+    except Exception:
         pass
     pass
 
@@ -341,7 +341,7 @@ def salome_close():
     try:
         # study can be clear either from GUI or directly with salome.myStudy.Clear()
         myStudy.Clear()
-    except:
+    except Exception:
         pass
     salome_initial=True
     salome_iapp_close()
@@ -392,7 +392,7 @@ def salome_shutdown_containers_with_session():
     for cont,(root,cont_name) in li:
         try:
             cont.Shutdown()
-        except:
+        except Exception:
             pass
         ref_in_ns = "/".join(root+[cont_name])
         naming_service.Destroy_Name(ref_in_ns)
index 0f3f18f1dfa0f9eb934c8de449b1a225f2c31da8..8c43b40e28be33a9cdc66f9cc005c510f17ace0b 100644 (file)
@@ -19,7 +19,7 @@
 #
 
 ## \defgroup enumerate enumerate
-#  \{ 
+#  \{
 #  \details Emulates a C-like enum for python
 #  \}
 
@@ -30,13 +30,13 @@ __date__ = "$1 avr. 2010 09:08:02$"
 #  of strings to be used as the enum symbolic keys. The enum values are automatically
 #  generated as sequencing integer starting at the specified offset value.
 #  \ingroup enumerate
-class Enumerate(object):
+class Enumerate:
     """
     This class emulates a C-like enum for python. It is initialized with a list
     of strings to be used as the enum symbolic keys. The enum values are automatically
     generated as sequencing integer starting at the specified offset value.
     """
-    
+
     ## Canonical constructor.
     #  \param keys a list of string to be used as the enum symbolic keys. The enum values
     #  are automatically generated as a sequence of integers starting at the specified
index c41a2e8faf0ab68b15928b2e11c1df54ac1f6335..091dcf2e0ddc91706d3f6f5e78a6edbbf0012d70 100644 (file)
@@ -461,7 +461,7 @@ class StudyEditor:
             else:
                 self.builder.RemoveObject(item)
             ok = True
-        except:
+        except Exception:
             ok = False
         return ok
 
index 31022ce487a3eab3549565968afad4e02b5093f6..b469dcb55ef895b52bf19645ae23ba7bbe844bec 100644 (file)
@@ -145,7 +145,7 @@ def TEST_serialize():
     try:
         res_testdata.setName("An other name")
         print(res_testdata.getName())
-    except:
+    except Exception:
         print(e)
         return False
     return True
index d7c7dea6c04c0ded7d7d0b47e49bc14e0ab28e0f..00c58fbf0dd3cdd93306e65d5834fb7d6dfebcc7 100644 (file)
@@ -68,7 +68,7 @@ def hasDesktop():
 
 salome_iapp_initial = 1
 
-class SalomeOutsideGUI(object):
+class SalomeOutsideGUI:
     """
     Provides a replacement for class SalomeGUI outside GUI process.
     Do almost nothing
@@ -202,5 +202,5 @@ def register_module_in_study(name, syncCall=True):
                 session_server.emitMessage(message)
             else:
                 session_server.emitMessageOneWay(message)
-    except:
+    except Exception:
          pass
index 2721cf0a40971fbc123ca47c04e847c6dbd09b67..6920f0ba44fea617c0d94242342fee6dc70d2eb4 100644 (file)
@@ -29,76 +29,76 @@ Module salome_notebook gives access to Salome Notebook.
 
 import salome
 
-class PseudoStudyForNoteBook(object):
-    
+class PseudoStudyForNoteBook:
+
     def __init__(self, **kwargs):
         self.kwargs = kwargs
         pass
-    
+
     def GetVariableNames(self):
         return list(self.kwargs.keys())
-    
+
     def IsVariable(self, variableName):
         return variableName in self.kwargs
-    
+
     def IsReal(self, variableName):
         val = self.kwargs[variableName]
         try:
             float(val)
             return True
-        except:
+        except Exception:
             pass
         return False
-    
+
     IsInteger = IsReal
     IsBoolean = IsReal
-    
+
     def IsString(self, variableName):
         return not self.IsReal(variableName)
-    
+
     def GetString(self, variableName):
         return self.kwargs[variableName]
-    
+
     def GetReal(self, variableName):
         return float(self.kwargs[variableName])
-    
+
     GetInteger = GetReal
     GetBoolean = GetReal
-    
+
     pass
 
 class NoteBook:
-    
-    def __init__(self, theIsEnablePublish = True):
+
+    def __init__(self, theIsEnablePublish=True):
         if theIsEnablePublish:
             self.myStudy = salome.myStudy
         else:
             self.myStudy = PseudoStudyForNoteBook()
-    
+
     def set(self, variableName, variable):
         """
-        Create (or modify) variable with name "variableName" 
+        Create (or modify) variable with name "variableName"
         and value equal "theValue".
         """
         if isinstance(variable, float):
             self.myStudy.SetReal(variableName, variable)
-            
+
         elif isinstance(variable, int):
             self.myStudy.SetInteger(variableName, variable)
-            
+
         elif isinstance(variable, bool):
             self.myStudy.SetBoolean(variableName, variable)
-            
+
         elif isinstance(variable, str):
             self.myStudy.SetString(variableName, variable)
-            
+
     def get(self, variableName):
         """
         Return value of the variable with name "variableName".
         """
         aResult = None
         if self.myStudy.IsVariable(variableName):
-            
+
             if self.myStudy.IsReal(variableName):
                 aResult = self.myStudy.GetReal(variableName)
 
@@ -111,18 +111,18 @@ class NoteBook:
             elif self.myStudy.IsString(variableName):
                 aResult = self.myStudy.GetString(variableName)
                 aResult_orig = aResult
-                l = self.myStudy.GetVariableNames()
-                l.remove(variableName)
+                list_of_variables = self.myStudy.GetVariableNames()
+                list_of_variables.remove(variableName)
                 # --
                 # To avoid the smallest strings to be replaced first,
                 # the list is sorted by decreasing lengths
                 # --
-                l.sort(key=str.__len__)
-                l.reverse()
-                for name in l:
+                list_of_variables.sort(key=str.__len__)
+                list_of_variables.reverse()
+                for name in list_of_variables:
                     if aResult.find(name) >= 0:
                         val = self.get(name)
-                        aResult = aResult.replace(name, "%s"%(val))
+                        aResult = aResult.replace(name, "%s" % (val))
                         pass
                     pass
                 try:
@@ -131,18 +131,18 @@ class NoteBook:
                     msg = str(e)
                     msg += "\n"
                     msg += "A problem occurs while parsing "
-                    msg += "the variable %s "%(variableName.__repr__())
-                    msg += "with value %s ..."%(aResult_orig.__repr__())
+                    msg += "the variable %s " % (variableName.__repr__())
+                    msg += "with value %s ..." % (aResult_orig.__repr__())
                     msg += "\n"
                     msg += "Please, check your notebook !"
                     raise Exception(msg)
                 pass
-                
+
         return aResult
-    
-    def isVariable(self, variableName): 
+
+    def isVariable(self, variableName):
         """
-        Return true if variable with name "variableName" 
+        Return true if variable with name "variableName"
         exists in the study, otherwise return false.
         """
         return self.myStudy.IsVariable(variableName)
@@ -152,30 +152,32 @@ class NoteBook:
         value = float(typ(value))
         self.myStudy.SetStringAsDouble(variableName, value)
         return
-    
+
     def setAsReal(self, variableName):
         self.setAs(variableName, float)
         return
-    
+
     def setAsInteger(self, variableName):
         self.setAs(variableName, int)
         return
-    
+
     def setAsBool(self, variableName):
         self.setAs(variableName, bool)
         return
-    
+
     def check(self):
         for variableName in self.myStudy.GetVariableNames():
             self.get(variableName)
             pass
         return
-    
+
     pass
 
+
 def checkThisNoteBook(**kwargs):
-    note_book = NoteBook( False )
+    note_book = NoteBook(False)
     note_book.check()
     return
 
+
 notebook = NoteBook()
index a1d5c1cc0a87559868f3a4f2ffc05b53a45b9367..7ddfde2d774409a915215af74f5e9e04c4e25e27 100644 (file)
@@ -70,7 +70,7 @@ def getVersion( mod = "KERNEL", full = False ):
                     elif "version" in key.lower() or mod in key:
                         _salome_versions[ mod ][ 0 ] = val
                     pass
-            except:
+            except Exception:
                 pass
     v = _salome_versions[ mod ][ 0 ]
     if full and v is not None:
@@ -87,7 +87,7 @@ def getVersionMajor( mod = "KERNEL" ):
     ver = getVersion( mod )
     try:
         return ver.split( "." )[ 0 ]
-    except:
+    except Exception:
         pass
     return None
 
@@ -101,7 +101,7 @@ def getVersionMinor( mod = "KERNEL" ):
     ver = getVersion( mod )
     try:
         return ver.split( "." )[ 1 ]
-    except:
+    except Exception:
         pass
     return None
 
@@ -115,7 +115,7 @@ def getVersionRelease( mod = "KERNEL" ):
     ver = getVersion( mod )
     try:
         return ver.split( "." )[ 2 ]
-    except:
+    except Exception:
         pass
     return None
 
@@ -128,17 +128,17 @@ def getVersions( mod = "KERNEL" ):
     """
     try:
         major = int( getVersionMajor( mod ) )
-    except:
+    except Exception:
         major = 0
         pass
     try:
         minor = int( getVersionMinor( mod ) )
-    except:
+    except Exception:
         minor = 0
         pass
     try:
         rel = int( getVersionRelease( mod ) )
-    except:
+    except Exception:
         rel = 0
         pass
     return [ major, minor, rel ]
index e4f8fd6a3c824c2c77876f77d22745509b403bc7..d757f55edf5f2fb7f51981d415fc6ab7545fffaf 100755 (executable)
@@ -26,7 +26,7 @@ import time
 
 JOB_FILE_NAME = "jobDump.xml"
 
-class Job(object):
+class Job:
   """
   This class makes an easier access to SalomeLauncher.
   It adds an automatic save of the job's parameters after the launch. The save
@@ -62,7 +62,7 @@ class Job(object):
       with open(job_file_path, "r") as f:
         job_string = f.read()
       myjob.job_id = launcher.restoreJob(job_string)
-    except:
+    except Exception:
       myjob = None
     return myjob
 
index 8118098cd3baf60e5c8081c747e1748f40026927..4246d3ff0015540b273fa332bfa176d3937d7243 100644 (file)
@@ -37,7 +37,7 @@ def closeSalome():
         from PortManager import releasePort
         print("### release current port:", port)
         releasePort(port)
-    except:
+    except Exception:
         pass
 
 
@@ -54,7 +54,7 @@ def killNamingService():
     try:
       pid=output_com.split()[0]
       os.kill(int(pid),signal.SIGKILL)
-    except:
+    except Exception:
       print("killNamingService failed.")
 
 
@@ -68,7 +68,7 @@ def killProcess(process_id):
         print("stop process %s : %s"% (pid, cmd[0]))
         try:
             os.kill(int(pid),signal.SIGKILL)
-        except:
+        except Exception:
             print("  ---- process %s : %s inexistant"% (pid, cmd[0]))
             pass
         del process_id[pid]
index dfabbf11beb0444cadfe6c87bc0cc4fab06348b7..00360abd002ce31d6cc121e846b3c3ef5cac7902 100644 (file)
@@ -40,7 +40,7 @@ from string import *
 from SALOME_utilities import *
 #=============================================================================
 
-class SALOME_NamingServicePy_i(object):
+class SALOME_NamingServicePy_i:
     """
       A class to manage SALOME naming service from python code
     """
index c135daf08f010f8ff8e53d14c26bc7296d5ceb6f..7cfb353bd4f245e2284294f75005b91f31ec18b2 100644 (file)
@@ -49,7 +49,7 @@ class SALOME_DriverPy_i(SALOMEDS__POA.Driver):
     def Version(self):
         try:
             return self.getVersion()
-        except:
+        except Exception:
             return ''
 
     def Save(self, theComponent, theURL, isMultiFile):
index bb2228c67df557a34b426765de26a8af8e04fc53..5330628553a6efe1e8ef6c66845df6a90e0855b4 100644 (file)
@@ -23,7 +23,7 @@
 import SALOME
 import pickle
 
-class List(object):
+class List:
     def __init__(self,varPtr,isTemporaryVar=False):
         assert(isinstance(varPtr,SALOME._objref_StringDataServer))
         self._var_ptr=varPtr
@@ -67,7 +67,7 @@ class List(object):
 
     pass
 
-class Tuple(object):
+class Tuple:
     def __init__(self,varPtr,isTemporaryVar=False):
         assert(isinstance(varPtr,SALOME._objref_StringDataServer))
         self._var_ptr=varPtr
@@ -106,9 +106,9 @@ class Tuple(object):
         return (tuple,(self.local_copy(),))
 
     pass
-        
 
-class Int(object):
+
+class Int:
     def __init__(self,varPtr,isTemporaryVar=False):
         assert(isinstance(varPtr,SALOME._objref_StringDataServer))
         self._var_ptr=varPtr
@@ -148,7 +148,7 @@ class Int(object):
 
     pass
 
-class Dict(object):
+class Dict:
     def __init__(self,varPtr,isTemporaryVar=False):
         assert(isinstance(varPtr,SALOME._objref_StringDataServer))
         self._var_ptr=varPtr
index d1f09c1ac2ae1fa2452c6c6fe94a7de4dc36580f..07c03f742b8428145925bc32faf3855cef625157 100644 (file)
@@ -23,7 +23,7 @@ import SALOME
 import pickle
 import SALOMEWrappedStdType
 
-class InvokatorStyle(object):
+class InvokatorStyle:
     def __init__(self,varPtr):
         self._var_ptr=varPtr
     def ptr(self):
index a3b119c7960a4551b79ba670d9b97f6c93d6689a..ae771301166d32ea2fb0244b7fe7a26d1ff394b7 100644 (file)
@@ -82,7 +82,7 @@ try:
   versnb = string.strip(string.split(s, ":")[1])
   dirname=".salome_"+versnb
   file.close()
-except:
+except Exception:
   versnb = ""
   dirname=".salome"