| 2688 | } |
| 2689 | |
| 2690 | bool QPilotMachine::init_withconfig(const std::string& config_path) |
| 2691 | { |
| 2692 | try |
| 2693 | { |
| 2694 | JsonParser json_conf; |
| 2695 | std::string s_pilot_conf; |
| 2696 | std::string s_pilot_conf_buffer; |
| 2697 | std::fstream f_pilot_conf(config_path); |
| 2698 | if (f_pilot_conf.is_open()) |
| 2699 | { |
| 2700 | while (!f_pilot_conf.eof()) |
| 2701 | { |
| 2702 | f_pilot_conf >> s_pilot_conf_buffer; |
| 2703 | s_pilot_conf += s_pilot_conf_buffer; |
| 2704 | } |
| 2705 | f_pilot_conf.close(); |
| 2706 | if (!s_pilot_conf.empty()) |
| 2707 | { |
| 2708 | json_conf.load_json(s_pilot_conf); |
| 2709 | bool log_cout = json_conf.get_bool("log_cout"); |
| 2710 | std::string pilot_url = json_conf.get_string("pilot_url"); |
| 2711 | return init(pilot_url, log_cout); |
| 2712 | } |
| 2713 | } |
| 2714 | PTraceError("Error: pilotmachine configure error:\n{\"log_out\":false,\"pilot_url\":\"https://ip:port\"}"); |
| 2715 | } |
| 2716 | catch (const std::exception& e) |
| 2717 | { |
| 2718 | PTraceError("Error: on exception: " << e.what()); |
| 2719 | throw; |
| 2720 | } |
| 2721 | } |
| 2722 | |
| 2723 | ErrorCode QPilotMachine::get_token(std::string& rep_json) |
| 2724 | { |