From 1fc21f0906ee1bd3fb3f0f520cdee910b6d966ec Mon Sep 17 00:00:00 2001 From: Brendan LE GLAUNEC Date: Fri, 2 Dec 2016 16:28:41 +0100 Subject: [PATCH] v1.1.4 : Output more human readable and no more useless alias for namespace --- cameradar_standalone/include/tasks/print.h | 2 ++ cameradar_standalone/src/main.cpp | 4 +--- cameradar_standalone/src/tasks/print.cpp | 18 +++++++++++------- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/cameradar_standalone/include/tasks/print.h b/cameradar_standalone/include/tasks/print.h index 70b2940..8b78322 100644 --- a/cameradar_standalone/include/tasks/print.h +++ b/cameradar_standalone/include/tasks/print.h @@ -23,6 +23,8 @@ namespace etix { namespace cameradar { +static const std::string default_result_file_path = "/tmp/shared/result.json"; + class print : public etix::cameradar::cameradar_task { const configuration& conf; std::shared_ptr cache; diff --git a/cameradar_standalone/src/main.cpp b/cameradar_standalone/src/main.cpp index f43801e..5a21919 100644 --- a/cameradar_standalone/src/main.cpp +++ b/cameradar_standalone/src/main.cpp @@ -18,8 +18,6 @@ #include // iostream #include // parsing opt -namespace cmrdr = etix::cameradar; - void print_version() { std::cout << "Cameradar version " << CAMERADAR_VERSION << std::endl; @@ -108,7 +106,7 @@ main(int argc, char* argv[]) { } // Try to load the configuration - auto conf = cmrdr::load(args); + auto conf = etix::cameradar::load(args); if (not conf.first) { return EXIT_FAILURE; } LOG_INFO_("Configuration successfully loaded", "main"); diff --git a/cameradar_standalone/src/tasks/print.cpp b/cameradar_standalone/src/tasks/print.cpp index 7416e06..25e2826 100644 --- a/cameradar_standalone/src/tasks/print.cpp +++ b/cameradar_standalone/src/tasks/print.cpp @@ -21,24 +21,28 @@ namespace cameradar { // Uses the subnets specified in the conf file to launch nmap bool print::run() const { + bool first = true; std::vector results = (*cache)->get_valid_streams(); std::ofstream file; - bool first = true; - file.open("/tmp/shared/result.json"); + + file.open(default_result_file_path); + if (file.fail()) { + LOG_ERR_("Result file could not be opened : " + default_result_file_path, "print"); + return false; + } + file << "[\n"; for (const auto& stream : results) { - LOG_INFO_("Found a valid RTSP Stream and generated a thumbnail at : " + - stream.thumbnail_path, - "print"); + file << deserialize(stream).toStyledString(); if (first) first = false; else file << ","; - file << deserialize(stream).toStyledString(); + LOG_INFO_("Generated JSON Result : " + deserialize(stream).toStyledString(), "print"); } - file << "\n]"; + file << "]"; file.close(); return true; }