Skip to content

Conversation

alexbrett
Copy link
Contributor

The document was updated in f785993 to use Python 3, however the examples were left unchanged.

In Python 3, xmlrpclib does not exist, it has been replaced by the xmlrpc module (specifically in this case xmlrpclib.Server has been replaced by xmlrpc.client.ServerProxy).

Additionally, the python-jsonrpc package has not been ported to Python 3, and as such is unavailable. There is no direct replacement, however a combination of the jsonrpcclient package and the requests packages provide a reasonable solution.

This commit updates the examples appropriately so they function in Python 3.

@@ -473,8 +473,17 @@ Import the library `xmlrpclib` and create a
python object referencing the remote server as shown below:

```python
>>> import xmlrpclib
>>> xen = xmlrpclib.Server("https://localhost:443")
>>> import xmlrpc.client
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above this is referred to as xmlrpclib and should be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

The document was updated in f785993 to use
Python 3, however the examples were left unchanged.

In Python 3, `xmlrpclib` does not exist, it has been replaced by the `xmlrpc`
module (specifically in this case `xmlrpclib.Server` has been replaced by
`xmlrpc.client.ServerProxy`).

Additionally, the `python-jsonrpc` package has not been ported to Python 3, and
as such is unavailable. There is no direct replacement, however a combination of
the `jsonrpcclient` package and the `requests` packages provide a reasonable
solution.

This commit updates the examples appropriately so they function in Python 3.

Signed-off-by: Alex Brett <alex.brett@cloud.com>
@lindig lindig enabled auto-merge October 16, 2024 14:26
@lindig lindig added this pull request to the merge queue Oct 16, 2024
Merged via the queue into xapi-project:master with commit 1683f8f Oct 16, 2024
15 checks passed
@@ -639,7 +656,7 @@ To retrieve the record of a single object as a python dictionary:
To retrieve all the VM records in a single call:

```python
>>> records = client.call("VM.get_all_records", session)
>>> records = jsonrpccall("VM.get_all_records", (session,))
>>> records.keys()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arriving a bit too late to this, and not caused by this PR, but the output shown is retrieved with list(records.keys()).
records.keys() shows dict_keys(['OpaqueRef:1', 'OpaqueRef:2', 'OpaqueRef:3', 'OpaqueRef:4' ])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants