From c345bb1d8f51fe7a4c42dddfe3555e4d424a129d Mon Sep 17 00:00:00 2001 From: Rick Lan Date: Tue, 2 Jul 2019 16:19:22 +1000 Subject: [PATCH] =?UTF-8?q?dragonconf=20=E6=94=B9=E8=87=B3=20apk?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- selfdrive/dragonpilot/dragonconf/__init__.py | 66 ++++++++++---------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/selfdrive/dragonpilot/dragonconf/__init__.py b/selfdrive/dragonpilot/dragonconf/__init__.py index c9429015b..ef6598ceb 100644 --- a/selfdrive/dragonpilot/dragonconf/__init__.py +++ b/selfdrive/dragonpilot/dragonconf/__init__.py @@ -1,8 +1,8 @@ #!/usr/bin/env python2.7 -import os -import json +# import os +# import json -file = '/data/dragonpilot.json' +# file = '/data/dragonpilot.json' default_conf = { @@ -12,39 +12,39 @@ default_conf = { 'DragonTempDisableSteerOnSignal': '0', } -def write_json_config(config): - with open(file, 'w') as f: - json.dump(config, f, indent=2, sort_keys=True) - os.chmod(file, 0644) +# def write_json_config(config): +# with open(file, 'w') as f: +# json.dump(config, f, indent=2, sort_keys=True) +# os.chmod(file, 0644) def dragonpilot_set_params(params): - # create new json file - if not os.path.isfile(file): - write_json_config(default_conf) - config = default_conf - else: - # load from json - with open(file, 'r') as f: - config = json.load(f) - - json_update_needed = False - # add new keys - for key, val in default_conf.items(): - if key not in config: - json_update_needed = True - config[key] = val - - # remove invalid keys - for key, val in config.items(): - if key not in default_conf: - json_update_needed = True - config.pop(key, None) - - # write to json if update needed - if json_update_needed: - write_json_config(config) + # # create new json file + # if not os.path.isfile(file): + # write_json_config(default_conf) + # config = default_conf + # else: + # # load from json + # with open(file, 'r') as f: + # config = json.load(f) + # + # json_update_needed = False + # # add new keys + # for key, val in default_conf.items(): + # if key not in config: + # json_update_needed = True + # config[key] = val + # + # # remove invalid keys + # for key, val in config.items(): + # if key not in default_conf: + # json_update_needed = True + # config.pop(key, None) + # + # # write to json if update needed + # if json_update_needed: + # write_json_config(config) # set params - for key, val in config.items(): + for key, val in default_conf.items(): if params.get(key) is None: params.put(key, str(val))