-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment.py
40 lines (36 loc) · 987 Bytes
/
environment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import socket
import json
import logging
import sys
logging.basicConfig(level=logging.INFO)
class currentMode() :
def __init__(self, myenv):
self.test = True
self.myenv = myenv
# En Prod chez AWS
if self.myenv == 'aws':
#self.yoti_pem_file = '/home/admin/issuer/key.pem'
#self.sys_path = '/home/admin'
self.server = 'https://talao.co/'
self.IP = '18.190.21.227'
elif self.myenv == 'thierry' :
self.server = 'http://' + extract_ip() + ':5000/'
self.IP = extract_ip()
self.port = 5000
elif self.myenv == 'achille' :
self.server = 'http://' + extract_ip() + ':3000/'
self.IP = extract_ip()
self.port = 3000
else :
logging.error('environment variable problem')
sys.exit()
def extract_ip():
st = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
st.connect(('10.255.255.255', 1))
IP = st.getsockname()[0]
except Exception:
IP = '127.0.0.1'
finally:
st.close()
return IP