Skip to content

Commit

Permalink
re #8924 merge changes
Browse files Browse the repository at this point in the history
Merge branch 'feature/8924_Intrument_file_repo' into develop

Conflicts:
	Code/Mantid/Framework/Kernel/inc/MantidKernel/ChecksumHelper.h
	Code/Mantid/Framework/Kernel/src/ChecksumHelper.cpp
	Code/Mantid/Framework/Kernel/test/ChecksumHelperTest.h
  • Loading branch information
NickDraper committed Nov 13, 2014
2 parents a9de065 + 65c165b commit 64d5d24
Show file tree
Hide file tree
Showing 14 changed files with 1,190 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/FrameworkManager.h
Expand Up @@ -113,6 +113,8 @@ namespace Mantid
void setGlobalLocaleToAscii();
/// Silence NeXus output
void disableNexusOutput();
/// Update instrument definitions from github
void UpdateInstrumentDefinitions();

#ifdef MPI_BUILD
/** Member variable that initialises the MPI environment on construction (in the
Expand Down
29 changes: 29 additions & 0 deletions Code/Mantid/Framework/API/src/FrameworkManager.cpp
Expand Up @@ -13,6 +13,9 @@
#include "MantidKernel/LibraryManager.h"
#include "MantidKernel/Memory.h"
#include "MantidKernel/MultiThreaded.h"

#include <Poco/ActiveResult.h>

#include <cstdarg>

#ifdef _WIN32
Expand Down Expand Up @@ -80,13 +83,39 @@ FrameworkManagerImpl::FrameworkManagerImpl()
#endif

g_log.debug() << "FrameworkManager created." << std::endl;

int updateInstrumentDefinitions = 0;
int reVal = Kernel::ConfigService::Instance().getValue("UpdateInstrumentDefinitions.OnStartup",updateInstrumentDefinitions);
if ((reVal == 1) && (updateInstrumentDefinitions == 1))
{
UpdateInstrumentDefinitions();
}
else
{
g_log.information() << "Instrument updates disabled - cannot update instrument definitions." << std::endl;
}
}

/// Destructor
FrameworkManagerImpl::~FrameworkManagerImpl()
{
}

/// Update instrument definitions from github
void FrameworkManagerImpl::UpdateInstrumentDefinitions()
{
try
{
IAlgorithm* algDownloadInstrument = this->createAlgorithm("DownloadInstrument");
Poco::ActiveResult<bool> result = algDownloadInstrument->executeAsync();
}
catch (Kernel::Exception::NotFoundError &)
{
g_log.debug() << "DowndloadInstrument algorithm is not available - cannot update instrument definitions." << std::endl;
}
}


/**
* Load a set of plugins from the path pointed to by the given config key
* @param key :: A string containing a key to lookup in the ConfigService
Expand Down
9 changes: 5 additions & 4 deletions Code/Mantid/Framework/DataHandling/CMakeLists.txt
Expand Up @@ -10,6 +10,7 @@ set ( SRC_FILES
src/DefineGaugeVolume.cpp
src/DeleteTableRows.cpp
src/DetermineChunking.cpp
src/DownloadInstrument.cpp
src/ExtractMonitorWorkspace.cpp
src/FilterEventsByLogValuePreNexus.cpp
src/FindDetectorsInShape.cpp
Expand Down Expand Up @@ -126,10 +127,9 @@ set ( SRC_FILES
src/SaveMask.cpp
src/SaveNISTDAT.cpp
src/SaveNXSPE.cpp
src/SaveNXTomo.cpp
src/SaveNexus.cpp
src/SaveNexusProcessed.cpp
src/SaveNXTomo.cpp
src/SaveParameterFile.cpp
src/SavePAR.cpp
src/SavePDFGui.cpp
src/SavePHX.cpp
Expand All @@ -156,6 +156,7 @@ set ( INC_FILES
inc/MantidDataHandling/DefineGaugeVolume.h
inc/MantidDataHandling/DeleteTableRows.h
inc/MantidDataHandling/DetermineChunking.h
inc/MantidDataHandling/DownloadInstrument.h
inc/MantidDataHandling/ExtractMonitorWorkspace.h
inc/MantidDataHandling/FilterEventsByLogValuePreNexus.h
inc/MantidDataHandling/FindDetectorsInShape.h
Expand Down Expand Up @@ -267,10 +268,9 @@ set ( INC_FILES
inc/MantidDataHandling/SaveMask.h
inc/MantidDataHandling/SaveNISTDAT.h
inc/MantidDataHandling/SaveNXSPE.h
inc/MantidDataHandling/SaveNXTomo.h
inc/MantidDataHandling/SaveNexus.h
inc/MantidDataHandling/SaveNexusProcessed.h
inc/MantidDataHandling/SaveNXTomo.h
inc/MantidDataHandling/SaveParameterFile.h
inc/MantidDataHandling/SavePAR.h
inc/MantidDataHandling/SavePDFGui.h
inc/MantidDataHandling/SavePHX.h
Expand Down Expand Up @@ -301,6 +301,7 @@ set ( TEST_FILES
DefineGaugeVolumeTest.h
DeleteTableRowsTest.h
DetermineChunkingTest.h
DownloadInstrumentTest.h
ExtractMonitorWorkspaceTest.h
FilterEventsByLogValuePreNexusTest.h
FindDetectorsInShapeTest.h
Expand Down
@@ -0,0 +1,69 @@
#ifndef MANTID_DATAHANDLING_DOWNLOADINSTRUMENT_H_
#define MANTID_DATAHANDLING_DOWNLOADINSTRUMENT_H_

#include "MantidKernel/System.h"
#include "MantidAPI/Algorithm.h"
#include "MantidKernel/ProxyInfo.h"

#include <map>

namespace Mantid
{

namespace DataHandling
{
typedef std::map<std::string,std::string> String2StringMap;

/** DownloadInstrument : Downloads one or more instrument files to the local instrument cache from the instrument repository
Copyright &copy; 2014 ISIS Rutherford Appleton Laboratory & NScD Oak Ridge National Laboratory
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class DLLExport DownloadInstrument : public API::Algorithm
{
public:
DownloadInstrument();
virtual ~DownloadInstrument();

virtual const std::string name() const;
virtual int version() const;
virtual const std::string category() const;
virtual const std::string summary() const;

private:
void init();
void exec();
virtual int doDownloadFile(const std::string& urlFile, const std::string& localFilePath = "", const String2StringMap& headers = String2StringMap());
void updateJsonFile(const std::string& directoryPath, const std::string& filePath);
const std::string MangleFileName(const std::string& filename) const;
const std::string getDownloadableRepoUrl(const std::string& filename) const;

String2StringMap processRepository();

bool m_isProxySet;
Mantid::Kernel::ProxyInfo m_proxyInfo;

};


} // namespace DataHandling
} // namespace Mantid

#endif /* MANTID_DATAHANDLING_DOWNLOADINSTRUMENT_H_ */

0 comments on commit 64d5d24

Please sign in to comment.