The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
JobHistory.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#include <Gaudi/Property.h>
13#include <GaudiKernel/System.h>
14#include <iostream>
15
16using std::endl;
17using std::ostream;
18using std::string;
19
21
22 time( &m_start_time );
23
24 std::string rel;
25
26 if ( ( rel = System::getEnv( "ATLAS_BASE_RELEASE" ) ) != "UNKNOWN" ) {
28 } else if ( ( rel = System::getEnv( "GAUDIROOT" ) ) != "UNKNOWN" ) {
30 } else {
31 m_release_version = "UNKNOWN";
32 }
33 m_dir = System::getEnv( "PWD" );
34 m_cmtconfig = System::getEnv( "CMTCONFIG" );
35
40
42}
43
44JobHistory::JobHistory( const std::string& rel, const std::string& os, const std::string& host, const std::string& dir,
45 const std::string& osver, const std::string& mach, const std::string& cmtconfig,
46 const time_t& time )
47 : m_release_version( rel )
48 , m_dir( dir )
50 , m_osname( os )
51 , m_hostname( host )
52 , m_os_version( osver )
53 , m_machine( mach )
54 , m_start_time( time ) {}
55
56JobHistory::~JobHistory() = default;
57
59
60 static const CLID CLID_JobHistory = 247994533;
61 return CLID_JobHistory;
62}
63
64void JobHistory::addProperty( const std::string& key, const std::string& value ) {
66 std::string prop_value = value;
67 if ( !prop_value.empty() && prop_value[0] == '"' && prop_value[prop_value.size() - 1] == '"' )
68 prop_value = prop_value.substr( 1, prop_value.size() - 2 );
69
70 std::string client, prop_name;
71 auto pos = key.rfind( '.' );
72 if ( pos == std::string::npos ) {
73 prop_name = key;
74 } else {
75 client = key.substr( 0, pos );
76 prop_name = key.substr( pos + 1 );
77 }
78
79 m_ppl.emplace_back( client, std::make_unique<Gaudi::Property<std::string>>( prop_name, prop_value ) );
80}
81
82std::ostream& JobHistory::dump( std::ostream& ost, const bool isXML, int /*ind*/ ) const {
83
84 if ( !isXML ) {
85 ost << "Release: " << release_version() << endl;
86 ost << "OS: " << os() << endl;
87 ost << "OS ver: " << os_version() << endl;
88 ost << "Host: " << hostname() << endl;
89 ost << "Machine: " << machine() << endl;
90 ost << "Run dir: " << dir() << endl;
91 ost << "CMTCONFIG: " << cmtconfig() << endl;
92 ost << "Job start time: " << start_time() << endl << endl;
93 ost << "Properties: [" << endl;
94 ;
95 for ( const auto& ipprop : propertyPairs() ) {
96 const auto& client = ipprop.first;
97 const auto& prop = ipprop.second;
98 ost << client << ": ";
99 prop->fillStream( ost );
100 ost << endl;
101 }
102 ost << "]" << endl;
103 for ( const auto& itr : environment() ) ost << itr << endl;
104 } else {
105 }
106
107 return ost;
108}
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
virtual ~JobHistory()
std::string m_os_version
Definition JobHistory.h:44
time_t start_time() const
Definition JobHistory.h:82
const std::string & os() const
Definition JobHistory.h:73
std::string m_osname
Definition JobHistory.h:42
const std::string & machine() const
Definition JobHistory.h:76
const std::vector< std::string > & environment() const
Definition JobHistory.h:79
const std::string & dir() const
Definition JobHistory.h:77
const std::string & release_version() const
Definition JobHistory.h:72
const PropertyPairList & propertyPairs() const
Definition JobHistory.h:81
time_t m_start_time
Definition JobHistory.h:53
static const CLID & classID()
std::ostream & dump(std::ostream &, bool isXML, int indent) const override
std::string m_machine
Definition JobHistory.h:45
std::string m_cmtconfig
Definition JobHistory.h:40
std::string m_release_version
Definition JobHistory.h:38
std::string m_hostname
Definition JobHistory.h:43
std::vector< std::string > m_environ
Definition JobHistory.h:47
const std::string & hostname() const
Definition JobHistory.h:74
PropertyPairList m_ppl
Definition JobHistory.h:50
const std::string & os_version() const
Definition JobHistory.h:75
void addProperty(const std::string &key, const std::string &value)
const std::string & cmtconfig() const
Definition JobHistory.h:78
std::string m_dir
Definition JobHistory.h:39
GAUDI_API const std::string & osName()
OS name.
Definition System.cpp:271
GAUDI_API const std::string & machineType()
Machine type.
Definition System.cpp:283
GAUDI_API std::vector< std::string > getEnv()
get all environment variables
Definition System.cpp:356
GAUDI_API const std::string & hostName()
Host name.
Definition System.cpp:265
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition System.cpp:329
GAUDI_API const std::string & osVersion()
OS version.
Definition System.cpp:277