From ac81820d25898033d2ee8c8856801307f75619e6 Mon Sep 17 00:00:00 2001 From: Martyn Gigg <martyn.gigg@stfc.ac.uk> Date: Tue, 27 Nov 2018 20:00:31 +0000 Subject: [PATCH] Rename UsageService::setApplication to UsageService::setApplicationName It more closely describes the intent of the method. --- Framework/Kernel/inc/MantidKernel/UsageService.h | 4 ++-- Framework/Kernel/src/UsageService.cpp | 10 ++++++---- Framework/Kernel/test/UsageServiceTest.h | 8 ++++---- .../mantid/kernel/src/Exports/UsageService.cpp | 6 +++--- .../test/python/mantid/kernel/UsageServiceTest.py | 14 ++++++++------ MantidPlot/src/Mantid/MantidApplication.cpp | 2 +- 6 files changed, 24 insertions(+), 20 deletions(-) diff --git a/Framework/Kernel/inc/MantidKernel/UsageService.h b/Framework/Kernel/inc/MantidKernel/UsageService.h index b17a111f9c2..35725779847 100644 --- a/Framework/Kernel/inc/MantidKernel/UsageService.h +++ b/Framework/Kernel/inc/MantidKernel/UsageService.h @@ -50,9 +50,9 @@ public: class MANTID_KERNEL_DLL UsageServiceImpl { public: /// Sets the application name that has invoked Mantid - void setApplication(const std::string &name); + void setApplicationName(const std::string &name); /// Returns the application name that has invoked Mantid - std::string getApplication() const; + std::string getApplicationName() const; /// Sets the interval that the timer checks for tasks void setInterval(const uint32_t seconds = 60); /// Registers the Startup of Mantid diff --git a/Framework/Kernel/src/UsageService.cpp b/Framework/Kernel/src/UsageService.cpp index e99031b1bf4..d113bc4fa86 100644 --- a/Framework/Kernel/src/UsageService.cpp +++ b/Framework/Kernel/src/UsageService.cpp @@ -68,6 +68,7 @@ UsageServiceImpl::UsageServiceImpl() : m_timer(), m_timerTicks(0), m_timerTicksTarget(0), m_FeatureQueue(), m_FeatureQueueSizeThreshold(50), m_isEnabled(false), m_mutex(), m_application("python"), + m_startTime(Types::Core::DateAndTime::getCurrentTime()), m_startupActiveMethod(this, &UsageServiceImpl::sendStartupAsyncImpl), m_featureActiveMethod(this, &UsageServiceImpl::sendFeatureAsyncImpl) { setInterval(60); @@ -78,15 +79,16 @@ UsageServiceImpl::UsageServiceImpl() } else { m_url = url.get(); g_log.debug() << "Root usage reporting url is " << m_url << "\n"; - } - m_startTime = Types::Core::DateAndTime::getCurrentTime(); + }; } -void UsageServiceImpl::setApplication(const std::string &name) { +void UsageServiceImpl::setApplicationName(const std::string &name) { m_application = name; } -std::string UsageServiceImpl::getApplication() const { return m_application; } +std::string UsageServiceImpl::getApplicationName() const { + return m_application; +} void UsageServiceImpl::setInterval(const uint32_t seconds) { // set the ticks target to by 24 hours / interval diff --git a/Framework/Kernel/test/UsageServiceTest.h b/Framework/Kernel/test/UsageServiceTest.h index 5187942f704..3a5048c87ae 100644 --- a/Framework/Kernel/test/UsageServiceTest.h +++ b/Framework/Kernel/test/UsageServiceTest.h @@ -63,7 +63,7 @@ public: void test_startupMessage() { TestableUsageService usageService; std::string name = "My testing application name"; - usageService.setApplication(name); + usageService.setApplicationName(name); std::string message = usageService.generateStartupMessage(); ::Json::Reader reader; @@ -162,11 +162,11 @@ public: void test_setApplicationName() { TestableUsageService usageService; // test default first - TS_ASSERT_EQUALS(usageService.getApplication(), "python"); + TS_ASSERT_EQUALS(usageService.getApplicationName(), "python"); std::string name = "My testing application name"; - usageService.setApplication(name); - TS_ASSERT_EQUALS(usageService.getApplication(), name); + usageService.setApplicationName(name); + TS_ASSERT_EQUALS(usageService.getApplicationName(), name); } }; diff --git a/Framework/PythonInterface/mantid/kernel/src/Exports/UsageService.cpp b/Framework/PythonInterface/mantid/kernel/src/Exports/UsageService.cpp index 78ffdf405a1..628f8ffedd5 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Exports/UsageService.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Exports/UsageService.cpp @@ -57,11 +57,11 @@ void export_UsageService() { .def("setInterval", &UsageServiceImpl::setEnabled, (arg("self"), arg("seconds")), "Sets the interval that the timer checks for tasks.") - .def("setApplication", &UsageServiceImpl::setApplication, + .def("setApplicationName", &UsageServiceImpl::setApplicationName, (arg("self"), arg("name")), "Sets the application name that has invoked Mantid.") - .def("getApplication", &UsageServiceImpl::getApplication, arg("self"), - "Gets the application name that has invoked Mantid.") + .def("getApplicationName", &UsageServiceImpl::getApplicationName, + arg("self"), "Gets the application name that has invoked Mantid.") .def("registerStartup", &UsageServiceImpl::registerStartup, arg("self"), "Registers the startup of Mantid.") .def("registerFeatureUsage", &UsageServiceImpl::registerFeatureUsage, diff --git a/Framework/PythonInterface/test/python/mantid/kernel/UsageServiceTest.py b/Framework/PythonInterface/test/python/mantid/kernel/UsageServiceTest.py index 78a4ca2fed9..66662d42613 100644 --- a/Framework/PythonInterface/test/python/mantid/kernel/UsageServiceTest.py +++ b/Framework/PythonInterface/test/python/mantid/kernel/UsageServiceTest.py @@ -10,6 +10,7 @@ import unittest from mantid.kernel import (UsageService, UsageServiceImpl) + class UsageServiceTest(unittest.TestCase): def test_singleton_returns_instance_of_UsageService(self): @@ -24,11 +25,11 @@ class UsageServiceTest(unittest.TestCase): self.assertEquals(UsageService.isEnabled(),False) def test_getSetApplication(self): - self.assertEquals(UsageService.getApplication(),"python") - UsageService.setApplication("python unit tests") - self.assertEquals(UsageService.getApplication(),"python unit tests") - UsageService.setApplication("python") - self.assertEquals(UsageService.getApplication(),"python") + self.assertEquals(UsageService.getApplicationName(), "python") + UsageService.setApplicationName("python unit tests") + self.assertEquals(UsageService.getApplicationName(), "python unit tests") + UsageService.setApplicationName("python") + self.assertEquals(UsageService.getApplicationName(), "python") def test_setInterval(self): UsageService.setEnabled(False) @@ -42,7 +43,7 @@ class UsageServiceTest(unittest.TestCase): def test_registerFeatureUsage(self): UsageService.setEnabled(False) #this will do nothing as it is disabled - UsageService.registerFeatureUsage("Algorithm","Test.v1",True) + UsageService.registerFeatureUsage("Algorithm", "Test.v1", True) def test_Flush(self): @@ -53,5 +54,6 @@ class UsageServiceTest(unittest.TestCase): def test_Shutdown(self): UsageService.shutdown() + if __name__ == '__main__': unittest.main() diff --git a/MantidPlot/src/Mantid/MantidApplication.cpp b/MantidPlot/src/Mantid/MantidApplication.cpp index b37e859a26a..b439635135c 100644 --- a/MantidPlot/src/Mantid/MantidApplication.cpp +++ b/MantidPlot/src/Mantid/MantidApplication.cpp @@ -29,7 +29,7 @@ Mantid::Kernel::Logger g_log("MantidApplication"); MantidApplication::MantidApplication(int &argc, char **argv) : QApplication(argc, argv) { try { - Mantid::Kernel::UsageService::Instance().setApplication("mantidplot"); + Mantid::Kernel::UsageService::Instance().setApplicationName("mantidplot"); } catch (std::runtime_error &rexc) { g_log.error() << "Failed to initialize the Mantid usage service. This " "is probably a sign that this Mantid is not fully or " -- GitLab