(ws) cobra to python bot / take a module python name as argument foo.bar.baz instead of a path foo/bar/baz.py

This commit is contained in:
Benjamin Sergeant
2020-08-19 10:00:00 -07:00
parent ee69aed2b0
commit ed5c63144e
5 changed files with 11 additions and 11 deletions

View File

@ -102,7 +102,7 @@ namespace ix
{
int64_t cobra_to_python_bot(const ix::CobraBotConfig& config,
StatsdClient& statsdClient,
const std::string& scriptPath)
const std::string& moduleName)
{
#ifndef IXBOTS_USE_PYTHON
CoreLogger::error("Command is disabled. "
@ -113,10 +113,7 @@ namespace ix
Py_InitializeEx(0); // 0 arg so that we do not install signal handlers
// which prevent us from using Ctrl-C
size_t lastIndex = scriptPath.find_last_of(".");
std::string modulePath = scriptPath.substr(0, lastIndex);
PyObject* pyModuleName = PyUnicode_DecodeFSDefault(modulePath.c_str());
PyObject* pyModuleName = PyUnicode_DecodeFSDefault(moduleName.c_str());
if (pyModuleName == nullptr)
{

View File

@ -15,5 +15,5 @@ namespace ix
{
int64_t cobra_to_python_bot(const ix::CobraBotConfig& config,
StatsdClient& statsdClient,
const std::string& scriptPath);
const std::string& moduleName);
} // namespace ix