Commit 255f21fb authored by Marco Mariani's avatar Marco Mariani

raise exceptions with ()

parent 2530f76d
...@@ -153,8 +153,7 @@ def getFullComputerInformation(): ...@@ -153,8 +153,7 @@ def getFullComputerInformation():
partition)) partition))
return xml_marshaller.xml_marshaller.dumps(slap_computer) return xml_marshaller.xml_marshaller.dumps(slap_computer)
else: else:
raise NotFoundError, "Only accept request for: %s" % \ raise NotFoundError('Only accept request for: %s' % app.config['computer_id'])
app.config['computer_id']
@app.route('/setComputerPartitionConnectionXml', methods=['POST']) @app.route('/setComputerPartitionConnectionXml', methods=['POST'])
def setComputerPartitionConnectionXml(): def setComputerPartitionConnectionXml():
...@@ -238,8 +237,7 @@ def loadComputerConfigurationFromXML(): ...@@ -238,8 +237,7 @@ def loadComputerConfigurationFromXML():
return 'done' return 'done'
else: else:
raise UnauthorizedError, "Only accept request for: %s" % \ raise UnauthorizedError('Only accept request for: %s' % app.config['computer_id'])
app.config['computer_id']
@app.route('/registerComputerPartition', methods=['GET']) @app.route('/registerComputerPartition', methods=['GET'])
def registerComputerPartition(): def registerComputerPartition():
...@@ -253,8 +251,7 @@ def registerComputerPartition(): ...@@ -253,8 +251,7 @@ def registerComputerPartition():
return xml_marshaller.xml_marshaller.dumps( return xml_marshaller.xml_marshaller.dumps(
partitiondict2partition(partition)) partitiondict2partition(partition))
else: else:
raise UnauthorizedError, "Only accept request for: %s" % \ raise UnauthorizedError('Only accept request for: %s' % app.config['computer_id'])
app.config['computer_id']
@app.route('/supplySupply', methods=['POST']) @app.route('/supplySupply', methods=['POST'])
def supplySupply(): def supplySupply():
...@@ -266,8 +263,7 @@ def supplySupply(): ...@@ -266,8 +263,7 @@ def supplySupply():
else: else:
execute_db('software', 'INSERT OR REPLACE INTO %s VALUES(?)', [url]) execute_db('software', 'INSERT OR REPLACE INTO %s VALUES(?)', [url])
else: else:
raise UnauthorizedError, "Only accept request for: %s" % \ raise UnauthorizedError('Only accept request for: %s' % app.config['computer_id'])
app.config['computer_id']
return '%r added' % url return '%r added' % url
...@@ -361,8 +357,7 @@ def request_not_shared(): ...@@ -361,8 +357,7 @@ def request_not_shared():
address_list.append((address['reference'], address['address'])) address_list.append((address['reference'], address['address']))
# XXX it should be ComputerPartition, not a SoftwareInstance # XXX it should be ComputerPartition, not a SoftwareInstance
return xml_marshaller.xml_marshaller.dumps(SoftwareInstance( software_instance = SoftwareInstance(xml=partition['xml'],
xml=partition['xml'],
connection_xml=partition['connection_xml'], connection_xml=partition['connection_xml'],
slap_computer_id=app.config['computer_id'], slap_computer_id=app.config['computer_id'],
slap_computer_partition_id=partition['reference'], slap_computer_partition_id=partition['reference'],
...@@ -371,8 +366,9 @@ def request_not_shared(): ...@@ -371,8 +366,9 @@ def request_not_shared():
slap_software_type=partition['software_type'], slap_software_type=partition['software_type'],
slave_instance_list=partition['slave_instance_list'], slave_instance_list=partition['slave_instance_list'],
instance_guid=partition['reference'], instance_guid=partition['reference'],
ip_list=address_list ip_list=address_list)
))
return xml_marshaller.xml_marshaller.dumps(software_instance)
def request_slave(): def request_slave():
...@@ -471,13 +467,13 @@ def request_slave(): ...@@ -471,13 +467,13 @@ def request_slave():
address_list.append((address['reference'], address['address'])) address_list.append((address['reference'], address['address']))
# XXX it should be ComputerPartition, not a SoftwareInstance # XXX it should be ComputerPartition, not a SoftwareInstance
return xml_marshaller.xml_marshaller.dumps(SoftwareInstance( software_instance = SoftwareInstance(_connection_dict=xml2dict(slave['connection_xml']),
_connection_dict=xml2dict(slave['connection_xml']),
xml=instance_xml, xml=instance_xml,
slap_computer_id=app.config['computer_id'], slap_computer_id=app.config['computer_id'],
slap_computer_partition_id=slave['hosted_by'], slap_computer_partition_id=slave['hosted_by'],
slap_software_release_url=partition['software_release'], slap_software_release_url=partition['software_release'],
slap_server_url='slap_server_url', slap_server_url='slap_server_url',
slap_software_type=partition['software_type'], slap_software_type=partition['software_type'],
ip_list=address_list ip_list=address_list)
))
return xml_marshaller.xml_marshaller.dumps(software_instance)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment