Форум сайта python.su
ребят объясните,нужно слить 2 скрипта,направьте пожалуйста в правильном направлении правильно ли сделал?может тут ответят?
1)
import os def archive_check(): s2 = os.access("Z:\\TrassirArchive", os.F_OK) if s2 == True: settings("archive/z")["read_only"] = 0 timeout(30*1000) settings("archive/f")["read_only"] = 1 settings("archive/d")["read_only"] = 1 timeout(10*1000, archive_check) else: settings("archive/f")["read_only"] = 0 settings("archive/d")["read_only"] = 0 alert("Íå äîñòóïåí âíåøíèé ìàññèâ!")# %s") %s2) timeout(10*1000, archive_check) timeout(0, archive_check)
import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('localhost', 8000)) s.listen(5) while True: try: client, addr = s.accept() while True: data = client.recv(1024) if data: print("Data: %s" % data) except Exception, ex: print("Some exception!\n",ex) try: print("IP: {ip}".format(ip=addr)) print("Host: {name}".format(name=socket.gethostbyaddr(str(addr)))) except (NameError, socket.error): pass
import os import socket s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.bind(('localhost', 8000)) s.listen(5) def archive_check(): s2 = os.access("Z:\\TrassirArchive", os.F_OK) if s2 == True: try: client, addr = s.accept() while True: data = client.recv(1024) if data: print("Data: %s" % data) except Exception, ex: print("Some exception!\n",ex) try: print("IP: {ip}".format(ip=addr)) print("Host: {name}".format(name=socket.gethostbyaddr(str(addr)))) except (NameError, socket.error): pass settings("archive/z")["read_only"] = 0 timeout(30*1000) settings("archive/f")["read_only"] = 1 settings("archive/d")["read_only"] = 1 timeout(10*1000, archive_check) else: settings("archive/f")["read_only"] = 0 settings("archive/d")["read_only"] = 0 alert("Íå äîñòóïåí âíåøíèé ìàññèâ!")# %s") %s2) timeout(10*1000, archive_check) timeout(0, archive_check)
Офлайн