def share_file(self, filename, other_user): if os.path.isdir(filename): return rpc.share_folder(other_user, filename, self.server_ip, self.server_port, self.username, self.ip, self.port) with open(filename, "rb") as in_file, open(filename + '.enc', "wb") as out_file: EncryptionTest.encrypt(in_file, out_file, "ThisPassword") in_file.close() out_file.close() with open(filename + '.enc', "rb") as handle: binary_data = xmlrpclib.Binary(handle.read()) handle.close() os.remove(filename + '.enc') return rpc.share_file(other_user, filename, binary_data, self.server_ip, self.server_port, self.username, self.ip, self.port)
def push_file(self, filename): # this method push the modified/new file to the server if os.path.isdir(filename): return rpc.push_folder(filename, self.server_ip, self.server_port, self.username, self.ip, self.port, self.mac) with open(filename, "rb") as in_file, open(filename + '.enc', "wb") as out_file: EncryptionTest.encrypt(in_file, out_file, "ThisPassword") in_file.close() out_file.close() with open(filename + '.enc', "rb") as handle: binary_data = xmlrpclib.Binary(handle.read()) handle.close() os.remove(filename + '.enc') return rpc.push_file(filename, binary_data, self.server_ip, self.server_port, self.username, self.ip, self.port, self.mac)