repr vs. string
---------------

                 Key: LIBCLOUD-156
                 URL: https://issues.apache.org/jira/browse/LIBCLOUD-156
             Project: Libcloud
          Issue Type: Bug
          Components: Core
    Affects Versions: 0.8.0
            Reporter: Mark Nottingham
            Priority: Minor


libcloud.common.types (and perhaps elsewhere) uses __str__ to serialise the 
details of an instance. In Python, this is the job of __repr__, not __str__.

For example, when I get a deployment error currently, this is what it looks 
like in the console:

Traceback (most recent call last):
  File "bin/bootstrap-cloud.py", line 104, in <module>
    ip = create_server(name, image, size, deploy_plan)
  File "bin/bootstrap-cloud.py", line 90, in create_server
    deploy=deploy_plan
  File "/Library/Python/2.7/site-packages/libcloud/compute/base.py", line 601, 
in deploy_node
    raise DeploymentError(node, e)
libcloud.compute.types.DeploymentError: LibcloudError()

If I change __str__ to __repr__ in LibcloudError, it becomes:

Traceback (most recent call last):
  File "bin/bootstrap-cloud.py", line 104, in <module>
    ip = create_server(name, image, size, deploy_plan)
  File "bin/bootstrap-cloud.py", line 90, in create_server
    deploy=deploy_plan
  File "/Library/Python/2.7/site-packages/libcloud/compute/base.py", line 601, 
in deploy_node
    raise DeploymentError(node, e)
libcloud.compute.types.DeploymentError: <LibcloudError in 
<libcloud.compute.drivers.rackspace.RackspaceNodeDriver object at 0x10118e490> 
'Failed after 3 tries'>

which is much more informative.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to