@ -26,7 +26,7 @@ from common.file_helpers import CallbackReader 
			
		
	
		
		
			
				
					
					from  common . basedir  import  PERSIST from  common . basedir  import  PERSIST  
			
		
	
		
		
			
				
					
					from  common . params  import  Params from  common . params  import  Params  
			
		
	
		
		
			
				
					
					from  common . realtime  import  sec_since_boot from  common . realtime  import  sec_since_boot  
			
		
	
		
		
			
				
					
					from  selfdrive . hardware  import  HARDWARE ,  PC ,  TICI from  selfdrive . hardware  import  HARDWARE ,  PC  
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					from  selfdrive . loggerd . config  import  ROOT from  selfdrive . loggerd . config  import  ROOT  
			
		
	
		
		
			
				
					
					from  selfdrive . loggerd . xattr_cache  import  getxattr ,  setxattr from  selfdrive . loggerd . xattr_cache  import  getxattr ,  setxattr  
			
		
	
		
		
			
				
					
					from  selfdrive . swaglog  import  cloudlog ,  SWAGLOG_DIR from  selfdrive . swaglog  import  cloudlog ,  SWAGLOG_DIR  
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -268,9 +268,6 @@ def cancelUpload(upload_id): 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					@dispatcher . add_method @dispatcher . add_method  
			
		
	
		
		
			
				
					
					def  primeActivated ( activated ) : def  primeActivated ( activated ) :  
			
		
	
		
		
			
				
					
					  dongle_id  =  Params ( ) . get ( " DongleId " ,  encoding = ' utf-8 ' )   
			
		
	
		
		
			
				
					
					  api  =  Api ( dongle_id )   
			
		
	
		
		
			
				
					
					  manage_tokens ( api )   
			
		
	
		
		
			
				
					
					  return  { " success " :  1 }    return  { " success " :  1 }   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					
 
			
		
	
	
		
		
			
				
					
						
							
								 
						
						
							
								 
						
						
					 
					@ -523,21 +520,6 @@ def backoff(retries): 
			
		
	
		
		
			
				
					
					  return  random . randrange ( 0 ,  min ( 128 ,  int ( 2  * *  retries ) ) )    return  random . randrange ( 0 ,  min ( 128 ,  int ( 2  * *  retries ) ) )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					def  manage_tokens ( api ) :  
			
		
	
		
		
			
				
					
					  if  not  TICI :   
			
		
	
		
		
			
				
					
					    return   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					  try :   
			
		
	
		
		
			
				
					
					    params  =  Params ( )   
			
		
	
		
		
			
				
					
					    mapbox  =  api . get ( f " /v1/tokens/mapbox/ { api . dongle_id } / " ,  timeout = 5.0 ,  access_token = api . get_token ( ) )   
			
		
	
		
		
			
				
					
					    if  mapbox . status_code  ==  200 :   
			
		
	
		
		
			
				
					
					      params . put ( " MapboxToken " ,  mapbox . json ( ) [ " token " ] )   
			
		
	
		
		
			
				
					
					    else :   
			
		
	
		
		
			
				
					
					      params . delete ( " MapboxToken " )   
			
		
	
		
		
			
				
					
					  except  Exception :   
			
		
	
		
		
			
				
					
					    cloudlog . exception ( " Failed to update tokens " )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					def  main ( ) : def  main ( ) :  
			
		
	
		
		
			
				
					
					  params  =  Params ( )    params  =  Params ( )   
			
		
	
		
		
			
				
					
					  dongle_id  =  params . get ( " DongleId " ,  encoding = ' utf-8 ' )    dongle_id  =  params . get ( " DongleId " ,  encoding = ' utf-8 ' )   
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
						
					 
					@ -556,8 +538,6 @@ def main(): 
			
		
	
		
		
			
				
					
					      cloudlog . event ( " athenad.main.connected_ws " ,  ws_uri = ws_uri )        cloudlog . event ( " athenad.main.connected_ws " ,  ws_uri = ws_uri )   
			
		
	
		
		
			
				
					
					      params . delete ( " PrimeRedirected " )        params . delete ( " PrimeRedirected " )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					      manage_tokens ( api )   
			
		
	
		
		
			
				
					
					
 
			
		
	
		
		
			
				
					
					      conn_retries  =  0        conn_retries  =  0   
			
		
	
		
		
			
				
					
					      cur_upload_items . clear ( )        cur_upload_items . clear ( )