-
Notifications
You must be signed in to change notification settings - Fork 122
/
UpdateScriptRepository.cpp
62 lines (51 loc) · 2.42 KB
/
UpdateScriptRepository.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAlgorithms/UpdateScriptRepository.h"
#include "MantidAPI/ScriptRepository.h"
#include "MantidAPI/ScriptRepositoryFactory.h"
namespace Mantid {
namespace Algorithms {
// Register the algorithm into the AlgorithmFactory
DECLARE_ALGORITHM(UpdateScriptRepository)
//----------------------------------------------------------------------------------------------
/// Algorithm's name for identification. @see Algorithm::name
const std::string UpdateScriptRepository::name() const { return "UpdateScriptRepository"; }
/// Algorithm's version for identification. @see Algorithm::version
int UpdateScriptRepository::version() const { return 1; }
/// Algorithm's category for identification. @see Algorithm::category
const std::string UpdateScriptRepository::category() const { return "Utility\\Python"; }
//----------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------
/** Initialize the algorithm's properties.
*/
void UpdateScriptRepository::init() {}
//----------------------------------------------------------------------------------------------
/** Execute the algorithm.
*/
void UpdateScriptRepository::exec() {
// TODO Auto-generated execute stub
using Mantid::API::ScriptRepository;
using Mantid::API::ScriptRepository_sptr;
using Mantid::API::ScriptRepositoryFactory;
auto repo_ptr = ScriptRepositoryFactory::Instance().create("ScriptRepositoryImpl");
if (!repo_ptr->isValid())
return; // it means that the ScriptRepository was not installed.
std::vector<std::string> f_list = repo_ptr->check4Update();
if (!f_list.empty()) {
std::stringstream info;
info << "Information about ScriptRepository:\n"
<< " A more recent version of the following files was installed:\n";
for (auto &file : f_list) {
info << " * " << file << "\n";
}
info << "Please check these files before using them. "
<< "Note: These files were configured for AutoUpdate.";
g_log.warning() << info.str() << '\n';
}
}
} // namespace Algorithms
} // namespace Mantid