Skip to content
Snippets Groups Projects
Commit 9eb3d5c1 authored by Peterson, Peter's avatar Peterson, Peter
Browse files

Add unicode support to UsageService in python

This is extremely similar to what was done in #23826
parent 034ded69
No related branches found
No related tags found
No related merge requests found
......@@ -6,53 +6,56 @@
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidKernel/UsageService.h"
#include "MantidPythonInterface/kernel/GetPointer.h"
#include "MantidPythonInterface/kernel/Converters/PyObjectToString.h"
#include <boost/python/class.hpp>
#include <boost/python/reference_existing_object.hpp>
using Mantid::Kernel::UsageService;
using Mantid::Kernel::UsageServiceImpl;
using Mantid::PythonInterface::Converters::pyObjToStr;
using namespace boost::python;
GET_POINTER_SPECIALIZATION(UsageServiceImpl)
namespace {
void setApplication(UsageServiceImpl *self, const object &name) {
self->setApplication(pyObjToStr(name));
}
void registerFeatureUsage(UsageServiceImpl *self, const object &type,
const object &name, const bool internal) {
self->registerFeatureUsage(pyObjToStr(type), pyObjToStr(name), internal);
}
} // anonymous namespace
void export_UsageService() {
class_<UsageServiceImpl, boost::noncopyable>("UsageServiceImpl", no_init)
.def("flush", &UsageServiceImpl::flush, arg("self"),
"Sends any pending usage information.")
.def("shutdown", &UsageServiceImpl::shutdown, arg("self"),
"Sends any pending usage information, and disables the usage "
"service.")
.def("getUpTime", &UsageServiceImpl::getUpTime, arg("self"),
"Returns the time that the instance of mantid has been running")
.def("isEnabled", &UsageServiceImpl::isEnabled, arg("self"),
"Returns if the usage service is enabled.")
.def("setEnabled", &UsageServiceImpl::setEnabled,
(arg("self"), arg("enabled")),
"Enables or disables the usage service.")
.def("setInterval", &UsageServiceImpl::setEnabled,
(arg("self"), arg("seconds")),
"Sets the interval that the timer checks for tasks.")
.def("setApplication", &UsageServiceImpl::setApplication,
(arg("self"), arg("name")),
.def("setApplication", &setApplication, (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("registerStartup", &UsageServiceImpl::registerStartup, arg("self"),
"Registers the startup of Mantid.")
.def("registerFeatureUsage", &UsageServiceImpl::registerFeatureUsage,
.def("registerFeatureUsage", &registerFeatureUsage,
(arg("self"), arg("type"), arg("name"), arg("internal")),
"Registers the use of a feature in Mantid.")
.def("Instance", &UsageService::Instance,
return_value_policy<reference_existing_object>(),
"Returns a reference to the UsageService")
......
......@@ -4,7 +4,7 @@
# NScD Oak Ridge National Laboratory, European Spallation Source
# & Institut Laue - Langevin
# SPDX - License - Identifier: GPL - 3.0 +
from __future__ import (absolute_import, division, print_function)
from __future__ import (absolute_import, division, print_function, unicode_literals)
import unittest
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment