Adding function
This commit is contained in:
parent
cb2f92ee7c
commit
1607eac1c9
1 changed files with 22 additions and 10 deletions
32
myapp.py
32
myapp.py
|
@ -142,8 +142,23 @@ def database_setter():
|
|||
passw = str(input("Enter the password: "))
|
||||
subprocess.run("echo \"INTERNET_PWD='"+passw+"'\" >> "+database_location+"/config.py", shell=True, executable="/bin/bash")
|
||||
|
||||
def users_manager(lck):
|
||||
pass
|
||||
def users_manager(lck, instruction="ADD", phone_number="000000000", duration=60):
|
||||
dp = datasaver.DataPockets(filename="database_location_path")
|
||||
database_location = dp.get("database_location")[0]
|
||||
dp = datasaver.DataPockets(filename="database", directory_path=database_location)
|
||||
if instruction=="ADD" and (phone_number_to_long_format(phone_number) in dp.get("admins") or phone_number_to_long_format(phone_number) in dp.get("upgraded_to_admins")):
|
||||
dp.append_as_it(pocket_name="guests", what_to_append=phone_number)
|
||||
elif instruction=="REMOVE":
|
||||
pass
|
||||
elif instruction=="UPGRADE":
|
||||
pass
|
||||
|
||||
def phone_number_to_long_format(number="0000000000"):
|
||||
if len(number)==12 and number[0]=="+":
|
||||
return number
|
||||
elif len(number)==10:
|
||||
return "+33"+number[1:]
|
||||
|
||||
|
||||
def opener(lck):
|
||||
with lck:
|
||||
|
@ -185,12 +200,6 @@ def remote_handler(lck):
|
|||
n_attempts += 1
|
||||
print("Attempt "+str(n_attempts)+" fails in finding remote")
|
||||
time.sleep(3)
|
||||
|
||||
def phone_number_to_long_format(number="0000000000"):
|
||||
if len(number)==12 and number[0]=="+":
|
||||
return number
|
||||
elif len(number)==10:
|
||||
return "+33"+number[1:]
|
||||
|
||||
#------ENDPOINTS------
|
||||
|
||||
|
@ -256,7 +265,7 @@ def receiver():
|
|||
if __name__=="__main__":
|
||||
if set_database==1: database_setter()
|
||||
else:
|
||||
dp = datasaver.DataPockets("database_location_path")
|
||||
dp = datasaver.DataPockets(filename="database_location_path")
|
||||
try:
|
||||
database_location = dp.get("database_location")[0]
|
||||
sys.path.insert(0,database_location)
|
||||
|
@ -264,7 +273,10 @@ if __name__=="__main__":
|
|||
print("Unable to find database location folder")
|
||||
exit(-1)
|
||||
#---import config file---
|
||||
import config
|
||||
try:
|
||||
import config
|
||||
except:
|
||||
print("Unable to find config file")
|
||||
if launch_app==1:
|
||||
remote_handler_thread = threading.Thread(target=remote_handler, args=(actuator_locker,))
|
||||
remote_handler_thread.start()
|
||||
|
|
Loading…
Reference in a new issue