jfjoch_viewer: Make code tighter regarding empty images
Some checks failed
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 10m40s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 12m26s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 12m31s
Build Packages / Generate python client (push) Successful in 20s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 13m1s
Build Packages / Create release (push) Has been skipped
Build Packages / Build documentation (push) Successful in 44s
Build Packages / build:rpm (rocky8) (push) Successful in 13m9s
Build Packages / build:rpm (rocky9) (push) Has been cancelled
Build Packages / Unit tests (push) Has been cancelled
Build Packages / build:rpm (ubuntu2404) (push) Has been cancelled
Build Packages / build:rpm (rocky9_nocuda) (push) Has been cancelled
Build Packages / build:rpm (rocky8_sls9) (push) Has been cancelled
Some checks failed
Build Packages / build:rpm (ubuntu2404_nocuda) (push) Successful in 10m40s
Build Packages / build:rpm (ubuntu2204_nocuda) (push) Successful in 12m26s
Build Packages / build:rpm (rocky8_nocuda) (push) Successful in 12m31s
Build Packages / Generate python client (push) Successful in 20s
Build Packages / build:rpm (ubuntu2204) (push) Successful in 13m1s
Build Packages / Create release (push) Has been skipped
Build Packages / Build documentation (push) Successful in 44s
Build Packages / build:rpm (rocky8) (push) Successful in 13m9s
Build Packages / build:rpm (rocky9) (push) Has been cancelled
Build Packages / Unit tests (push) Has been cancelled
Build Packages / build:rpm (ubuntu2404) (push) Has been cancelled
Build Packages / build:rpm (rocky9_nocuda) (push) Has been cancelled
Build Packages / build:rpm (rocky8_sls9) (push) Has been cancelled
This commit is contained in:
@@ -10,15 +10,10 @@
|
||||
#include "../broker/gen/model/Plots.h"
|
||||
#include "../image_analysis/bragg_integration/CalcISigma.h"
|
||||
|
||||
void JFJochHttpReader::Close_i() {
|
||||
addr = "";
|
||||
SetStartMessage({});
|
||||
|
||||
}
|
||||
|
||||
void JFJochHttpReader::Close() {
|
||||
std::unique_lock ul(http_mutex);
|
||||
Close_i();
|
||||
addr = "";
|
||||
SetStartMessage({});
|
||||
}
|
||||
|
||||
uint64_t JFJochHttpReader::GetNumberOfImages() const {
|
||||
@@ -43,14 +38,21 @@ uint64_t JFJochHttpReader::GetNumberOfImages() const {
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<JFJochReaderDataset> JFJochHttpReader::UpdateDataset_i() {
|
||||
std::shared_ptr<JFJochReaderDataset> JFJochHttpReader::UpdateDataset_i() {
|
||||
httplib::Client cli_cmd(addr);
|
||||
|
||||
auto res = cli_cmd.Get("/image_buffer/start.cbor");
|
||||
|
||||
if (!res || res->status != httplib::StatusCode::OK_200)
|
||||
if (!res || (res->status != httplib::StatusCode::OK_200
|
||||
&& res->status != httplib::StatusCode::NotFound_404))
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Could not get image buffer status");
|
||||
|
||||
if (res->status == httplib::StatusCode::NotFound_404)
|
||||
return {};
|
||||
if (res->body.empty())
|
||||
return {};
|
||||
|
||||
try {
|
||||
auto msg = CBORStream2Deserialize(res->body);
|
||||
|
||||
@@ -125,19 +127,18 @@ std::shared_ptr<JFJochReaderDataset> JFJochHttpReader::UpdateDataset_i() {
|
||||
|
||||
return dataset;
|
||||
} catch (std::exception &e) {
|
||||
Close_i();
|
||||
throw JFJochException(JFJochExceptionCategory::InputParameterInvalid,
|
||||
"Could not load dataset");
|
||||
std::string("Could not load dataset: ") + std::string(e.what()));
|
||||
}
|
||||
}
|
||||
|
||||
void JFJochHttpReader::ReadURL(const std::string &url) {
|
||||
std::unique_lock ul(http_mutex);
|
||||
|
||||
addr = url;
|
||||
if (url.empty())
|
||||
Close_i();
|
||||
SetStartMessage(UpdateDataset_i());
|
||||
SetStartMessage({});
|
||||
else
|
||||
SetStartMessage(UpdateDataset_i());
|
||||
}
|
||||
|
||||
bool JFJochHttpReader::LoadImage_i(std::shared_ptr<JFJochReaderDataset> &dataset,
|
||||
@@ -155,6 +156,8 @@ bool JFJochHttpReader::LoadImage_i(std::shared_ptr<JFJochReaderDataset> &dataset
|
||||
// Always update dataset, as it might have changed from the last time
|
||||
if (update_dataset)
|
||||
dataset = UpdateDataset_i();
|
||||
if (!dataset)
|
||||
return false;
|
||||
|
||||
auto res = cli_cmd.Get("/image_buffer/image.cbor?id=" + std::to_string(image_number));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user