Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ build_idl84:
- cp -r install/lib/python${PYTHON_VERSION}/site-packages/*uda* dist

- export PYTHONPATH=dist:$PYTHONPATH
# - export LD_LIBRARY_PATH=install/lib:$LD_LIBRARY_PATH
- module use install/modulefiles
- UDA_MODULE=`ls install/modulefiles | grep uda`
- module load $UDA_MODULE
Expand All @@ -76,6 +75,7 @@ build_idl84:
- python3 -m pytest -v mastcodes/uda/python/tests/test_uda_meta.py
- python3 -m pytest -v mastcodes/uda/python/tests/test_uda_signals.py
- python3 -m pytest -v mastcodes/uda/python/tests/test_uda_xpad.py
- python3 mastcodes/uda/python/tests/test_put.py
artifacts:
paths:
- dist
Expand Down
94 changes: 54 additions & 40 deletions source/plugins/bytes/bytesPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#include <clientserver/stringUtils.h>
#include <clientserver/makeRequestBlock.h>
#include <clientserver/initStructs.h>
#include <exception>
#include <plugins/utils.h>
#include <stdexcept>
#include <version.h>

#include "readBytesNonOptimally.h"
Expand Down Expand Up @@ -62,6 +64,7 @@ class BytesPlugin
return;
}
// Free Heap & reset counters
file_map_.clear();
init_ = false;
}

Expand All @@ -82,50 +85,57 @@ class BytesPlugin

int bytesPlugin(IDAM_PLUGIN_INTERFACE* plugin_interface)
{
static BytesPlugin plugin = {};
try {
static BytesPlugin plugin = {};

if (plugin_interface->interfaceVersion > THISPLUGIN_MAX_INTERFACE_VERSION) {
RAISE_PLUGIN_ERROR("Plugin Interface Version Unknown to this plugin: Unable to execute the request!");
}
if (plugin_interface->interfaceVersion > THISPLUGIN_MAX_INTERFACE_VERSION) {
RAISE_PLUGIN_ERROR("Plugin Interface Version Unknown to this plugin: Unable to execute the request!");
}

plugin_interface->pluginVersion = THISPLUGIN_VERSION;
plugin_interface->pluginVersion = THISPLUGIN_VERSION;

REQUEST_DATA* request = plugin_interface->request_data;
REQUEST_DATA* request = plugin_interface->request_data;

if (plugin_interface->housekeeping || STR_IEQUALS(request->function, "reset")) {
plugin.reset(plugin_interface);
return 0;
}
if (plugin_interface->housekeeping || STR_IEQUALS(request->function, "reset")) {
plugin.reset(plugin_interface);
return 0;
}

plugin.init(plugin_interface);
if (STR_IEQUALS(request->function, "init")
|| STR_IEQUALS(request->function, "initialise")) {
return 0;
}
plugin.init(plugin_interface);
if (STR_IEQUALS(request->function, "init")
|| STR_IEQUALS(request->function, "initialise")) {
return 0;
}

//----------------------------------------------------------------------------------------
// Plugin Functions
//----------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------
// Standard methods: version, builddate, defaultmethod, maxinterfaceversion

if (STR_IEQUALS(request->function, "help")) {
return plugin.help(plugin_interface);
} else if (STR_IEQUALS(request->function, "version")) {
return plugin.version(plugin_interface);
} else if (STR_IEQUALS(request->function, "builddate")) {
return plugin.build_date(plugin_interface);
} else if (STR_IEQUALS(request->function, "defaultmethod")) {
return plugin.default_method(plugin_interface);
} else if (STR_IEQUALS(request->function, "maxinterfaceversion")) {
return plugin.max_interface_version(plugin_interface);
} else if (STR_IEQUALS(request->function, "read")) {
return plugin.read(plugin_interface);
} else if (STR_IEQUALS(request->function, "size")) {
return plugin.size(plugin_interface);
} else {
RAISE_PLUGIN_ERROR_AND_EXIT("Unknown function requested!", plugin_interface);
//----------------------------------------------------------------------------------------
// Plugin Functions
//----------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------
// Standard methods: version, builddate, defaultmethod, maxinterfaceversion

if (STR_IEQUALS(request->function, "help")) {
return plugin.help(plugin_interface);
} else if (STR_IEQUALS(request->function, "version")) {
return plugin.version(plugin_interface);
} else if (STR_IEQUALS(request->function, "builddate")) {
return plugin.build_date(plugin_interface);
} else if (STR_IEQUALS(request->function, "defaultmethod")) {
return plugin.default_method(plugin_interface);
} else if (STR_IEQUALS(request->function, "maxinterfaceversion")) {
return plugin.max_interface_version(plugin_interface);
} else if (STR_IEQUALS(request->function, "read")) {
return plugin.read(plugin_interface);
} else if (STR_IEQUALS(request->function, "size")) {
return plugin.size(plugin_interface);
} else {
RAISE_PLUGIN_ERROR_AND_EXIT("Unknown function requested!", plugin_interface);
}
} catch (const std::exception& e) {
std::string err_msg = std::string("Excption raised in bytes plugin:") + e.what();
RAISE_PLUGIN_ERROR_AND_EXIT(err_msg.c_str(), plugin_interface);
} catch (...) {
RAISE_PLUGIN_ERROR_AND_EXIT("Unknown exception raised by bytes plugin", plugin_interface);
}
}

Expand Down Expand Up @@ -227,8 +237,12 @@ int BytesPlugin::read(IDAM_PLUGIN_INTERFACE* plugin_interface)
int max_bytes = -1;
FIND_INT_VALUE(plugin_interface->request_data->nameValueList, max_bytes);

int offset = -1;
FIND_INT_VALUE(plugin_interface->request_data->nameValueList, offset);
unsigned long offset = 0;
FIND_UNSIGNED_LONG_VALUE(plugin_interface->request_data->nameValueList, offset);
auto file_size = filesystem::file_size(path);
if (offset >= file_size) {
RAISE_PLUGIN_ERROR_AND_EXIT("Offset specified is out of bounds", plugin_interface);
}

const char* checksum = nullptr;
FIND_STRING_VALUE(plugin_interface->request_data->nameValueList, checksum);
Expand Down
2 changes: 1 addition & 1 deletion source/plugins/bytes/readBytesNonOptimally.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int readBytes(FILE* fh, DATA_BLOCK* data_block, int offset, int max_bytes, const
while (!feof(fh)) {
char* newp = (char*)realloc(bp, (size_t)data_block->data_n);
if (newp == nullptr) {
free(bp);
if (bp != nullptr) free(bp);
err = BYTE_FILE_HEAP_ERROR;
addIdamError(UDA_CODE_ERROR_TYPE, "readBytes", err, "Unable to Allocate Heap Memory for the File");
break;
Expand Down
47 changes: 47 additions & 0 deletions source/plugins/udaPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <type_traits>
#include <regex>
#include <string>
#include <cstring>

IDAM_PLUGIN_INTERFACE* udaCreatePluginInterface(const char* request)
{
Expand Down Expand Up @@ -467,6 +468,52 @@ bool findIntValue(const NAMEVALUELIST* namevaluelist, int* value, const char* na
return found;
}

/**
* Look for an argument with the given name in the provided NAMEVALUELIST and return it's associate value as a long integer.
*
* If the argument is found the value associated with the argument is provided via the value parameter and the function
* returns 1. Otherwise value is not set and the function returns 0.
* @param namevaluelist
* @param value
* @param name
* @return
*/
bool findLongIntValue(const NAMEVALUELIST* namevaluelist, long* value, const char* name)
{
const char* str;
bool found = findStringValue(namevaluelist, &str, name);
if (found) {
*value = atol(str);
}
return found;
}

/**
* Look for an argument with the given name in the provided NAMEVALUELIST and return it's associate value as an
* unsigned long integer.
*
* If the argument is found the value associated with the argument is provided via the value parameter and the function
* returns 1. Otherwise value is not set and the function returns 0.
* @param namevaluelist
* @param value
* @param name
* @return
*/
bool findUnsignedLongValue(const NAMEVALUELIST* namevaluelist, unsigned long* value, const char* name)
{
const char* str;
bool found = findStringValue(namevaluelist, &str, name);
if (found) {
if (std::strchr(str, '-') != nullptr) {
std::string err_msg = std::string("Negative value found when unsigned expected: ") + name + "=" + str;
RAISE_PLUGIN_ERROR(err_msg.c_str());
return false;
}
*value = std::strtoul(str, nullptr, 10);
}
return found;
}

/**
* Look for an argument with the given name in the provided NAMEVALUELIST and return it's associate value as a short.
*
Expand Down
6 changes: 6 additions & 0 deletions source/plugins/udaPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ LIBRARY_API int setReturnData(DATA_BLOCK* data_block, void* value, size_t size,
LIBRARY_API bool findStringValue(const NAMEVALUELIST* namevaluelist, const char** value, const char* name);
LIBRARY_API bool findValue(const NAMEVALUELIST* namevaluelist, const char* name);
LIBRARY_API bool findIntValue(const NAMEVALUELIST* namevaluelist, int* value, const char* name);
LIBRARY_API bool findLongIntValue(const NAMEVALUELIST* namevaluelist, long* value, const char* name);
LIBRARY_API bool findUnsignedLongValue(const NAMEVALUELIST* namevaluelist, unsigned long* value, const char* name);
LIBRARY_API bool findShortValue(const NAMEVALUELIST* namevaluelist, short* value, const char* name);
LIBRARY_API bool findCharValue(const NAMEVALUELIST* namevaluelist, char* value, const char* name);
LIBRARY_API bool findFloatValue(const NAMEVALUELIST* namevaluelist, float* values, const char* name);
Expand Down Expand Up @@ -142,6 +144,8 @@ if (!find##TYPE##Array(&NAME_VALUE_LIST, &VARIABLE, CONCAT(&n, VARIABLE), QUOTE(
}

#define FIND_REQUIRED_INT_VALUE(NAME_VALUE_LIST, VARIABLE) FIND_REQUIRED_VALUE(NAME_VALUE_LIST, VARIABLE, Int)
#define FIND_REQUIRED_LONG_VALUE(NAME_VALUE_LIST, VARIABLE) FIND_REQUIRED_VALUE(NAME_VALUE_LIST, VARIABLE, LongInt)
#define FIND_REQUIRED_UNSIGNED_LONG_VALUE(NAME_VALUE_LIST, VARIABLE) FIND_REQUIRED_VALUE(NAME_VALUE_LIST, VARIABLE, UnsignedLong)
#define FIND_REQUIRED_SHORT_VALUE(NAME_VALUE_LIST, VARIABLE) FIND_REQUIRED_VALUE(NAME_VALUE_LIST, VARIABLE, Short)
#define FIND_REQUIRED_CHAR_VALUE(NAME_VALUE_LIST, VARIABLE) FIND_REQUIRED_VALUE(NAME_VALUE_LIST, VARIABLE, Char)
#define FIND_REQUIRED_FLOAT_VALUE(NAME_VALUE_LIST, VARIABLE) FIND_REQUIRED_VALUE(NAME_VALUE_LIST, VARIABLE, Float)
Expand All @@ -152,6 +156,8 @@ if (!find##TYPE##Array(&NAME_VALUE_LIST, &VARIABLE, CONCAT(&n, VARIABLE), QUOTE(
#define FIND_REQUIRED_DOUBLE_ARRAY(NAME_VALUE_LIST, VARIABLE) FIND_REQUIRED_ARRAY(NAME_VALUE_LIST, VARIABLE, Double)

#define FIND_INT_VALUE(NAME_VALUE_LIST, VARIABLE) findIntValue(&NAME_VALUE_LIST, &VARIABLE, QUOTE(VARIABLE))
#define FIND_LONG_VALUE(NAME_VALUE_LIST, VARIABLE) findLongIntValue(&NAME_VALUE_LIST, &VARIABLE, QUOTE(VARIABLE))
#define FIND_UNSIGNED_LONG_VALUE(NAME_VALUE_LIST, VARIABLE) findUnsignedLongValue(&NAME_VALUE_LIST, &VARIABLE, QUOTE(VARIABLE))
#define FIND_SHORT_VALUE(NAME_VALUE_LIST, VARIABLE) findShortValue(&NAME_VALUE_LIST, &VARIABLE, QUOTE(VARIABLE))
#define FIND_CHAR_VALUE(NAME_VALUE_LIST, VARIABLE) findCharValue(&NAME_VALUE_LIST, &VARIABLE, QUOTE(VARIABLE))
#define FIND_FLOAT_VALUE(NAME_VALUE_LIST, VARIABLE) findFloatValue(&NAME_VALUE_LIST, &VARIABLE, QUOTE(VARIABLE))
Expand Down
2 changes: 1 addition & 1 deletion source/wrappers/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ signal_object = client.get(signal, source)
```

## Old release versions
Releases 2.7.6-2.8.1 were uploaded to the uda project on pypi [here](https://pypi.org/project/uda). The project moved here under the pyuda name for release 2.8.2.
Releases 2.7.6-2.8.1 were uploaded to the uda project on pypi [here](https://pypi.org/project/uda). The project moved here under the pyuda name for release 2.9.0.
2 changes: 1 addition & 1 deletion source/wrappers/python/pyuda/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def get_file(self, source_file, output_file=None, chunk_size=1):
chunk_size = 0

if chunk_size:
result = cpyuda.get_data("bytes::size(path={path})".format(path=source_file) % source_file, "")
result = cpyuda.get_data("bytes::size(path={path})".format(path=source_file), "")
size = result.data()
chunk_size = int(chunk_size * 1024 * 1024)
count = 0
Expand Down
2 changes: 1 addition & 1 deletion source/wrappers/python/uda/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Install the new package directly using:
pip install pyuda
```

Previous release versions (2.7.6-2.8.1) are still hosted here. The first release under the new pyuda name is 2.8.2.
Previous release versions (2.7.6-2.8.1) are still hosted here. The first release under the new pyuda name is 2.9.0.

## Pyuda package description

Expand Down
Loading