From c5caed78b1be84de0e0a2fa480fb581fa94a83f2 Mon Sep 17 00:00:00 2001 From: Gbkng Date: Wed, 14 Feb 2024 09:49:33 +0100 Subject: [PATCH] feat(all): replace all usage of bare except clause with except Exception clause --- AllTestLauncherSat.py | 4 ++-- commands/application.py | 2 +- commands/compile.py | 4 ++-- commands/config.py | 2 +- commands/generate.py | 2 +- commands/jobs.py | 8 ++++---- commands/log.py | 6 +++--- commands/package.py | 8 ++++---- commands/template.py | 2 +- commands/test.py | 4 ++-- .../Application/config/splash_generator/splash2.py | 4 ++-- .../PythonComponent/src/PYCMP/PYCMP_utils.py | 4 ++-- .../PythonComponent8/src/PYCMP/PYCMP_utils.py | 4 ++-- src/ElementTree.py | 2 +- src/ElementTreePython2.py | 6 +++--- src/ElementTreePython3.py | 4 ++-- src/__init__.py | 14 +++++++------- src/architecture.py | 4 ++-- src/callerName.py | 2 +- src/compilation.py | 2 +- src/debug.py | 4 ++-- src/environment.py | 4 ++-- src/fork.py | 2 +- src/loggingSimple.py | 2 +- src/product.py | 10 +++++----- src/pyconf.py | 10 +++++----- src/returnCode.py | 2 +- src/salomeTools.py | 4 ++-- src/system.py | 4 ++-- src/test/TOOLS.py | 2 +- src/test_module.py | 8 ++++---- src/versionMinorMajorPatch.py | 8 ++++---- src/xmlManager.py | 2 +- test/test_501_paramiko.py | 2 +- test/test_sat5_0/log/test_launch_browser.py | 4 ++-- test/test_sat5_0/prepare/test_prepare.py | 2 +- 36 files changed, 79 insertions(+), 79 deletions(-) diff --git a/AllTestLauncherSat.py b/AllTestLauncherSat.py index eaa1a96..cf8319d 100755 --- a/AllTestLauncherSat.py +++ b/AllTestLauncherSat.py @@ -86,7 +86,7 @@ def errPrint(aStr): try: import unittestpy.HTMLTestRunner as HTST -except: +except Exception: HTST = None errPrint(""" WARNING: no HTML output available. @@ -96,7 +96,7 @@ WARNING: no HTML output available. try: import xmlrunner as XTST -except: +except Exception: XTST = None errPrint(""" WARNING: no XML output available for unittest. diff --git a/commands/application.py b/commands/application.py index 025baf3..4015ff1 100644 --- a/commands/application.py +++ b/commands/application.py @@ -155,7 +155,7 @@ def customize_app(config, appli_dir, logger): if text is not None: try: n.text = text.strip("\n\t").decode("UTF-8") - except: + except Exception: sys.stderr.write("################ %s %s\n" % (node_name, text)) n.text = "?" parent.append(n) diff --git a/commands/compile.py b/commands/compile.py index 0368549..12cfbe6 100644 --- a/commands/compile.py +++ b/commands/compile.py @@ -230,7 +230,7 @@ def compile_all_products(sat, config, options, products_infos, all_products_dict batch=True, verbose=0, logger_add_link = logger) - except: + except Exception: pass if check_salome_configuration: @@ -547,7 +547,7 @@ def compile_product_pip(sat, env=build_environ.environ.environ, stderr=subprocess.STDOUT).decode(sys.stdout.encoding).strip() pip_build_options=int(res_pip_version.split('.')[0]) < 21 - except: + except Exception: pip_build_options= True # d- install (in python or in separate product directory) if src.appli_test_property(config,"pip_install_dir", "python"): diff --git a/commands/config.py b/commands/config.py index a5997bb..24a95a8 100644 --- a/commands/config.py +++ b/commands/config.py @@ -1068,7 +1068,7 @@ def get_config_children(config, args): if dir(a).__contains__('keys'): vals = map(lambda x: head + '.' + x, [m for m in a.keys() if m.startswith(tail)]) - except: + except Exception: pass for v in sorted(vals): diff --git a/commands/generate.py b/commands/generate.py index fbd08aa..a6a83ce 100644 --- a/commands/generate.py +++ b/commands/generate.py @@ -147,7 +147,7 @@ def generate_component(config, compo, product_name, product_info, context, heade # get files to build a template GUI try: # try new yacsgen api gui_files = salome_compo.getGUIfilesTemplate(compo) - except: # use old yacsgen api + except Exception: # use old yacsgen api gui_files = salome_compo.getGUIfilesTemplate() else: gui_files = None diff --git a/commands/jobs.py b/commands/jobs.py index c043d70..b948a74 100644 --- a/commands/jobs.py +++ b/commands/jobs.py @@ -30,7 +30,7 @@ import re # generate problem try: import paramiko -except: +except Exception: paramiko = "import paramiko impossible" pass @@ -114,7 +114,7 @@ class Machine(object): except paramiko.SSHException: message = ( _("SSHException error connecting or " "establishing an SSH session")) - except: + except Exception: message = ( _("Error connecting or establishing an SSH session")) else: self._connection_successful = True @@ -215,7 +215,7 @@ class Machine(object): ": the server failed to execute the command\n") logger.write( src.printcolors.printcError(message)) return (None, None, None) - except: + except Exception: logger.write( src.printcolors.printcError(src.KO_STATUS + '\n')) return (None, None, None) else: @@ -327,7 +327,7 @@ class Job(object): ''' try: pids = self.get_pids() - except: + except Exception: return ("Unable to get the pid of the command.", "") cmd_kill = " ; ".join([("kill -2 " + pid) for pid in pids]) diff --git a/commands/log.py b/commands/log.py index 22a7885..fbdbaad 100644 --- a/commands/log.py +++ b/commands/log.py @@ -181,7 +181,7 @@ def ask_value(nb): x = int(rep) if x > nb: x = -1 - except: + except Exception: x = -1 return x @@ -269,7 +269,7 @@ def run(args, runner, logger): src.ensure_path_exists(os.path.join(logDir, "TEST")) shutil.copy(xsltest, os.path.join(logDir, "TEST")) shutil.copy(imgLogo, logDir) - except: + except Exception: # we are here if an user make sat log in jenkins LOGS without write rights # Make a warning and do nothing logger.warning("problem for writing in directory '%s', may be not owner." % logDir) @@ -338,7 +338,7 @@ def run(args, runner, logger): notShownCommands = notShownCommands) logger.write(src.printcolors.printc("OK"), 3) - except: + except Exception: logger.write(src.printcolors.printc("KO"), 3) logger.write(" problem update hat.xml", 3) diff --git a/commands/package.py b/commands/package.py index f91476e..c5ffbff 100644 --- a/commands/package.py +++ b/commands/package.py @@ -385,7 +385,7 @@ def hack_for_distene_licence(filepath, licence_file): import imp distene = imp.load_source('distene_licence', distene_licence_file) distene.set_distene_variables(context) - except: + except Exception: pass\n""" % licence_file text.insert(num_line + 1, text_to_insert) for line in text: @@ -948,7 +948,7 @@ def source_package(sat, config, logger, options, tmp_working_dir): if not src.architecture.is_windows(): try: t = os.getcwd() - except: + except Exception: # In the jobs, os.getcwd() can fail t = config.LOCAL.workdir os.chdir(tmp_working_dir) @@ -1447,7 +1447,7 @@ def project_package(config, name_project, project_file_path, ftp_mode, tmp_worki try: project_pyconf_cfg = config.PROJECTS.projects.__getattr__(name_project) - except: + except Exception: logger.write(""" WARNING: inexisting config.PROJECTS.projects.%s, try to read now from:\n%s\n""" % (name_project, project_file_path)) project_pyconf_cfg = src.pyconf.Config(project_file_path) @@ -1899,7 +1899,7 @@ Please add it in file: # case if no application, only package sat as 'sat package -t' try: app = runner.cfg.APPLICATION - except: + except Exception: app = None # unconditionaly remove the tmp_local_working_dir diff --git a/commands/template.py b/commands/template.py index e4ddc59..cdc1c81 100644 --- a/commands/template.py +++ b/commands/template.py @@ -35,7 +35,7 @@ except NameError: # Python 2/3 compatibility for execfile function try: execfile -except: +except Exception: def execfile(somefile, global_vars, local_vars): with open(somefile) as f: code = compile(f.read(), somefile, 'exec') diff --git a/commands/test.py b/commands/test.py index 62fd7fe..cac9b4c 100644 --- a/commands/test.py +++ b/commands/test.py @@ -174,7 +174,7 @@ def move_test_results(in_dir, what, out_dir, logger): #shutil.rmtree(finalPath) os.makedirs(finalPath) pathIsOk = True - except: + except Exception: logger.error(_("%s cannot be created.") % finalPath) finalPath = ask_a_path() @@ -664,7 +664,7 @@ def run(args, runner, logger): if os.access(tmp_dir, os.F_OK): try: shutil.rmtree(tmp_dir) - except: + except Exception: logger.error(_("error removing TT_TMP_RESULT %s\n") % tmp_dir) diff --git a/data/templates/Application/config/splash_generator/splash2.py b/data/templates/Application/config/splash_generator/splash2.py index 1521075..8c9e3cd 100755 --- a/data/templates/Application/config/splash_generator/splash2.py +++ b/data/templates/Application/config/splash_generator/splash2.py @@ -9,7 +9,7 @@ import os, sys try: __LANG__ = os.environ["LANG"] # original locale -except: +except Exception: __LANG__ = "en_US.utf8" #default __FR__={ @@ -27,7 +27,7 @@ def _loc(text): if "FR" in __LANG__: try: return __FR__[text] - except: + except Exception: return text return text diff --git a/data/templates/PythonComponent/src/PYCMP/PYCMP_utils.py b/data/templates/PythonComponent/src/PYCMP/PYCMP_utils.py index 56e1557..da4f92b 100755 --- a/data/templates/PythonComponent/src/PYCMP/PYCMP_utils.py +++ b/data/templates/PythonComponent/src/PYCMP/PYCMP_utils.py @@ -88,7 +88,7 @@ def verbose(): if __verbose__ is None: try: __verbose__ = int( os.getenv( 'SALOME_VERBOSE', 0 ) ) - except: + except Exception: __verbose__ = 0 pass pass @@ -177,7 +177,7 @@ def findOrCreateComponent( study ): try: builder.DefineComponentInstance( father, getEngine() ) pass - except: + except Exception: pass pass return father diff --git a/data/templates/PythonComponent8/src/PYCMP/PYCMP_utils.py b/data/templates/PythonComponent8/src/PYCMP/PYCMP_utils.py index 56e1557..da4f92b 100755 --- a/data/templates/PythonComponent8/src/PYCMP/PYCMP_utils.py +++ b/data/templates/PythonComponent8/src/PYCMP/PYCMP_utils.py @@ -88,7 +88,7 @@ def verbose(): if __verbose__ is None: try: __verbose__ = int( os.getenv( 'SALOME_VERBOSE', 0 ) ) - except: + except Exception: __verbose__ = 0 pass pass @@ -177,7 +177,7 @@ def findOrCreateComponent( study ): try: builder.DefineComponentInstance( father, getEngine() ) pass - except: + except Exception: pass pass return father diff --git a/src/ElementTree.py b/src/ElementTree.py index b871200..65c63c9 100644 --- a/src/ElementTree.py +++ b/src/ElementTree.py @@ -30,7 +30,7 @@ else: """ try: aStr = etree.tostring(node, encoding='unicode', method="pretty_xml") - except: + except Exception: print("*****************************\n problem node", node) # try no pretty aStr = etree.tostring(node, encoding='unicode') diff --git a/src/ElementTreePython2.py b/src/ElementTreePython2.py index d1ba909..4b31874 100644 --- a/src/ElementTreePython2.py +++ b/src/ElementTreePython2.py @@ -700,7 +700,7 @@ class ElementTree: if items or xmlns_items: try: items = sorted(items) # lexical order - except: + except Exception: print("*** problem sorting items", items) for k, v in items: try: @@ -1086,7 +1086,7 @@ class TreeBuilder: for item in self._data: try: text += item - except: + except Exception: text += item.decode() if self._tail: assert self._last.tail is None, "internal error (tail)" @@ -1292,7 +1292,7 @@ class XMLTreeBuilder: """ try: self._parser.Parse(data, 0) - except: + except Exception: print("*** problem feed:\n%s" % data.decode('utf-8')) ## diff --git a/src/ElementTreePython3.py b/src/ElementTreePython3.py index 68635ce..74adb5d 100644 --- a/src/ElementTreePython3.py +++ b/src/ElementTreePython3.py @@ -1266,7 +1266,7 @@ def iterparse(source, events=None, parser=None): close_source = True try: return _IterParseIterator(source, events, parser, close_source) - except: + except Exception: if close_source: source.close() raise @@ -1365,7 +1365,7 @@ class _IterParseIterator: else: self._root = self._parser._close_and_return_root() self.root = self._root - except: + except Exception: if self._close_file: self._file.close() raise diff --git a/src/__init__.py b/src/__init__.py index 9f3e8d1..34aecde 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -403,14 +403,14 @@ class Path: try: os.symlink(str(path), self.path) return True - except: + except Exception: return False def copylink(self, path): try: os.symlink(os.readlink(self.path), str(path)) return True - except: + except Exception: return False def copydir(self, dst, smart=False): @@ -429,14 +429,14 @@ class Path: dstname = dst + name srcname.copy(dstname, smart) return True - except: + except Exception: return False def copyfile(self, path): try: shutil.copy2(self.path, str(path)) return True - except: + except Exception: return False def find_file_in_lpath(file_name, lpath, additional_dir = ""): @@ -507,7 +507,7 @@ def find_file_in_ftppath(file_name, ftppath, installation_dir, logger, additiona ftp.cwd(directory) if additional_dir: ftp.cwd(additional_dir) - except: + except Exception: logger.error("while connecting to ftp server %s\n" % ftp_server) continue @@ -517,7 +517,7 @@ def find_file_in_ftppath(file_name, ftppath, installation_dir, logger, additiona if ftp.size(file_name_md5) > 0: with open(destination_md5,'wb') as dest_file_md5: ftp.retrbinary("RETR "+file_name_md5, dest_file_md5.write) - except: + except Exception: pass try: @@ -527,7 +527,7 @@ def find_file_in_ftppath(file_name, ftppath, installation_dir, logger, additiona ftp.retrbinary("RETR "+file_name, dest_file.write) logger.write(" Archive %s was retrieved and stored in %s\n" % (file_name, destination), 3) return destination - except: + except Exception: logger.error("File not found in ftp_archive %s\n" % ftp_server) return False diff --git a/src/architecture.py b/src/architecture.py index 6e83d0b..f631fbc 100644 --- a/src/architecture.py +++ b/src/architecture.py @@ -29,10 +29,10 @@ from platform import system,python_version,release # write an error message if distro is not installed try: from platform import linux_distribution -except: +except Exception: try: from distro import linux_distribution - except: + except Exception: print ("\nError :\n" " linux_distribution was removed from platform module in Python 3.8+\n" " For python 3.8+ sat requires distro module to get information on linux distribution.\n" diff --git a/src/callerName.py b/src/callerName.py index 9fd0308..33df6ce 100644 --- a/src/callerName.py +++ b/src/callerName.py @@ -116,7 +116,7 @@ def caller_name_stack(skip=1): if namesrc == "__main__": namesrc = os.path.basename(fr.f_globals["__file__"]) lineno.insert(0, (namesrc + "[%s]" % fr.f_lineno)) - except: + except Exception: lineno.insert(0, ("??", fr.f_lineno)) if codename != '': # top level usually diff --git a/src/compilation.py b/src/compilation.py index 751fe73..b8e84bd 100644 --- a/src/compilation.py +++ b/src/compilation.py @@ -440,7 +440,7 @@ CC=\\"hack_libtool\\"%g" libtool''' pymodule = imp.load_source(product + "_compile_script", script) self.nb_proc = nb_proc retcode = pymodule.compil(self.config, self, self.logger) - except: + except Exception: __, exceptionValue, exceptionTraceback = sys.exc_info() self.logger.write(str(exceptionValue), 1) import traceback diff --git a/src/debug.py b/src/debug.py index 330fb6d..da1ca94 100755 --- a/src/debug.py +++ b/src/debug.py @@ -61,7 +61,7 @@ import src # Compatibility python 2/3 for unicode try: _test = unicode -except: +except Exception: unicode = str # Compatibility python 2/3 for StringIO @@ -272,7 +272,7 @@ def _saveConfigRecursiveDbg(config, aStream, indent, path, nb): try: #type config, mapping order = object.__getattribute__(config, 'order') data = object.__getattribute__(config, 'data') - except: + except Exception: aStream.write("%s%s : '%s'\n" % (indstr, path, str(config))) return for key in sorted(data): #order): # data as sort alphabetical, order as initial order diff --git a/src/environment.py b/src/environment.py index a706d5d..74e6bbd 100644 --- a/src/environment.py +++ b/src/environment.py @@ -321,7 +321,7 @@ class SalomeEnviron: for k in self.environ.environ.keys(): try: value = self.get(k) - except: + except Exception: value = "?" out.write("%s=%s\n" % (k, value)) @@ -743,7 +743,7 @@ class SalomeEnviron: # not mandatory, if set_nativ_env not defined, we do nothing if "set_nativ_env" in dir(pyproduct): pyproduct.set_nativ_env(self) - except: + except Exception: __, exceptionValue, exceptionTraceback = sys.exc_info() print(exceptionValue) import traceback diff --git a/src/fork.py b/src/fork.py index aa239de..e4492f0 100644 --- a/src/fork.py +++ b/src/fork.py @@ -131,7 +131,7 @@ def batch_salome(cmd, logger, cwd, args, getTmpDir, try: statinfo = os.stat(os.path.join(tmp_dir, file_name)) currentTime = statinfo.st_mtime - except: + except Exception: pass if currentTime and currentTime > beginTime: diff --git a/src/loggingSimple.py b/src/loggingSimple.py index 177b342..ddbb0b7 100755 --- a/src/loggingSimple.py +++ b/src/loggingSimple.py @@ -377,7 +377,7 @@ class StreamHandlerSimple(LOGI.StreamHandler, object): # object force new-style self.flush() except (KeyboardInterrupt, SystemExit): raise - except: + except Exception: self.handleError(record) diff --git a/src/product.py b/src/product.py index a679e44..091ffe2 100644 --- a/src/product.py +++ b/src/product.py @@ -355,7 +355,7 @@ Please provide a 'compil_script' key in its definition.""") % product_name "prod_name" : prod_info.name}) raise src.SatException(msg) patches.append(patch_path) - except: + except Exception: DBG.tofix("problem in prod_info.patches", prod_info) prod_info.patches = patches @@ -425,7 +425,7 @@ def get_product_section(config, product_name, version, section=None): # decode version number try: versionMMP = VMMP.MinorMajorPatch(version) - except: # example setuptools raise "minor in major_minor_patch is not integer: '0_6c11'" + except Exception: # example setuptools raise "minor in major_minor_patch is not integer: '0_6c11'" versionMMP = None # if a section is explicitely specified we select it @@ -666,7 +666,7 @@ def add_compile_config_file(p_info, config): try: with open(aFile, 'w') as f: p_info.__save__(f, evaluated=True) # evaluated expressions mode - except: + except Exception: # sometime some information cannot be evaluated. # for example, in the context of non VCS archives, information on git server is not available. DBG.write("Warning : sat was not able to evaluate and write down some information in file %s" % aFile) @@ -829,7 +829,7 @@ def get_products_list(options, cfg, logger): else: res.append((p_name, p_info)) ok.append(p_name) - except: + except Exception: res.append((p_name, p_info)) ok.append(p_name) else: @@ -840,7 +840,7 @@ def get_products_list(options, cfg, logger): ok.append(p_name) else: ko.append(p_name) - except: + except Exception: ko.append(p_name) if len(ok) != len(resAll): diff --git a/src/pyconf.py b/src/pyconf.py index 5957d6d..d19b577 100644 --- a/src/pyconf.py +++ b/src/pyconf.py @@ -155,7 +155,7 @@ else: try: has_utf32 = True -except: +except Exception: has_utf32 = False class ConfigInputStream(object): @@ -951,7 +951,7 @@ class Reference(object): rv = eval(str(self)[1:-1], vars(ns)) found = True break - except: + except Exception: pass if found: break @@ -963,7 +963,7 @@ class Reference(object): key = item[1] rv = rv[key] break - except: + except Exception: rv = None pass current = object.__getattribute__(current, 'parent') @@ -1632,13 +1632,13 @@ class ConfigMerger(object): continue try: exec( 'map1.' + key + " = " + repr(overwrite_instruction[key])) - except: + except Exception: exec('map1.' + key + " = " + str(overwrite_instruction[key])) else: for key in overwrite_instruction.keys(): try: exec('map1.' + key + " = " + repr(overwrite_instruction[key])) - except: + except Exception: exec('map1.' + key + " = " + str(overwrite_instruction[key])) def mergeMapping(self, map1, map2): diff --git a/src/returnCode.py b/src/returnCode.py index 1af9116..240eb63 100644 --- a/src/returnCode.py +++ b/src/returnCode.py @@ -148,7 +148,7 @@ class ReturnCode(object): """return system return code as bash or bat""" try: return self._TOSYS[self._status] - except: + except Exception: return self._TOSYS[self.NA_STATUS] def toXmlPassed(self): diff --git a/src/salomeTools.py b/src/salomeTools.py index a49524b..2b1a50d 100755 --- a/src/salomeTools.py +++ b/src/salomeTools.py @@ -67,7 +67,7 @@ gettext.install("salomeTools", os.path.join(srcdir, "i18n")) try: _LANG = os.environ["LANG"] # original locale -except: +except Exception: _LANG = "en_US.utf8" #default # The possible hooks : @@ -356,7 +356,7 @@ class Sat(object): sys.stderr = ff import paramiko sys.stderr = saveout - except: + except Exception: sys.stderr = saveout continue diff --git a/src/system.py b/src/system.py index acb6fea..cc500d0 100644 --- a/src/system.py +++ b/src/system.py @@ -53,7 +53,7 @@ def show_in_editor(editor, filePath, logger): logger.write('Launched command:\n' + cmd + '\n', 5) p = SP.Popen(cmd, shell=True) p.communicate() - except: + except Exception: logger.write(printcolors.printcError(_("Unable to edit file %s\n") % filePath), 1) @@ -444,7 +444,7 @@ def check_system_pkg(check_cmd,pkg): try: output = SP.check_output(['grep', pkg], stdin=p.stdout) msg_status=src.printcolors.printcSuccess("OK") - except: + except Exception: msg_status=src.printcolors.printcError("KO") msg_status+=" (package is not installed!)\n" elif check_cmd[0] == "dpkg-query": diff --git a/src/test/TOOLS.py b/src/test/TOOLS.py index 64b4b11..7e2b9e1 100644 --- a/src/test/TOOLS.py +++ b/src/test/TOOLS.py @@ -90,7 +90,7 @@ def compMED(file1, file2, tol=0, diff_flags=""): try: line.index('Universal name of mesh') continue - except: + except Exception: dumpfile.write(line.replace(med, 'filename')) return dump diff --git a/src/test_module.py b/src/test_module.py index 03c7b58..218ba18 100644 --- a/src/test_module.py +++ b/src/test_module.py @@ -19,7 +19,7 @@ # Python 2/3 compatibility for execfile function try: execfile -except: +except Exception: def execfile(somefile, global_vars, local_vars): with open(somefile) as f: code = compile(f.read(), somefile, 'exec') @@ -354,12 +354,12 @@ class Test: if 'time' in ldic: try: exec_time = float(ldic['time']) - except: + except Exception: pass results[test] = [status, exec_time, callback, expected] - except: + except Exception: results[test] = ["?", -1, "", []] # results[test] = [src.O_STATUS, -1, open(resfile, 'r').read(), []] @@ -484,7 +484,7 @@ echo -e 'import os\nprint(os.environ[\"KERNEL_ROOT_DIR\"])' > tmpscript.py try: grid = imp.load_module(sal_uts, file_, pathname, description) return grid.getLogDir - except: + except Exception: grid = imp.load_module(sal_uts, file_, pathname, description) return grid.getTmpDir finally: diff --git a/src/versionMinorMajorPatch.py b/src/versionMinorMajorPatch.py index a8df954..e7d8731 100755 --- a/src/versionMinorMajorPatch.py +++ b/src/versionMinorMajorPatch.py @@ -90,7 +90,7 @@ def toList_majorMinorPatch(aStr, verbose=False): try: ii = int(res[0]) - except: + except Exception: msg = "major in major_minor_patch is not integer: '%s'" % aStr raise Exception(msg) if ii < 0: @@ -99,7 +99,7 @@ def toList_majorMinorPatch(aStr, verbose=False): try: ii = int(res[1]) - except: + except Exception: msg = "minor in major_minor_patch is not integer: '%s'" % aStr raise Exception(msg) if ii < 0: @@ -108,7 +108,7 @@ def toList_majorMinorPatch(aStr, verbose=False): try: ii = int(res[2]) - except: + except Exception: msg = "patch in major_minor_patch is not integer: '%s'" % aStr raise Exception(msg) if ii < 0: @@ -186,7 +186,7 @@ def getRange_majorMinorPatch(aStr, verbose=False): try: rMin = MinorMajorPatch(aMin) rMax = MinorMajorPatch(aMax) - except: + except Exception: msg = "problem version range in '%s'" % aStr raise Exception(msg) """if verbose: diff --git a/src/xmlManager.py b/src/xmlManager.py index 6a4bb66..8f7f28e 100644 --- a/src/xmlManager.py +++ b/src/xmlManager.py @@ -23,7 +23,7 @@ try: # For python2 import sys reload(sys) sys.setdefaultencoding('utf8') -except: +except Exception: pass import src diff --git a/test/test_501_paramiko.py b/test/test_501_paramiko.py index ab5f92b..3b0c7fb 100755 --- a/test/test_501_paramiko.py +++ b/test/test_501_paramiko.py @@ -161,7 +161,7 @@ class TestCase(unittest.TestCase): try: import paramiko as PK - except: + except Exception: print("\nproblem 'import paramiko', no tests") return diff --git a/test/test_sat5_0/log/test_launch_browser.py b/test/test_sat5_0/log/test_launch_browser.py index a9c8be4..c06bddf 100755 --- a/test/test_sat5_0/log/test_launch_browser.py +++ b/test/test_sat5_0/log/test_launch_browser.py @@ -64,7 +64,7 @@ class TestCase(unittest.TestCase): sat.log('-t') OK = "OK" sys.stdin = sys.__stdin__ - except: + except Exception: sys.stdin = sys.__stdin__ self.assertEqual(OK, "OK") @@ -84,7 +84,7 @@ class TestCase(unittest.TestCase): sat.log('appli-test -t --last') OK = "OK" sys.stdin = sys.__stdin__ - except: + except Exception: pass self.assertEqual(OK, "OK") diff --git a/test/test_sat5_0/prepare/test_prepare.py b/test/test_sat5_0/prepare/test_prepare.py index 3340547..d6779a8 100755 --- a/test/test_sat5_0/prepare/test_prepare.py +++ b/test/test_sat5_0/prepare/test_prepare.py @@ -91,7 +91,7 @@ class TestCase(unittest.TestCase): try: sat.prepare(appli + " --force --force_patch") OK = 'OK' - except: + except Exception: pass self.assertEqual(OK, 'OK') -- 2.39.2