From 96a543f7a3559bae98b44b5eff6180a905a5f008 Mon Sep 17 00:00:00 2001
From: Bertrand Martin <martindl@cern.ch>
Date: Wed, 14 Oct 2020 19:28:23 +0200
Subject: [PATCH] EventLoopGrid: minor changes for R22 AnalysisBase

Hello,

This MR is tentatively fixing 2 EventLoopGrid-related errors seen when submitting GRID jobs with AnalysisBase 22.2.0:
```
TUnixSystem::GetFromPipe  ERROR   command "python -c "from pandatools import PsubUtils;print PsubUtils.getNickname();" 2>/dev/null" returned 256
```
and
```
  File "<string>", line 130, in ELG_prun
  File "/cvmfs/atlas.cern.ch/repo/sw/software/22.2/AnalysisBaseExternals/22.2.0/InstallArea/x86_64-centos7-gcc8-opt/lib/python3.7/re.py", line 223, in findall
    return _compile(pattern, flags).findall(string)
TypeError: cannot use a string pattern on a bytes-like object
TypeError: an integer is required (got type NoneType)
```

The job submission is "successful" with the proposed changes (well, jobs crash at runtime, but likely due to an unrelated reason...).

Tagging Nils for verification.

Cheers,
Bertrand
---
 PhysicsAnalysis/D3PDTools/EventLoopGrid/Root/PrunDriver.cxx | 2 +-
 PhysicsAnalysis/D3PDTools/EventLoopGrid/data/ELG_prun.py    | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/PhysicsAnalysis/D3PDTools/EventLoopGrid/Root/PrunDriver.cxx b/PhysicsAnalysis/D3PDTools/EventLoopGrid/Root/PrunDriver.cxx
index 11b2ece3b3c0..24ee3132d3a6 100644
--- a/PhysicsAnalysis/D3PDTools/EventLoopGrid/Root/PrunDriver.cxx
+++ b/PhysicsAnalysis/D3PDTools/EventLoopGrid/Root/PrunDriver.cxx
@@ -370,7 +370,7 @@ static std::string formatOutputName(const SH::MetaObject& sampleMeta,
   static const std::string nickname = 
     gSystem->GetFromPipe(Form("python -c \"%s\" 2>/dev/null", 
 			      "from pandatools import PsubUtils;"
-			      "print PsubUtils.getNickname();")).Data();
+			      "print(PsubUtils.getNickname());")).Data();
     
   TString out = pattern.c_str();
 
diff --git a/PhysicsAnalysis/D3PDTools/EventLoopGrid/data/ELG_prun.py b/PhysicsAnalysis/D3PDTools/EventLoopGrid/data/ELG_prun.py
index 914e0091591a..c82a27b240b4 100644
--- a/PhysicsAnalysis/D3PDTools/EventLoopGrid/data/ELG_prun.py
+++ b/PhysicsAnalysis/D3PDTools/EventLoopGrid/data/ELG_prun.py
@@ -127,7 +127,7 @@ def ELG_prun(sample) :
 
     jediTaskID = 0
     try:
-        line = re.findall(r'TaskID=\d+', out)[0]
+        line = re.findall(r'TaskID=\d+', str(out))[0]
         jediTaskID = int(re.findall(r'\d+', line)[0])
     except IndexError:
         print (out)
-- 
GitLab