params: remove persistent params (#21975)

* cleanup constructors

* remove persistent_param

* remove test_persist_params_put_and_get
pull/22001/head
Dean Lee 2021-08-21 07:57:45 +08:00 committed by GitHub
parent fa023b75a3
commit 3b752a307f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 12 additions and 22 deletions

View File

@ -17,7 +17,7 @@ cdef extern from "selfdrive/common/params.h":
ALL
cdef cppclass Params:
Params(bool) nogil
Params() nogil
Params(string) nogil
string get(string, bool) nogil
bool getBool(string) nogil

View File

@ -30,11 +30,11 @@ class UnknownKeyName(Exception):
cdef class Params:
cdef c_Params* p
def __cinit__(self, d=None, bool persistent_params=False):
def __cinit__(self, d=None):
cdef string path
if d is None:
with nogil:
self.p = new c_Params(persistent_params)
self.p = new c_Params()
else:
path = <string>d.encode()
with nogil:

View File

@ -21,11 +21,6 @@ class TestParams(unittest.TestCase):
self.params.put("DongleId", "cb38263377b873ee")
assert self.params.get("DongleId") == b"cb38263377b873ee"
def test_persist_params_put_and_get(self):
p = Params(persistent_params=True)
p.put("DongleId", "cb38263377b873ee")
assert p.get("DongleId") == b"cb38263377b873ee"
def test_params_non_ascii(self):
st = b"\xe1\x90\xff"
self.params.put("CarParams", st)

View File

@ -228,15 +228,13 @@ std::unordered_map<std::string, uint32_t> keys = {
} // namespace
Params::Params(bool persistent_param) : Params(persistent_param ? Path::persistent_params() : Path::params()) {}
Params::Params() : params_path(Path::params()) {
static std::once_flag once_flag;
std::call_once(once_flag, ensure_params_path, params_path);
}
std::once_flag default_params_path_ensured;
Params::Params(const std::string &path) : params_path(path) {
if (path == Path::params()) {
std::call_once(default_params_path_ensured, ensure_params_path, path);
} else {
ensure_params_path(path);
}
ensure_params_path(params_path);
}
bool Params::checkKey(const std::string &key) {

View File

@ -17,11 +17,8 @@ enum ParamKeyType {
};
class Params {
private:
std::string params_path;
public:
Params(bool persistent_param = false);
Params();
Params(const std::string &path);
bool checkKey(const std::string &key);
@ -78,4 +75,7 @@ public:
inline int putBool(const std::string &key, bool val) {
return putBool(key.c_str(), val);
}
private:
const std::string params_path;
};

View File

@ -29,9 +29,6 @@ inline std::string log_root() {
inline std::string params() {
return Hardware::PC() ? HOME + "/.comma/params" : "/data/params";
}
inline std::string persistent_params() {
return Hardware::PC() ? HOME + "/.comma/params" : "/persist/comma/params";
}
inline std::string rsa_file() {
return Hardware::PC() ? HOME + "/.comma/persist/comma/id_rsa" : "/persist/comma/id_rsa";
}