From 2ff508f1b76ef1ae0d64dba462908c604d04e98b Mon Sep 17 00:00:00 2001 From: scott snyder <snyder@bnl.gov> Date: Mon, 6 Jan 2020 16:21:40 +0100 Subject: [PATCH] AthenaCommon: More python 3 fixes - Give exception information on failed import. - Relative import fix - iteritems - string.split --- Control/AthenaCommon/python/JobProperties.py | 4 +++- Control/AthenaCommon/python/PhysicalConstants.py | 4 ++-- Control/AthenaCommon/share/MemTraceInclude.py | 7 ++++--- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Control/AthenaCommon/python/JobProperties.py b/Control/AthenaCommon/python/JobProperties.py index e26059c7e08..4a6805b9e97 100755 --- a/Control/AthenaCommon/python/JobProperties.py +++ b/Control/AthenaCommon/python/JobProperties.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration #======================================================================= # File: JobProperties/python/JobProperties.py @@ -551,6 +551,8 @@ class JobPropertyContainer (object): module=__import__(module_name,globals(),locals(),\ ['JobProperties']) except ImportError: + import traceback + traceback.print_exc() self._log.error(" import_JobProperties: No module named %s", module_name) return None diff --git a/Control/AthenaCommon/python/PhysicalConstants.py b/Control/AthenaCommon/python/PhysicalConstants.py index ae29fb01eb6..3b16529de37 100755 --- a/Control/AthenaCommon/python/PhysicalConstants.py +++ b/Control/AthenaCommon/python/PhysicalConstants.py @@ -1,4 +1,4 @@ -# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # File: AthenaCommon/share/PhysicalConstants.py # Author: Wim Lavrijsen (LBNL, WLavrijsen@lbl.gov) @@ -43,7 +43,7 @@ from __future__ import print_function -from SystemOfUnits import henry, eplus, MeV, joule, s, m, kelvin, atmosphere, g, mg, cm3, mole +from .SystemOfUnits import henry, eplus, MeV, joule, s, m, kelvin, atmosphere, g, mg, cm3, mole # # diff --git a/Control/AthenaCommon/share/MemTraceInclude.py b/Control/AthenaCommon/share/MemTraceInclude.py index 44c8c5f6099..d9fb0f7a90e 100755 --- a/Control/AthenaCommon/share/MemTraceInclude.py +++ b/Control/AthenaCommon/share/MemTraceInclude.py @@ -1,10 +1,11 @@ import string +import six from AthenaCommon.Include import Include class MemTraceInclude( Include ): def __init__( self, org ): Include.__init__( self, org._show ) - for name, value in org.__dict__.iteritems(): + for name, value in six.iteritems (org.__dict__): setattr (self, name, value) import AthenaCommon.Logging as L self.msg = L.logging.getLogger('Athena') @@ -15,8 +16,8 @@ class MemTraceInclude( Include ): from sys import platform if platform != 'darwin' : pid = os.getpid() - statm = string.split( open( '/proc/%d/statm' % pid, 'r' ).readlines()[0] ) - stat = string.split( open( '/proc/%d/stat' % pid, 'r' ).readlines()[0] ) + statm = open( '/proc/%d/statm' % pid, 'r' ).readlines()[0].split() + stat = open( '/proc/%d/stat' % pid, 'r' ).readlines()[0].split() self.msg.info( 'VSIZE = %8.3f MB, SIZE = %8.3f MB, RSS = %8.3f MB', -- GitLab