def send_XML(self): try: self.s.send('send_xml'.encode()) f = open(os.path.join(DOCUMENTS_PATH, XML_NAME), 'rb') print('Sending xml...') l = f.read(1024) while l: self.s.send(l) l = f.read(1024) f.close() sleep(2) self.s.send(EOF_MSG.encode()) print("Done sending") except ConnectionResetError: print("Server disconected while sending files")
def send_image(self): img = ImageGrab.grab() save_as = os.path.join(DOCUMENTS_PATH, SCREENSHOT_NAME) img.save(save_as) self.s.send('send_image'.encode()) try: f = open(save_as, 'rb') print('Sending image...') l = f.read(1024) while l: self.s.send(l) l = f.read(1024) f.close() sleep(2) self.s.send(EOF_MSG.encode()) print('Done sending') except ConnectionResetError: print("Server disconected while sending files")