Skip to content

Commit

Permalink
Merge pull request commaai#377 from ShaneSmiskol/release2
Browse files Browse the repository at this point in the history
username fix for data collection
  • Loading branch information
sshane authored Jun 8, 2019
2 parents 1830187 + 1d43c60 commit 201b74d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
7 changes: 5 additions & 2 deletions selfdrive/df/df_uploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,20 @@
import random
import os
from common.params import Params
import selfdrive.kegman_conf as kegman

def upload_data():
filepath = "/data/openpilot/selfdrive/df/df-data"
if os.path.isfile(filepath):
if kegman.get("uniqueID") is None:
kegman.save({"uniqueID": ''.join([random.choice(string.lowercase+string.uppercase+string.digits) for i in range(15)])})
try:
username = ''.join([random.choice(string.lowercase+string.uppercase+string.digits) for i in range(15)])
username = kegman.get("uniqueID", ''.join([random.choice(string.lowercase+string.uppercase+string.digits) for i in range(15)]))
try:
with open("/data/data/ai.comma.plus.offroad/files/persistStore/persist-auth", "r") as f:
auth = json.loads(f.read())
auth = json.loads(auth['commaUser'])
if auth:
if auth and str(auth['username']) != "":
username = str(auth['username'])
except:
pass
Expand Down
9 changes: 3 additions & 6 deletions selfdrive/kegman_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,13 @@ def save(data): # allows for writing multiple key/value pairs
variables_written.append(key)
conf.update(data)

def get(key="", default=""): # can specify a default value if key doesn't exist
def get(key=None, default=None): # can specify a default value if key doesn't exist
global thread_counter
if key == "": # get all
if key is None: # get all
return conf
else:
thread_counter = 0
if key in conf:
return conf[key]
else:
return None if default == "" else default
return conf[key] if key in conf else default

thread_counter = 0 # don't change
thread_timeout = 5.0 # minutes to wait before stopping thread. reading or writing will reset the counter
Expand Down

0 comments on commit 201b74d

Please sign in to comment.