ATLAS Offline Software
Loading...
Searching...
No Matches
get_generator_info.py
Go to the documentation of this file.
1#!/usr/bin/env python
2# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
4from PyJobTransforms.trfExceptions import TransformAMIException
5from PyJobTransforms.trfAMI import AMIerrorCode, getAMIClient, get_ami_tag
6
7import logging
8msg = logging.getLogger(__name__)
9
10import os
11import sys
12tag = sys.argv[1]
13
14try:
15 import pyAMI.exception
16except ImportError as e:
17 raise TransformAMIException(AMIerrorCode, 'Import of pyAMI modules failed ({0})'.format(e))
18
19try:
20 amiclient = getAMIClient()
21 result = get_ami_tag(amiclient, tag, True)
22except pyAMI.exception.Error as e:
23 msg.warning('An exception occured when connecting to primary AMI: {0}'.format(e))
24 msg.error('Exception: {0}'.format(e))
25 if 'please login' in e.message or 'certificate expired' in e.message:
26 raise TransformAMIException(AMIerrorCode, 'Getting tag info from AMI failed with credential problem. '
27 'Please check your AMI account status.')
28 if 'Invalid amiTag' in e.message:
29 raise TransformAMIException(AMIerrorCode, 'Invalid AMI tag ({0}).'.format(tag))
30
31 msg.error("Error may not be fatal - will try AMI replica catalog")
32
33build, version = result[0]["SWReleaseCache"].split("_")
34print(build)
35print(version)
36
37folder_path = os.path.dirname(os.path.realpath(__file__))
38command = f"{folder_path}/get_generator_versions.sh {build} {version} {tag}"
39import subprocess
40output, error = subprocess.Popen(["/bin/bash", "-c", command], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
41output, error = output.decode("utf-8"), error.decode("utf-8")
42# sanitize error
43error = [l for l in error.strip().split("\n") if l and "manpath" not in l]
44
45output = output.strip()
46print(output)
47
48if error:
49 print(error)
50 sys.exit(1)
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
Utilities for configuration of transforms via AMI tags.