未验证 提交 7cc253a6 编写于 作者: X Xiangquan Xiao 提交者: GitHub

 
All: Final clean up of old file util usages. (#6865)
上级 e9f5e64a
......@@ -19,8 +19,8 @@
#include <algorithm>
#include <cmath>
#include "cyber/common/file.h"
#include "modules/common/configs/config_gflags.h"
#include "modules/common/util/file.h"
namespace apollo {
namespace common {
......@@ -34,7 +34,7 @@ void VehicleConfigHelper::Init() { Init(FLAGS_vehicle_config_path); }
void VehicleConfigHelper::Init(const std::string &config_file) {
VehicleConfig params;
CHECK(apollo::common::util::GetProtoFromFile(config_file, &params))
CHECK(cyber::common::GetProtoFromFile(config_file, &params))
<< "Unable to parse vehicle config file " << config_file;
Init(params);
}
......
......@@ -20,7 +20,6 @@
#include "gflags/gflags.h"
#include "cyber/common/log.h"
#include "modules/common/util/file.h"
#include "modules/common/util/string_util.h"
#include "modules/common/util/util.h"
......
......@@ -35,21 +35,10 @@ namespace util {
// usages we'll retire the aliases here.
using apollo::cyber::common::SetProtoToASCIIFile;
using apollo::cyber::common::GetProtoFromASCIIFile;
using apollo::cyber::common::SetProtoToBinaryFile;
using apollo::cyber::common::GetProtoFromBinaryFile;
using apollo::cyber::common::GetProtoFromFile;
using apollo::cyber::common::GetContent;
using apollo::cyber::common::GetAbsolutePath;
using apollo::cyber::common::PathExists;
using apollo::cyber::common::DirectoryExists;
using apollo::cyber::common::Glob;
using apollo::cyber::common::CopyFile;
using apollo::cyber::common::CopyDir;
using apollo::cyber::common::Copy;
using apollo::cyber::common::EnsureDirectory;
using apollo::cyber::common::RemoveAllFiles;
using apollo::cyber::common::ListSubPaths;
using apollo::cyber::common::GetFileName;
} // namespace util
} // namespace common
......
......@@ -24,9 +24,9 @@
#include <memory>
#include <string>
#include "cyber/common/file.h"
#include "google/protobuf/message.h"
#include "modules/common/time/time.h"
#include "modules/common/util/file.h"
#include "modules/common/util/string_util.h"
/**
......@@ -75,8 +75,8 @@ bool DumpMessage(const std::shared_ptr<T>& msg,
auto type_name = T::descriptor()->full_name();
std::string dump_path = dump_dir + "/" + type_name;
if (!DirectoryExists(dump_path)) {
if (!EnsureDirectory(dump_path)) {
if (!cyber::common::DirectoryExists(dump_path)) {
if (!cyber::common::EnsureDirectory(dump_path)) {
AERROR << "Cannot enable dumping for '" << type_name
<< "' because the path " << dump_path
<< " cannot be created or is not a directory.";
......@@ -85,7 +85,7 @@ bool DumpMessage(const std::shared_ptr<T>& msg,
}
auto sequence_num = msg->header().sequence_num();
return util::SetProtoToASCIIFile(
return cyber::common::SetProtoToASCIIFile(
*msg, util::StrCat(dump_path, "/", sequence_num, ".pb.txt"));
}
......
......@@ -31,8 +31,8 @@ TEST(MessageUtilTest, DumpMessage) {
auto simple_msg = std::make_shared<test::SimpleMessage>();
FillHeader("test", simple_msg.get());
EXPECT_TRUE(DumpMessage(simple_msg));
EXPECT_TRUE(
PathExists("/tmp/apollo.common.util.test.SimpleMessage/0.pb.txt"));
EXPECT_TRUE(cyber::common::PathExists(
"/tmp/apollo.common.util.test.SimpleMessage/0.pb.txt"));
}
TEST(MessageUtilTest, MessageFingerprint) {
......
......@@ -21,8 +21,8 @@
#include "Eigen/Core"
#include "gtest/gtest.h"
#include "cyber/common/file.h"
#include "modules/canbus/proto/chassis.pb.h"
#include "modules/common/util/file.h"
#include "modules/localization/common/localization_gflags.h"
#include "modules/localization/proto/localization.pb.h"
......@@ -38,7 +38,7 @@ class VehicleStateProviderTest : public ::testing::Test {
virtual void SetUp() {
std::string localization_file =
"modules/localization/testdata/3_localization_result_1.pb.txt";
CHECK(common::util::GetProtoFromFile(localization_file, &localization_));
CHECK(cyber::common::GetProtoFromFile(localization_file, &localization_));
chassis_.set_speed_mps(3.0);
chassis_.set_gear_location(canbus::Chassis::GEAR_DRIVE);
FLAGS_enable_map_reference_unify = false;
......
......@@ -19,8 +19,8 @@
#include <iostream>
#include <string>
#include "cyber/common/file.h"
#include "gtest/gtest.h"
#include "modules/common/util/file.h"
#include "modules/control/proto/control_conf.pb.h"
#include "modules/control/proto/leadlag_conf.pb.h"
......@@ -32,7 +32,7 @@ class LeadlagControllerTest : public ::testing::Test {
virtual void SetUp() {
std::string control_conf_file =
"/apollo/modules/control/testdata/conf/control_conf.pb.txt";
CHECK(common::util::GetProtoFromFile(control_conf_file, &control_conf_));
CHECK(cyber::common::GetProtoFromFile(control_conf_file, &control_conf_));
lon_controller_conf_ = control_conf_.lon_controller_conf();
}
......
......@@ -201,8 +201,8 @@ bool ControlComponentTest::RunControl(const std::string& test_case_name) {
cyber::common::SetProtoToASCIIFile(control_command_, golden_result_file);
} else {
ControlCommand golden_result;
bool load_success =
common::util::GetProtoFromASCIIFile(full_golden_path, &golden_result);
bool load_success = cyber::common::GetProtoFromASCIIFile(
full_golden_path, &golden_result);
if (!load_success) {
AERROR << "Failed to load golden file: " << full_golden_path;
cyber::common::SetProtoToASCIIFile(control_command_, tmp_golden_path);
......
......@@ -160,7 +160,7 @@ bool ControlTestBase::test_control(const std::string &test_case_name,
cyber::common::GetProtoFromASCIIFile(full_golden_path, &golden_result);
if (!load_success) {
AERROR << "Failed to load golden file: " << full_golden_path;
common::util::SetProtoToASCIIFile(control_command_, tmp_golden_path);
cyber::common::SetProtoToASCIIFile(control_command_, tmp_golden_path);
AINFO << "Current result is written to " << tmp_golden_path;
return false;
}
......
......@@ -16,7 +16,6 @@
#include "modules/data/data_component.h"
#include "cyber/common/log.h"
#include "modules/common/adapters/adapter_gflags.h"
#include "modules/common/util/message_util.h"
#include "modules/data/common/data_gflags.h"
......@@ -26,8 +25,7 @@ namespace apollo {
namespace data {
bool DataComponent::Init() {
CHECK(apollo::common::util::GetProtoFromFile(FLAGS_data_conf_file,
&data_conf_))
CHECK(cyber::common::GetProtoFromFile(FLAGS_data_conf_file, &data_conf_))
<< "Unable to load data conf file: " << FLAGS_data_conf_file;
if (!data_conf_.data_enabled()) {
......@@ -45,8 +43,7 @@ bool DataComponent::Init() {
bool DataComponent::Proc(
const std::shared_ptr<DataInputCommand> &request) {
ADEBUG << "Received data input command: "
<< request->DebugString();
ADEBUG << "Received data input command: " << request->DebugString();
OnDataInputCommand(request);
......@@ -58,10 +55,8 @@ bool DataComponent::Proc(
void DataComponent::CreateReader() {
data_input_cmd_reader_ = node_->CreateReader<DataInputCommand>(
FLAGS_data_topic,
std::bind(
&DataComponent::OnDataInputCommand,
this,
std::placeholders::_1));
std::bind(&DataComponent::OnDataInputCommand, this,
std::placeholders::_1));
CHECK(data_input_cmd_reader_ != nullptr);
}
......
......@@ -21,7 +21,6 @@
#include "cyber/common/file.h"
#include "modules/common/configs/vehicle_config_helper.h"
#include "modules/common/time/time.h"
#include "modules/dreamview/backend/common/dreamview_gflags.h"
namespace apollo {
......@@ -29,7 +28,7 @@ namespace dreamview {
using apollo::common::Status;
using apollo::common::VehicleConfigHelper;
using apollo::common::util::PathExists;
using cyber::common::PathExists;
Dreamview::~Dreamview() { Stop(); }
......
......@@ -85,7 +85,7 @@ std::string TitleCase(const std::string& origin) {
// List subdirs and return a dict of {subdir_title: subdir_path}.
Map<std::string, std::string> ListDirAsDict(const std::string& dir) {
Map<std::string, std::string> result;
const auto subdirs = apollo::common::util::ListSubPaths(dir);
const auto subdirs = cyber::common::ListSubPaths(dir);
for (const auto& subdir : subdirs) {
const auto subdir_title = TitleCase(subdir);
const auto subdir_path = StrCat(dir, "/", subdir);
......@@ -99,9 +99,9 @@ Map<std::string, std::string> ListFilesAsDict(const std::string& dir,
const std::string& extension) {
Map<std::string, std::string> result;
const std::string pattern = StrCat(dir, "/*", extension);
for (const std::string& file_path : apollo::common::util::Glob(pattern)) {
for (const std::string& file_path : cyber::common::Glob(pattern)) {
// Remove the extention and convert to title case as the file title.
const std::string filename = apollo::common::util::GetFileName(file_path);
const std::string filename = cyber::common::GetFileName(file_path);
const std::string file_title =
TitleCase(filename.substr(0, filename.length() - extension.length()));
result.insert({file_title, file_path});
......
......@@ -16,6 +16,7 @@
#include "modules/dreamview/backend/simulation_world/simulation_world_updater.h"
#include "cyber/common/file.h"
#include "google/protobuf/util/json_util.h"
#include "modules/common/util/json_util.h"
#include "modules/common/util/map_util.h"
......@@ -27,7 +28,7 @@ namespace dreamview {
using apollo::common::monitor::MonitorMessageItem;
using apollo::common::util::ContainsKey;
using apollo::common::util::GetProtoFromASCIIFile;
using apollo::cyber::common::GetProtoFromASCIIFile;
using apollo::hdmap::EndWayPointFile;
using apollo::relative_map::NavigationInfo;
using apollo::routing::RoutingRequest;
......
......@@ -19,6 +19,7 @@
#include "google/protobuf/text_format.h"
#include "gtest/gtest.h"
#include "cyber/common/file.h"
#include "cyber/common/log.h"
#include "modules/common/util/util.h"
......@@ -32,7 +33,7 @@ class RTKLocalizationTest : public ::testing::Test {
protected:
template <class T>
void load_data(const std::string &filename, T *data) {
CHECK(common::util::GetProtoFromFile(filename, data))
CHECK(cyber::common::GetProtoFromFile(filename, data))
<< "Failed to open file " << filename;
}
......
......@@ -53,8 +53,8 @@ int main(int argc, char** argv) {
NavigatorConfig navigator_config;
AINFO << "The navigator configuration filename is: "
<< FLAGS_navigator_config_filename;
if (!apollo::common::util::GetProtoFromFile(FLAGS_navigator_config_filename,
&navigator_config)) {
if (!apollo::cyber::common::GetProtoFromFile(FLAGS_navigator_config_filename,
&navigator_config)) {
AERROR << "Failed to parse " << FLAGS_navigator_config_filename;
return -1;
}
......
......@@ -64,7 +64,7 @@ void ResourceMonitor::UpdateStatus(
status->clear_status();
// Monitor available disk space.
for (const auto& disk_space : config.disk_spaces()) {
for (const auto& path : apollo::common::util::Glob(disk_space.path())) {
for (const auto& path : cyber::common::Glob(disk_space.path())) {
const auto space = boost::filesystem::space(path);
const int available_gb = static_cast<int>(space.available >> 30);
if (available_gb < disk_space.insufficient_space_error()) {
......
......@@ -27,7 +27,7 @@ DEFINE_string(process_monitor_name, "ProcessMonitor",
"Name of the process monitor.");
DEFINE_double(process_monitor_interval, 1.5,
"Process status checking interval (s).");
"Process status checking interval in seconds.");
namespace apollo {
namespace monitor {
......@@ -40,10 +40,10 @@ ProcessMonitor::ProcessMonitor()
void ProcessMonitor::RunOnce(const double current_time) {
// Get running processes.
std::vector<std::string> running_processes;
for (const auto& cmd_file : apollo::common::util::Glob("/proc/*/cmdline")) {
for (const auto& cmd_file : cyber::common::Glob("/proc/*/cmdline")) {
// Get process command string.
std::string cmd_string;
if (apollo::common::util::GetContent(cmd_file, &cmd_string) &&
if (cyber::common::GetContent(cmd_file, &cmd_string) &&
!cmd_string.empty()) {
// In /proc/<PID>/cmdline, the parts are seperated with \0, which will be
// converted back to whitespaces here.
......
......@@ -23,8 +23,8 @@
#include <utility>
#include <vector>
#include "cyber/common/file.h"
#include "cyber/common/log.h"
#include "modules/common/util/file.h"
#include "modules/perception/base/object.h"
#include "modules/perception/camera/app/debug_info.h"
#include "modules/perception/camera/common/global_config.h"
......@@ -48,7 +48,7 @@ bool LaneCameraPerception::Init(
std::string config_file =
GetAbsolutePath(options.root_dir, options.conf_file);
config_file = GetAbsolutePath(work_root, config_file);
CHECK(apollo::common::util::GetProtoFromFile(
CHECK(cyber::common::GetProtoFromFile(
config_file, &perception_param_)) << "Read config failed: ";
CHECK(inference::CudaUtil::set_device_id(perception_param_.gpu_id()));
......
......@@ -28,10 +28,10 @@
#include <string>
#include <tuple>
#include "cyber/common/file.h"
#include "cyber/common/log.h"
#include "modules/common/math/math_utils.h"
#include "modules/common/time/time_util.h"
#include "modules/common/util/file.h"
#include "modules/perception/common/perception_gflags.h"
#include "modules/perception/common/sensor_manager/sensor_manager.h"
#include "modules/perception/lib/utils/time_util.h"
......@@ -53,7 +53,7 @@ static int GetGpuId(const camera::CameraPerceptionInitOptions &options) {
std::string config_file =
GetAbsolutePath(options.root_dir, options.conf_file);
config_file = GetAbsolutePath(work_root, config_file);
if (!apollo::common::util::GetProtoFromFile(config_file, &perception_param)) {
if (!cyber::common::GetProtoFromFile(config_file, &perception_param)) {
AERROR << "Read config failed: " << config_file;
return -1;
}
......
......@@ -20,14 +20,13 @@
#include "cyber/common/log.h"
#include "modules/canbus/proto/chassis.pb.h"
#include "modules/common/adapters/adapter_gflags.h"
#include "modules/localization/proto/localization.pb.h"
#include "modules/perception/proto/traffic_light_detection.pb.h"
#include "modules/planning/common/planning_gflags.h"
#include "modules/prediction/proto/prediction_obstacle.pb.h"
#include "modules/routing/proto/routing.pb.h"
#include "modules/common/adapters/adapter_gflags.h"
#include "modules/planning/common/planning_gflags.h"
namespace apollo {
namespace planning {
......@@ -163,8 +162,7 @@ void PlanningTestBase::SetUp() {
CHECK(FeedTestData()) << "Failed to feed test data";
CHECK(apollo::cyber::common::GetProtoFromFile(FLAGS_planning_config_file,
&config_))
CHECK(cyber::common::GetProtoFromFile(FLAGS_planning_config_file, &config_))
<< "failed to load planning config file " << FLAGS_planning_config_file;
CHECK(planning_->Init(config_).ok()) << "Failed to init planning module";
......@@ -243,17 +241,17 @@ bool PlanningTestBase::RunPlanning(const std::string& test_case_name,
TrimPlanning(&adc_trajectory_, no_trajectory_point);
if (FLAGS_test_update_golden_log) {
AINFO << "The golden file is regenerated:" << full_golden_path;
common::util::SetProtoToASCIIFile(adc_trajectory_, full_golden_path);
cyber::common::SetProtoToASCIIFile(adc_trajectory_, full_golden_path);
} else {
ADCTrajectory golden_result;
bool load_success =
common::util::GetProtoFromASCIIFile(full_golden_path, &golden_result);
cyber::common::GetProtoFromASCIIFile(full_golden_path, &golden_result);
TrimPlanning(&golden_result, no_trajectory_point);
if (!load_success ||
!common::util::IsProtoEqual(golden_result, adc_trajectory_)) {
char tmp_fname[100] = "/tmp/XXXXXX";
int fd = mkstemp(tmp_fname);
if (!common::util::SetProtoToASCIIFile(adc_trajectory_, fd)) {
if (!cyber::common::SetProtoToASCIIFile(adc_trajectory_, fd)) {
AERROR << "Failed to write to file " << tmp_fname;
}
AERROR << "found error\ndiff -y " << tmp_fname << " " << full_golden_path;
......
......@@ -138,8 +138,8 @@ void OfflineProcessFeatureProtoFile(
if (list_data_for_learning.data_for_learning_size() <= 0) {
ADEBUG << "Skip writing empty data_for_learning.";
} else {
apollo::common::util::SetProtoToBinaryFile(list_data_for_learning,
output_filename);
apollo::cyber::common::SetProtoToBinaryFile(
list_data_for_learning, output_filename);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册