Skip to content

Commit 5e4a3db

Browse files
committed
Cast safely environemnt varibales to int.
1 parent 3623538 commit 5e4a3db

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

event-based-simulators/main/profile_generator.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,14 @@
55
from cumulocityAPI import C8Y_BASE, C8Y_TENANT, C8Y_HEADERS, CumulocityAPI
66
from oeeAPI import OeeAPI, ProfileCreateMode
77

8-
PROFILES_PER_DEVICE = os.environ.get('PROFILES_PER_DEVICE') or 1
9-
SLEEP_TIME_FOR_PROFILE_CREATION_LOOP = os.environ.get('SLEEP_TIME_FOR_PROFILE_CREATION_LOOP') or 60 * 12
8+
def try_int(value):
9+
try:
10+
return int(value)
11+
except:
12+
return None
13+
14+
PROFILES_PER_DEVICE = try_int(os.environ.get('PROFILES_PER_DEVICE')) or 1
15+
SLEEP_TIME_FOR_PROFILE_CREATION_LOOP = try_int(os.environ.get('SLEEP_TIME_FOR_PROFILE_CREATION_LOOP')) or 60 * 12
1016

1117
parser = ArgumentParser()
1218
group = parser.add_mutually_exclusive_group(required=True)

0 commit comments

Comments
 (0)