You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@libcloud.apache.org by "Mark Nottingham (Created) (JIRA)" <ji...@apache.org> on 2012/02/18 00:53:59 UTC

[dev] [jira] [Created] (LIBCLOUD-156) repr vs. string

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

        

[dev] [jira] [Resolved] (LIBCLOUD-156) repr vs. string

Posted by "Tomaz Muraus (Resolved) (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/LIBCLOUD-156?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tomaz Muraus resolved LIBCLOUD-156.
-----------------------------------

    Resolution: Fixed
    
> 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

        

[dev] [jira] [Commented] (LIBCLOUD-156) repr vs. string

Posted by "Tomaz Muraus (Commented) (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/LIBCLOUD-156?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13211196#comment-13211196 ] 

Tomaz Muraus commented on LIBCLOUD-156:
---------------------------------------

Added __repr__ for the common types in 1290936 - http://svn.apache.org/viewvc?view=revision&revision=1290936
                
> 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