Skip to content

Commit 0360ee8

Browse files
authored
Merge pull request #5903 from stephenchengCloud/private/stephenche/drop_python2_XenAPI
Drop python2 support for XenAPI
2 parents 21174bb + 2e883b7 commit 0360ee8

File tree

14 files changed

+24
-47
lines changed

14 files changed

+24
-47
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
uses: actions/upload-artifact@v4
3434
with:
3535
name: XenAPI
36-
path: scripts/examples/python/dist/
36+
path: python3/examples/dist/
3737

3838
build-sdks:
3939
name: Build and upload SDK artifacts

.gitignore

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ config.mk
1616
# python packaging
1717
**/__pycache__/
1818
**/*.pyc
19-
scripts/examples/python/setup.py
20-
scripts/examples/python/XenAPI.egg-info/
21-
scripts/examples/python/build/
22-
scripts/examples/python/dist/
19+
python3/examples/setup.py
20+
python3/examples/XenAPI.egg-info/
21+
python3/examples/build/
22+
python3/examples/dist/
2323

2424
# ignore file needed for building the SDK
2525
ocaml/sdk-gen/csharp/XE_SR_ERRORCODES.xml

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ sdk:
121121
cp -r _build/default/ocaml/sdk-gen/java/autogen/* $(XAPISDK)/java
122122
cp -r _build/default/ocaml/sdk-gen/powershell/autogen/* $(XAPISDK)/powershell
123123
cp -r _build/default/ocaml/sdk-gen/go/autogen/* $(XAPISDK)/go
124-
cp scripts/examples/python/XenAPI/XenAPI.py $(XAPISDK)/python
124+
cp python3/examples/XenAPI/XenAPI.py $(XAPISDK)/python
125125
sh ocaml/sdk-gen/windows-line-endings.sh $(XAPISDK)/csharp
126126
sh ocaml/sdk-gen/windows-line-endings.sh $(XAPISDK)/powershell
127127

@@ -136,7 +136,7 @@ sdk-build-java: sdk
136136
cd _build/install/default/xapi/sdk/java && mvn -f xen-api/pom.xml -B clean package install -Drevision=0.0
137137

138138
python:
139-
$(MAKE) -C scripts/examples/python build
139+
$(MAKE) -C python3/examples build
140140

141141
doc-json:
142142
dune exec --profile=$(PROFILE) -- ocaml/idl/json_backend/gen_json.exe -destdir $(XAPIDOC)/jekyll

ocaml/sdk-gen/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ XenAPI's datamodel. The generation code is written in OCaml and is contained in
99
this directory.
1010

1111
The Python module is not auto-generated, it can be found at
12-
[XenAPI.py](../../scripts/examples/python/XenAPI/XenAPI.py).
12+
[XenAPI.py](../../python3/examples/XenAPI/XenAPI.py).
1313

1414
To compile the generated source code, follow the instructions in the corresponding
1515
`README` files.

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ exclude = [
227227
"ocaml/xcp-rrdd/scripts/rrdd/rrdd.py",
228228
"ocaml/xcp-rrdd/scripts/rrdd/rrdd-example.py",
229229
"python3/packages/observer.py",
230+
"python3/examples/XenAPI/XenAPI.py",
231+
"python3/examples/XenAPIPlugin.py",
232+
230233
]
231234

232235

python3/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ install:
5252
$(IDATA) perfmon/perfmon.service $(DESTDIR)/usr/lib/systemd/system/perfmon.service
5353
$(IPROG) perfmon/sysconfig-perfmon $(DESTDIR)/etc/sysconfig/perfmon
5454

55+
# example/python
56+
$(IDATA) examples/XenAPIPlugin.py $(DESTDIR)$(SITE3_DIR)/
57+
$(IDATA) examples/XenAPI/XenAPI.py $(DESTDIR)$(SITE3_DIR)/
58+
5559

5660
# poweron
5761
$(IPROG) poweron/wlan.py $(DESTDIR)$(PLUGINDIR)/wlan.py

scripts/examples/python/Makefile renamed to python3/examples/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ build:
88
SETUPTOOLS_SCM_PRETEND_VERSION=$(XAPI_VERSION) python -m build --sdist .
99

1010
clean:
11-
dune clean
1211
rm -rf dist/ build/ XenAPI.egg-info/

scripts/examples/python/README.md renamed to python3/examples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ To install the package, enable the virtual environment where it's going to be us
77
Examples
88
--------
99

10-
The [examples](https://github.com/xapi-project/xen-api/tree/master/scripts/examples/python) will not work unless they have been placed in the same directory as `XenAPI.py` or `XenAPI` package from PyPI has been installed (`pip install XenAPI`)
10+
The [examples](https://github.com/xapi-project/xen-api/tree/master/python3/examples) will not work unless they have been placed in the same directory as `XenAPI.py` or `XenAPI` package from PyPI has been installed (`pip install XenAPI`)
1111

1212
Packaging
1313
=========

scripts/examples/python/XenAPI/XenAPI.py renamed to python3/examples/XenAPI/XenAPI.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,8 @@
5858
import os
5959
import socket
6060
import sys
61-
62-
if sys.version_info[0] == 2:
63-
import httplib as httplib
64-
import xmlrpclib as xmlrpclib
65-
else:
66-
import http.client as httplib
67-
import xmlrpc.client as xmlrpclib
61+
import http.client as httplib
62+
import xmlrpc.client as xmlrpclib
6863

6964
otel = False
7065
try:
@@ -150,15 +145,10 @@ class Session(xmlrpclib.ServerProxy):
150145
def __init__(self, uri, transport=None, encoding=None, verbose=False,
151146
allow_none=True, ignore_ssl=False):
152147

153-
if sys.version_info[0] > 2:
154-
# this changed to be a 'bool' in Python3
155-
verbose = bool(verbose)
156-
allow_none = bool(allow_none)
148+
verbose = bool(verbose)
149+
allow_none = bool(allow_none)
157150

158-
# Fix for CA-172901 (+ Python 2.4 compatibility)
159-
# Fix for context=ctx ( < Python 2.7.9 compatibility)
160-
if not (sys.version_info[0] <= 2 and sys.version_info[1] <= 7 and sys.version_info[2] <= 9 ) \
161-
and ignore_ssl:
151+
if ignore_ssl:
162152
import ssl
163153
ctx = ssl._create_unverified_context()
164154
xmlrpclib.ServerProxy.__init__(self, uri, transport, encoding,

0 commit comments

Comments
 (0)