mesh token changes
from loguru import logger
import pytz
import os
+import time
from django.db import models
from django.core.exceptions import ValidationError
@@ -132,7 +133,9 @@ class CoreSettings(models.Model):
raise AttributeError("MESH_TOKEN_KEY doesn't exist")
except AttributeError:
filepath = "/token/token.key"
- if os.path.exists(filepath):
+ counter = 0
+ while counter < 12:
+ try:
with open(filepath, "r") as read_file:
key = read_file.readlines()
@@ -142,7 +145,11 @@ class CoreSettings(models.Model):
# readlines() returns an array. Get first item
mesh_settings["mesh_token"] = key[0].rstrip()
- else:
+ break
+ except IOError:
pass
+ counter = counter + 1
+ time.sleep(10)
+
return mesh_settings
