From 245e72e936eb963f7bef65984928d9841972b63f Mon Sep 17 00:00:00 2001 From: Gazebo Date: Sun, 5 Jul 2020 21:50:17 -0300 Subject: [PATCH] BugsCorrigidos --- Server/DataBase.py | 8 ++--- Server/Server.py | 36 +++++++++++++++++++-- Server/__pycache__/DataBase.cpython-36.pyc | Bin 5292 -> 5454 bytes 3 files changed, 37 insertions(+), 7 deletions(-) diff --git a/Server/DataBase.py b/Server/DataBase.py index e07e802..fd81b1a 100644 --- a/Server/DataBase.py +++ b/Server/DataBase.py @@ -47,19 +47,19 @@ def insertDevice(self, name, desc, json): def updateInteraction(self, updateId, key1, key2, key3, res1, res2, res3, command): - self.dataBaseCursor.execute('UPDATE Interactions set KeyWord1 = %s, KeyWord2 = %s, KeyWord3 = %s, Response1 = %s, Response2 = %s, Response3 = %s, WHERE InteractionId = %d', (key1, key2, key3, res1, res2, res3, command, updateId)) + self.dataBaseCursor.execute(f"UPDATE Interactions set KeyWord1 = '{key1}', KeyWord2 = '{key2}', KeyWord3 = '{key3}', Response1 = '{res1}', Response2 = '{res2}', Response3 = '{res3}', Command = '{command}' WHERE InteractionId = '{updateId}' ") self.dataBaseConnector.commit() def updateHomeWork(self, updateId, type, subject, homeWork, delivery, desc): - self.dataBaseCursor.execute('UPDATE HomeWorkManagement set HomeWorkType = %s, HomeWorkSubject = %s, HomeWork = %s, HomeWorkDelivery = %s, HomeWorkDescription = %s, WHERE HomeWorkID = %d', (type, subject, homeWork, delivery, desc, updateId)) + self.dataBaseCursor.execute(f"UPDATE HomeWorkManagement set HomeWorkType = '{type}', HomeWorkSubject = '{subject}', HomeWork = '{homeWork}', HomeWorkDelivery = '{datetime.strptime(delivery, '%d/%m/%Y').date()}', HomeWorkDescription = '{desc}' WHERE HomeWorkID ='{updateId}' ") self.dataBaseConnector.commit() def updateProject(self, updateId, name, repository): - self.dataBaseCursor.execute('UPDATE Projects set ProjectName = %s, ProjectRepository = %s, WHERE ProjectID = %d' % (name, repository, updateId)) + self.dataBaseCursor.execute(f"UPDATE Projects SET ProjectName='{name}', ProjectRepository='{repository}' WHERE ProjectID='{updateId}' ") self.dataBaseConnector.commit() def updateDevice(self, updateId, name, desc, json): - self.dataBaseCursor.execute('UPDATE Device set DeviceName = %s, DeviceDescription = %s, DeviceJsonJson = %s, WHERE DeviceID = %d', (name, desc, json)) + self.dataBaseCursor.execute(f"UPDATE Device SET DeviceName = '{name}', DeviceDescription = '{desc}', DeviceJson = '{json}' WHERE DeviceID = '{updateId}' ") self.dataBaseConnector.commit() diff --git a/Server/Server.py b/Server/Server.py index b34c04d..c80a0fb 100644 --- a/Server/Server.py +++ b/Server/Server.py @@ -59,7 +59,7 @@ def handle(self): data = self.request.recv(5800).decode() print(data) - try: + if True: if data: clientRequest = json.loads(data) @@ -170,12 +170,42 @@ def handle(self): self.request.send(json.dumps({'requestStatus': True}).encode()) + elif clientRequest['request'] == 'updateDevice': + dataBaseConnection.updateDevice(clientRequest['updateId'], + clientRequest['device'], + clientRequest['description'], + clientRequest['json']) + + self.request.send(json.dumps({'requestStatus': True}).encode()) + + elif clientRequest['request'] == 'updateHomeWork': + dataBaseConnection.updateHomeWork(clientRequest['updateId'], + clientRequest['type'], + clientRequest['subject'], + clientRequest['homeWork'], + clientRequest['delivery'], + clientRequest['description']) + + self.request.send(json.dumps({'requestStatus': True}).encode()) + + elif clientRequest['request'] == 'updateInteraction': + dataBaseConnection.updateInteraction(clientRequest['updateId'], + clientRequest['key1'], + clientRequest['key2'], + clientRequest['key3'], + clientRequest['res1'], + clientRequest['res2'], + clientRequest['res3'], + clientRequest['command']) + + self.request.send(json.dumps({'requestStatus': True}).encode()) + else: break - except: - print('error') + #except: + # print('error') server = socketserver.ThreadingTCPServer((host, port), ClientManage) server.serve_forever() diff --git a/Server/__pycache__/DataBase.cpython-36.pyc b/Server/__pycache__/DataBase.cpython-36.pyc index 3f3e79e1e2fb4f7da2f30839070479e026e7eb36..a379d7d5eef3a0bc3810ff862be94abea2cbf190 100644 GIT binary patch delta 826 zcma)4%Wl&^6dgNuY{#|JP-p-NF$jVc1P!I#1_|njwje7?S}GPiN<0g@IF9U4Db@%U z`Gi@bEZ8F^Mtc~TcL{(p%%Aqnv!XUS)32XYyno1H6Mh(kT zBq1O5QPc3UHTHGs)>|iA1wGqwM8N4$|Mkm|48|vZ3tkZQQ;jZp6&#afA_{uLZ#AM; z<4JaLp(Pz8!Dt-BL(z54!3W!&UgzYo9T&GR3ENFAsesj_%0cFEnFD46>nTL>-CA$z zK!_=?!Qrn{=5thL8lU51)yuBzcinq?9o$V~ZYjn6&R+539Y&;`JD-<(WE7{tI8G+O zuM|q>#T^&Od^-CQW%8y);Na;Kz qm{TrU%#W{IUfE6Ok)ADt<~$D+7PZ);&(-_Vb@s8g`o&y+ulxb?wAgL{ delta 558 zcmX@7wMLWEn3tEU>-zt=eH%HMxz)KC7#N&^xL5~B)G%Z*WHF{N)-csD*Ra&E*09yE z*KpJ@rg2PG

A2l9$&fSl%$pPLGFYBtm*Fs@5#PG(tZQ6*S-@?2gCW}xE9=Y(`8f9LgQ zl$vZPEH*ioPg