def assignIso(self, date, iso, committer): """Tries to assign an iso to the burner. Returns true if the operation was succesful, that is: the burner is burning.""" try: try: connection = common.RequestMaker(self.ip, self.port) except socket.error, e: raise common.BurnerException, "assignIso: Socket error: " + \ str(e) network.handshake(connection) connection.send("%s\n%s\n%s\n%s\n" % (common.MSG_REQUEST_BURN, date, iso, committer)) data = connection.readLine() if data == common.MSG_ACK: retval = True # Succesful! self.free = False self.iso = iso self.committer = committer elif data == common.MSG_NO_SUCH_ISO: self.logger.debug("No such ISO: %s" % iso) retval = False else: raise common.BurnerException, \ ("Strange data from burner: \"%s\"" % data)
def close(self): """Closes the connection with the burner.""" if not self.free: self.logger.error("close: Closing the connection but the burner " \ "is still working") try: connection = common.RequestMaker(self.ip, self.port) network.handshake(connection) connection.send(common.MSG_CLOSING + "\n") data = connection.readLine() if data != common.MSG_ACK: raise common.BurnerException, \ "close: Server doesn't want to tell us goodbye: " \ "\"%s\"" % data connection.close() self.logger.debug("Connection closed.") except common.BurnerException, e: self.logger.error("close: " + str(e))