KaliVeda
Toolkit for HIC analysis
Loading...
Searching...
No Matches
KVRemoteAvailableRunsFile.cpp
1/*
2$Id: KVRemoteAvailableRunsFile.cpp,v 1.4 2008/02/08 08:19:59 franklan Exp $
3$Revision: 1.4 $
4$Date: 2008/02/08 08:19:59 $
5*/
6
7//Created by KVClassFactory on Mon May 22 00:14:11 2006
8//Author: John Frankland
9
10#include "KVRemoteAvailableRunsFile.h"
11#include "KVDataRepository.h"
12#include "KVDataSet.h"
13#include "TSystem.h"
14#include "TEnv.h"
15
16using namespace std;
17
19
20
21
23
25{
26 //default Constructor
27 init();
28}
29
30
31
35
37 type,
40 (type, ds)
41{
42 //Constructor with name of datatype
43 //and pointer to parent dataset
44 init();
45}
46
47
48
52
54{
55 //Destructor
56 //Delete the runlist file from the temp directory if it has been opened
57 if (IsFileOpen()) {
61 }
62 }
63}
64
65
66
67
71
73{
74 //Find executable 'curl' or programme indicated by
75 //value of DataRepository.RemoteAvailableRuns.protocol
77 ("%s.DataRepository.RemoteAvailableRuns.protocol",
78 GetDataSet()->GetRepository()->GetName()), "curl");
80}
81
82
83
84
99
101{
102 //Initialise fRunlist so that it can be used to read the available runs file from the beginning.
103 //
104 //If the file has already been opened, this means resetting the ifstream to the start of the file.
105 //
106 //If not already open, open the file containing the list of available runs for the dataset.
107 //What this actually means is:
108 // - read value of DataRepository.RemoteAvailableRuns.url for the data repository
109 // - use 'curl' or programme indicated by value of
110 // DataRepository.RemoteAvailableRuns.protocol to make local copy
111 // of file
112 // - open copy
113 //Returns kFALSE in case of problems.
114
115 //already open ?
116 if (IsFileOpen()) {
117 fRunlist.clear(); // clear any error flags (EOF etc.)
118 fRunlist.seekg(0, ios::beg); // set file buffer pointer to beginning of file
119 //if we can get a lock on the file, all is well. if not, we need to fetch a new
120 //copy
121 if (runlist_lock.Lock()) return kTRUE;
122 }
123 TString http =
124 gEnv->GetValue(Form("%s.DataRepository.RemoteAvailableRuns.url",
125 GetDataSet()->GetRepository()->GetName()), "");
126 if (http == "") {
127 Warning("OpenAvailableRunsFile(ifstream& runlist)",
128 "%s.DataRepository.RemoteAvailableRuns.url is not defined. See $KVROOT/KVFiles/.kvrootrc",
129 GetDataSet()->GetRepository()->GetName());
130 return kFALSE;
131 }
132 TString url;
133 url.Form("%s/%s", http.Data(), GetFileName());
134 //remote file will be copied to $TEMP directory with name
135 //repository.available_runs....
138 TString cmd;
139 cmd.Form("%s -o%s %s", fCurl.Data(), fFilePath.Data(), url.Data());
140 //lock temp file - just in case
142 if (gSystem->Exec(cmd.Data())) {
144 return kFALSE; // problem with curl
145 }
146 fRunlist.open(fFilePath.Data());
147 if (!fRunlist.good() || !fRunlist.is_open()) {
148 Error("OpenAvailableRunsFile",
149 "Cannot open temp file to copy remote runlist file");
151 return kFALSE;
152 }
153 return kTRUE;
154}
155
156
157
158
163
165{
166 //Redefines KVAvailableRunsFile::CloseAvailableRunsFile
167 //We do not want to transfer the file again every time we need to read it,
168 //therefore we do not close the file, simply remove the lock.
170}
171
172
173
bool Bool_t
char Char_t
constexpr Bool_t kFALSE
constexpr Bool_t kTRUE
R__EXTERN TEnv * gEnv
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
char * Form(const char *fmt,...)
R__EXTERN TSystem * gSystem
Handles lists of available runs for different datasets and types of data.
const KVDataSet * GetDataSet() const
const Char_t * GetFileName() const
KVLockfile runlist_lock
for locking runlist file
std::ifstream fRunlist
for reading runlist file
static Bool_t FindExecutable(TString &exec, const Char_t *path="$(PATH)")
Definition KVBase.cpp:1001
static void GetTempFileName(TString &base)
Definition KVBase.cpp:848
Manage an experimental dataset corresponding to a given experiment or campaign.
Definition KVDataSet.h:35
Bool_t Release()
Bool_t Lock(const Char_t *filename="")
List of available runfiles in a remote data repository.
KVRemoteAvailableRunsFile()
default Constructor
TString fCurl
full path to executable used to copy files
TString fFilePath
full path to copy of remote file kept in temp dir
virtual const char * GetValue(const char *name, const char *dflt) const
const char * GetName() const override
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
const char * Data() const
void Form(const char *fmt,...)
virtual Int_t Exec(const char *shellcmd)
virtual int Unlink(const char *name)
void init()
ClassImp(TPyArg)