def start_setup(): pwd = "1" password = input("Enter password: "******"Available devices are:") s.available_devs() selection = input("\nSelect :"+"\n"+"a : Add device"+"\n"+"r : Remove device"+"\n"+"x : Exit"+"\n") selection = selection.lower() if selection == 'x': print ("Exiting...") Play_speech("System rebooting").start() time.sleep(2) startup() break elif selection == 'a': room_name = input("Enter room: ").strip() device_name = input("Enter device: ").strip() s.add_device(device_name, room_name) elif selection == 'r': room_name = input("Enter room: ").strip() device_name = input("Enter device: ").strip() s.remove_device(device_name, room_name) else: Play_speech("Please check your password").start() print("Wrong password !!!") return False
def wait_for_secret_word(): session_user.open_file("r") import_session = session_user.file.readline().split(',') while len(import_session) >= 3: session_user.close_file() session_user.open_file("r") import_session = session_user.file.readline().split(',') time.sleep(1) session_user.close_file() global secret_word global word_level secret_word = import_session[0] word_level = import_session[1] global secret_word_split secret_word_split = [] for i in secret_word.lower(): secret_word_split.append(i) global input_list input_list = [] for i in range(0, int(word_level)): input_list.append("_") global user_fails user_fails = 0 global user_tries user_tries = int(word_level) * 2 global letters_tried letters_tried = [] user_input(input_list, secret_word, secret_word_split)
def state(self): try: self.open_file("r") self.session_state = int(self.file.readline().split(',')[2]) self.close_file() return self.session_state except IndexError: time.sleep(1) self.state()
def motor(): global water_v, low if not water_v: w = Water() #create water thread w.Start() time.sleep(2) if not w.isAlive: water_v = low Log("Unable to start water thread.").start()
def error_led(): global low, high, er_pin pi.digitalWrite(er_pin, low) #make pin 13 low for i in range(0, 3): #blink LED 3 times time.sleep(0.5) #delay 0.5sec pi.digitalWrite(er_pin, high) #make pin high time.sleep(0.5) pi.digitalWrite(er_pin, low) #make pin low return
def win(): session_user.write_file("{}, {}, {}, {}".format(input_list, user_tries, letters_tried, True)) print(Fore.GREEN + "\n\n\nYou have won\n" + "Your number of mistakes: " + str(user_fails) + "\n\n") #timenow = datetime.now() time.sleep(3) #addtoleaderboard(timenow) #hangman_main() sys.exit(0)
def check(): global dev_pins, room, device, operation, event if device: dev = dev_pins[room][device]["obj"] if not operation: operation = high if dev.get(): operation = low if device == "fan": response = dev.fan_toggle(operation) else: response = dev.toggle(operation) if not response or dev.get() != operation: #checking command execution Log("Executing the command\n\t"+room+" "+device+" "+str(operation)+".").start() return True else: if event == "play": if not s_features["play"]: p = process.Process(target=play_d, args=(operation,)) p.start() time.sleep(0.2) if p.is_alive(): s_features["play"] = p else: s_features["play"] = None Log("Unable to start play thread.").start() #Create and run error thread elif s_features["play"].is_alive(): print ("Already playing...") elif event == "send": response = re.search('(.*)\\sto\\s.*?(\w+)', operation, re.I) if response: message = response.group(1) to = response.group(2) E_mail(message, to).start() elif event == "time": play_string("time") elif event == "day": play_string("day") elif event == "stop": if s_features["play"] and s_features["play"].is_alive(): s_features["play"].terminate() time.sleep(0.5) if s_features["play"].is_alive(): Log("Unable to stop play thread.").start() else: s_features["play"] = None elif operation == "motor": water_v = low elif event == "setup": start_setup() return True
def waiting_for_user(self): user_is_ready = False while user_is_ready == False: if self.state() == 1: print(Fore.GREEN + "User is ready") user_is_ready = True elif self.state() == 0: print(Fore.YELLOW + "User is not ready") time.sleep(1) else: print(Fore.RED + "Something went wrong, exiting Hangman") sys.exit(0) self.open_file("r") self.name_of_user = self.file.readline().split(',')[1] self.close_file()
def water_toggle(sw): global water_v, low, high, u_e, o_e, o_f water_v = high while water_v: if ((not sw.get(o_e)) and sw.get(u_e)) or sw.get(): if not sw.get(): sw.toggle(high) #turn on while sw.get(u_e) and water_v: if sw.get(o_f): break elif not sw.get(): break time.sleep(5) #5 seconds if sw.get(): sw.toggle(low) #turn off time.sleep(300) #5 minutes
def welcome(): """ """ from modules import version from modules import time from modules import mode print(mode) print( " \t\twelcome to SHARET\n\t by toutpuissantged \n\t\t contact :: mail :[email protected] ; whatsapps+telegrame : +228 96870360\n \t\t\tversion : {} \n" .format(version)) date = int(time.time()) expir = 1689807440 rest = int(expir - date) r_j = int(rest / (60 * 60 * 24)) if date >= expir: print( "your software has expired since {} days and needs an update \n please contact the developer by email at [email protected] or on whatsapps + telegrame on +228 96870360 \n NB : this software is 100% free the developer will also provide you the updates completely free of charge." .format(-r_j)) time.sleep(5) exit() else: print( " \t\ttime remaining before the update: {} jours ".format(r_j))
def user_stats(): # Importing stats from session_admin.txt # Import: "Eingabeliste", "Remaining Tries", "All letters inputed", "Is word Correct (Bool)" did_game_end = False session_admin.open_file("r") while not did_game_end: session_admin.open_file("r") import_session = session_admin.file.readline().split(';') session_admin.close_file() print(import_session) try: input_list = import_session[0] remaining_tries = import_session[1] all_letters_tried = import_session[2] check_game_state = import_session[3] if check_game_state == "True": did_game_end = True print("\n\n\n\n\n\nWord: {} \nRemaining tries: {}\nAll letters tried: {}\nDid Game End?{}".format(str(input_list), str(remaining_tries), str(all_letters_tried), str(did_game_end))) time.sleep(1) except IndexError: print("IndexError") # TODO Zeile entfernen wenn alles funktioniert time.sleep(1) session_admin.close_file() get_results(input_list, remaining_tries)
def loser(secret_word): session_user.write_file("{}, {}, {}, {}".format(input_list, user_tries, letters_tried, False)) print(Fore.RED + "You lost, the solution is: " + secret_word + "\n\n\n") time.sleep(3)
def wait_for_admin(): if session_user.state() == 0: session_user.start_user() else: time.sleep(1) wait_for_admin()
def serveur(): from modules import calc,conf_r,time,zlib,datetime,sqlite3,subprocess,sys,os,hashlib,base hosta,hostb,temp=base.ip_rd() temp=int(temp) inte=1 port = 5566 n=0 tim4=0.0 deb=0 ps2=False ps3=0 if inte==1: import socket sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) host1=socket.gethostname() host1=hosta sock.bind((host1,port)) if n==0: print("your network address is : ",str(hosta)) n+=1 while inte: sock.listen() conn, adress =sock.accept() while inte: msg2=conn.recv(1024).decode("utf8") if msg2=="send": neu=1 nou=0 msg3=conn.recv(1024).decode("utf8") msg6 =conn.recv(1024).decode("utf8") print("your friend sends you the file => ",str(msg3)) if deb==0: seuc=input('press enter to validate !!! ') if seuc=="": seuc=5 else : seuc=float(seuc) deb+=1 msg4="virtual/receved/" msg5=msg4+msg3 fd =open(msg5,'wb') ft= open('virtual/system/temp','wb') print("compression recu est "+msg6) while neu: tim1=time.time() ft.write(conn.recv(1024)) tim2=time.time() tim3=(tim2-tim1) tim4+=tim3 if nou==0: print("reception in progress") nou+=1 if tim3>=seuc: tim4=int(tim4) ft.close() neu=0 ft= open('virtual/system/temp','rb') z_temp=ft.read() ft.close() z_fin=zlib.decompress(z_temp,wbits=0) fd.write(z_fin) fd.close() os.remove('virtual/system/temp') t_now=datetime.datetime.today() forma_t="["+str(t_now.year)+'-'+str(t_now.month)+'-'+str(t_now.day)+' '+str(t_now.hour)+':'+str(t_now.minute)+':'+str(t_now.second)+"] \t "+msg3+" \t succesfuly receved \n" ft2= open('virtual/system/receved.history','a') ft2.write(forma_t) ft2.close() print("receive {} end with a time of {} seconds \n your message : ".format(msg3,tim4)) elif msg2=="cmd": msg2=conn.recv(1024).decode("utf8") h=subprocess.getoutput(msg2) conn.send(str(h).encode("utf8")) elif msg2=="exit": print('disconnection !!!') time.sleep(1) exit() elif msg2=='check': pass elif msg2=='sendall': dec=conn.recv(1024).decode("utf8") if dec=='end': pass else: ps2=True if ps2==True: print('taille de la liste == ',dec) lon=int(dec) while ps3<lon: pass ps2=False elif msg2=="money": mrecu="" mrecu=conn.recv(1024).decode("utf8") print("you just received {} money".format(mrecu)) mrecu=int(mrecu) if mrecu !=0: conn2=sqlite3.connect("virtual/system/base.db") cur=conn2.cursor() cur.execute("select money from info") for l in cur: liste_d=l cur.execute("select pseudo from info") for l in cur: liste_s=l cur.execute("select code from info") for l in cur: liste_n=l cur.execute("select hache from info") for l in cur: liste_h=l t2money=(liste_d[0]) snum=0 tb=1 while tb==1: ts2=hashlib.sha224((bytes(str(snum),'utf8'))).hexdigest() if ts2==t2money: tb=0 t3money=snum else: snum+=1 nmoney=mrecu+t3money hmoney=hashlib.sha224((bytes(str(nmoney),'utf8'))).hexdigest() don2=(liste_s[0],liste_n[0],hmoney,liste_h[0]) cur.execute("insert into info (pseudo,code,money,hache) values(?,?,?,?)",don2) conn2.commit() cur.close() conn2.close() else : time.sleep(0.0) print("\n message from your friend: ",str(msg2))