From c7baa5a724520bd3eff509ce905a947e6ba265ff Mon Sep 17 00:00:00 2001 From: mesmith75 Date: Mon, 8 Jul 2024 10:27:36 +0000 Subject: [PATCH 1/2] autopep8 action fixes --- .../Core/GangaRepository/SubJobXMLList.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ganga/GangaCore/Core/GangaRepository/SubJobXMLList.py b/ganga/GangaCore/Core/GangaRepository/SubJobXMLList.py index 064012705d..61ddb800d4 100644 --- a/ganga/GangaCore/Core/GangaRepository/SubJobXMLList.py +++ b/ganga/GangaCore/Core/GangaRepository/SubJobXMLList.py @@ -181,7 +181,7 @@ def load_subJobIndex(self): new_data = self._registry.getIndexCache(self.__getitem__(subjob_id)) self._subjobIndexData[subjob_id] = new_data continue - #self._subjobIndexData = {} + # self._subjobIndexData = {} except Exception as err: logger.debug("Subjob Index file open, error: %s" % err) self._subjobIndexData = {} @@ -328,7 +328,7 @@ def getMasterID(self): except Exception as err: try: fqid = job_obj.id - except: + except BaseException: fqid = "unknown" else: fqid = "unknown" @@ -340,11 +340,11 @@ def _loadSubJobFromDisk(self, subjob_data): subjob_data (str): filename for the subjob 'data' file we're interested in """ # For debugging where this was called from to try and push it to as high a level as possible at runtime - #print("SJXML Load") - #import traceback + # print("SJXML Load") + # import traceback # traceback.print_stack() # print("\n\n\n") - #import sys + # import sys # sys.exit(-1) job_obj = self.getSafeJob() if job_obj is not None: @@ -414,7 +414,9 @@ def _getItem(self, index): if isinstance(x, IOError) and x.errno == errno.ENOENT: raise IOError("Subobject %s not found: %s" % (index, x)) else: - raise RepositoryError(self._registry.repository, "IOError on loading subobject %s: %s" % (index, x)) + raise RepositoryError( + self._registry.repository, "IOError on loading subobject %s: %s" % + (index, x)) from GangaCore.Core.GangaRepository.VStreamer import from_file @@ -490,7 +492,7 @@ def getCachedData(self, index): def getAllCachedData(self): """Get the cached data from the index for all subjobs""" cached_data = [] - #logger.debug("Cache: %s" % self._subjobIndexData) + # logger.debug("Cache: %s" % self._subjobIndexData) if len(self._subjobIndexData) == len(self): for i in range(len(self)): if self.isLoaded(i): @@ -573,7 +575,7 @@ def _private_display(self, reg_slice, this_format, default_width, markup): vals = [] for item in reg_slice._display_columns: display_str = "display:" + str(item) - #logger.debug("Looking for : %s" % display_str) + # logger.debug("Looking for : %s" % display_str) width = reg_slice._display_columns_width.get(item, default_width) try: if item == 'fqid': From a8db6a163d845cfe8f2a2ded2b302132aa507303 Mon Sep 17 00:00:00 2001 From: Mark Smith Date: Mon, 8 Jul 2024 12:09:42 +0100 Subject: [PATCH 2/2] Update SubJobXMLList.py --- .../Core/GangaRepository/SubJobXMLList.py | 38 +++++++++++-------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/ganga/GangaCore/Core/GangaRepository/SubJobXMLList.py b/ganga/GangaCore/Core/GangaRepository/SubJobXMLList.py index 61ddb800d4..189d7c73cb 100644 --- a/ganga/GangaCore/Core/GangaRepository/SubJobXMLList.py +++ b/ganga/GangaCore/Core/GangaRepository/SubJobXMLList.py @@ -1,14 +1,12 @@ -from GangaCore.GPIDev.Schema.Schema import Schema, SimpleItem, Version +from GangaCore.GPIDev.Schema.Schema import Schema, Version from GangaCore.GPIDev.Base.Objects import GangaObject from GangaCore.Utility.logging import getLogger from GangaCore.Core.GangaRepository.GangaRepository import RepositoryError from GangaCore.Core.exceptions import GangaException -from GangaCore.GPIDev.Base.Proxy import stripProxy from GangaCore.Core.GangaRepository.VStreamer import XMLFileError import errno import copy import threading -import shutil from os import listdir, path, stat logger = getLogger() @@ -152,7 +150,7 @@ def load_subJobIndex(self): try: index_file_obj = open(index_file, "rb") self._subjobIndexData = from_file(index_file_obj)[0] - except IOError as err: + except IOError: self._subjobIndexData = None self._setDirty() @@ -249,7 +247,8 @@ def __iter__(self): return SJXLIterator(self) def __get_dataFile(self, index, force_backup=False): - """Get the filename for this file (with out without backup '~'. Store already determine combinations in _cached_filenames for speed + """Get the filename for this file (with out without backup '~'. + Store already determine combinations in _cached_filenames for speed Args: index (int): This is the index of the subjob we're interested in force_backup (bool): Should we force the loading from the backup XML @@ -270,7 +269,8 @@ def __get_dataFile(self, index, force_backup=False): return subjob_data def __len__(self): - """ return length or lookup the last modified time compare against self._stored_len[0] and if nothings changed return self._stored_len[1]""" + """ return length or lookup the last modified time compare against self._stored_len[0] + and if nothings changed return self._stored_len[1]""" try: this_time = stat(self._jobDirectory).st_ctime except OSError: @@ -315,7 +315,7 @@ def getSafeJob(self): logger.debug("Error: %s" % err) try: job_obj = self._getParent() - except Exception as err: + except Exception: job_obj = None return job_obj @@ -325,7 +325,7 @@ def getMasterID(self): if job_obj is not None: try: fqid = job_obj.getFQID('.') - except Exception as err: + except Exception: try: fqid = job_obj.id except BaseException: @@ -423,7 +423,7 @@ def _getItem(self, index): # load the subobject into a temporary object try: loaded_sj = from_file(sj_file)[0] - except (IOError, XMLFileError) as err: + except (IOError, XMLFileError): try: logger.warning("Loading subjob #%s for job #%s from backup, recent changes may be lost" % ( @@ -558,8 +558,10 @@ def _setFlushed(self): super(SubJobXMLList, self)._setFlushed() def _private_display(self, reg_slice, this_format, default_width, markup): - """ This is a private display method which makes use of the display slice as well as knowlede of the wanted format, default_width and markup to be used - Given it's display method this returns a displayable string. Given it's tied into the RegistrySlice it's similar to that + """ This is a private display method which makes use of the display slice as well as knowlede of the wanted format, + default_width and markup to be used. + Given it's display method this returns a displayable string. + Given it's tied into the RegistrySlice it's similar to that Args: reg_slice (RegistrySlice): This is the registry slice which is the context in which this is called this_format (str): This is the format used in the registry slice for the formatting of the table @@ -593,8 +595,9 @@ def _private_display(self, reg_slice, this_format, default_width, markup): @staticmethod def checkJobHasChildren(jobDirectory, datafileName): """ Return True/False if given (job?) object has children associated with it - This function will test for the presence of all of the subjob XML in the appropriate folders and will trigger an exception - if/when some of the xml files are missing. This is subtly different to the default countSubJobDirs behaviour. + This function will test for the presence of all of the subjob XML in the appropriate folders + and will trigger an exception if/when some of the xml files are missing. + This is subtly different to the default countSubJobDirs behaviour. Args: jobDirectory (str): name of folder to be examined datafileName (str): name of the files containing the xml, i.e. 'data' by convention @@ -607,12 +610,15 @@ def checkJobHasChildren(jobDirectory, datafileName): @staticmethod def countSubJobDirs(jobDirectory, datafileName, checkDataFiles): - """ I'm a function which returns a number, my number corresponds to the amount of sequentially listed numerically named folders exiting within 'jobDirectory' - This (optionally) checks for the existance of all of the XML files. This is useful during a call to 'jobHasChildrenTest' but not when calling __len__ repeatedly + """ I'm a function which returns a number, my number corresponds to the amount of sequentially + listed numerically named folders exiting within 'jobDirectory'. + This (optionally) checks for the existance of all of the XML files. + This is useful during a call to 'jobHasChildrenTest' but not when calling __len__ repeatedly Args: jobDirectory (str): name of folder to be examined datafileName (str): name of the files containing the xml, i.e. 'data' by convention - checkDataFiles (bool): if True check for the existance of all of the data files and check this against the numerically named folders + checkDataFiles (bool): if True check for the existance of all of the data files + and check this against the numerically named folders """ jobDirectoryList = listdir(jobDirectory)