The Gaudi Framework
master (bdbe7744)
Toggle main menu visibility
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
>
12
#include <
GaudiKernel/JobHistory.h
>
13
#include <
GaudiKernel/System.h
>
14
#include <iostream>
15
16
using
std::endl;
17
using
std::ostream;
18
using
std::string;
19
20
JobHistory::JobHistory
() :
m_start_time
( 0 ) {
21
22
time( &
m_start_time
);
23
24
std::string rel;
25
26
if
( ( rel =
System::getEnv
(
"ATLAS_BASE_RELEASE"
) ) !=
"UNKNOWN"
) {
27
m_release_version
= rel;
28
}
else
if
( ( rel =
System::getEnv
(
"GAUDIROOT"
) ) !=
"UNKNOWN"
) {
29
m_release_version
= rel;
30
}
else
{
31
m_release_version
=
"UNKNOWN"
;
32
}
33
m_dir
=
System::getEnv
(
"PWD"
);
34
m_cmtconfig
=
System::getEnv
(
"CMTCONFIG"
);
35
36
m_osname
=
System::osName
();
37
m_hostname
=
System::hostName
();
38
m_os_version
=
System::osVersion
();
39
m_machine
=
System::machineType
();
40
41
m_environ
=
System::getEnv
();
42
}
43
44
JobHistory::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
)
49
,
m_cmtconfig
(
cmtconfig
)
50
,
m_osname
(
os
)
51
,
m_hostname
( host )
52
,
m_os_version
( osver )
53
,
m_machine
( mach )
54
,
m_start_time
( time ) {}
55
56
JobHistory::~JobHistory
() =
default
;
57
58
const
CLID
&
JobHistory::classID
() {
59
60
static
const
CLID
CLID_JobHistory = 247994533;
61
return
CLID_JobHistory;
62
}
63
64
void
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
82
std::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
}
CLID
unsigned int CLID
Class ID definition.
Definition
ClassID.h:16
Property.h
JobHistory.h
System.h
Gaudi::Property
Implementation of property with value of concrete type.
Definition
Property.h:35
JobHistory::~JobHistory
virtual ~JobHistory()
JobHistory::m_os_version
std::string m_os_version
Definition
JobHistory.h:44
JobHistory::start_time
time_t start_time() const
Definition
JobHistory.h:82
JobHistory::os
const std::string & os() const
Definition
JobHistory.h:73
JobHistory::m_osname
std::string m_osname
Definition
JobHistory.h:42
JobHistory::machine
const std::string & machine() const
Definition
JobHistory.h:76
JobHistory::environment
const std::vector< std::string > & environment() const
Definition
JobHistory.h:79
JobHistory::JobHistory
JobHistory()
Definition
JobHistory.cpp:20
JobHistory::dir
const std::string & dir() const
Definition
JobHistory.h:77
JobHistory::release_version
const std::string & release_version() const
Definition
JobHistory.h:72
JobHistory::propertyPairs
const PropertyPairList & propertyPairs() const
Definition
JobHistory.h:81
JobHistory::m_start_time
time_t m_start_time
Definition
JobHistory.h:53
JobHistory::classID
static const CLID & classID()
Definition
JobHistory.cpp:58
JobHistory::dump
std::ostream & dump(std::ostream &, bool isXML, int indent) const override
Definition
JobHistory.cpp:82
JobHistory::m_machine
std::string m_machine
Definition
JobHistory.h:45
JobHistory::m_cmtconfig
std::string m_cmtconfig
Definition
JobHistory.h:40
JobHistory::m_release_version
std::string m_release_version
Definition
JobHistory.h:38
JobHistory::m_hostname
std::string m_hostname
Definition
JobHistory.h:43
JobHistory::m_environ
std::vector< std::string > m_environ
Definition
JobHistory.h:47
JobHistory::hostname
const std::string & hostname() const
Definition
JobHistory.h:74
JobHistory::m_ppl
PropertyPairList m_ppl
Definition
JobHistory.h:50
JobHistory::os_version
const std::string & os_version() const
Definition
JobHistory.h:75
JobHistory::addProperty
void addProperty(const std::string &key, const std::string &value)
Definition
JobHistory.cpp:64
JobHistory::cmtconfig
const std::string & cmtconfig() const
Definition
JobHistory.h:78
JobHistory::m_dir
std::string m_dir
Definition
JobHistory.h:39
System::osName
GAUDI_API const std::string & osName()
OS name.
Definition
System.cpp:265
System::machineType
GAUDI_API const std::string & machineType()
Machine type.
Definition
System.cpp:277
System::getEnv
GAUDI_API std::vector< std::string > getEnv()
get all environment variables
Definition
System.cpp:341
System::hostName
GAUDI_API const std::string & hostName()
Host name.
Definition
System.cpp:259
System::getEnv
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition
System.cpp:314
System::osVersion
GAUDI_API const std::string & osVersion()
OS version.
Definition
System.cpp:271
GaudiKernel
src
Lib
JobHistory.cpp
Generated on
for The Gaudi Framework by
1.17.0