Revert "Drop python2 support"

This reverts commit fb1dc7c405.

I was under the impression, that all previous scripts were already
working with python 3. But as it turns out, this isn't true. Reverting,
so I can properly post follow-up patches, that fix the issues before we
apply this "drop python2" patch again.

Related: OS#2819
Change-Id: Ic1559d1a9f7839fa86a841d62a04b22e1caed466
This commit is contained in:
Oliver Smith 2019-12-06 15:51:46 +01:00
parent fb1dc7c405
commit b0ba927e33
13 changed files with 71 additions and 22 deletions

View File

@ -4,6 +4,16 @@ set -ex
COM_FLAGS='-m compileall' COM_FLAGS='-m compileall'
# FIXME: remove once python 2 support is deprecated
PY2=python2
PY2_LIST="osmopy scripts/osmodumpdoc.py scripts/osmotestvty.py scripts/osmotestconfig.py"
$PY2 ./setup.py install
$PY2 tests/test_py2.py
for f in $PY2_LIST
do
$PY2 $COM_FLAGS $f
done
rm -rf ./build rm -rf ./build
PY3=python3 PY3=python3
PY3_LIST="osmopy scripts/osmo_ctrl.py scripts/osmo_rate_ctr2csv.py scripts/osmodumpdoc.py scripts/osmotestvty.py scripts/osmotestconfig.py scripts/osmo_interact_ctrl.py scripts/osmo_interact_vty.py scripts/osmo_verify_transcript_ctrl.py scripts/osmo_verify_transcript_vty.py scripts/soap.py scripts/twisted_ipa.py" PY3_LIST="osmopy scripts/osmo_ctrl.py scripts/osmo_rate_ctr2csv.py scripts/osmodumpdoc.py scripts/osmotestvty.py scripts/osmotestconfig.py scripts/osmo_interact_ctrl.py scripts/osmo_interact_vty.py scripts/osmo_verify_transcript_ctrl.py scripts/osmo_verify_transcript_vty.py scripts/soap.py scripts/twisted_ipa.py"

16
debian/control vendored
View File

@ -2,12 +2,26 @@ Source: osmo-python-tests
Section: python Section: python
Priority: optional Priority: optional
Maintainer: Harald Welte <laforge@gnumonks.org> Maintainer: Harald Welte <laforge@gnumonks.org>
Build-Depends: debhelper (>= 9), dh-python, python3, python3-setuptools Build-Depends: debhelper (>= 9), python, dh-python, python-setuptools, python3, python3-setuptools
Standards-Version: 3.9.8 Standards-Version: 3.9.8
Homepage: http://git.osmocom.org/python/osmo-python-tests/ Homepage: http://git.osmocom.org/python/osmo-python-tests/
Vcs-Git: git://git.osmocom.org/python/osmo-python-tests Vcs-Git: git://git.osmocom.org/python/osmo-python-tests
Vcs-Browser: http://git.osmocom.org/python/osmo-python-tests/ Vcs-Browser: http://git.osmocom.org/python/osmo-python-tests/
Package: python2-osmopy-libs
Architecture: all
Depends: ${python:Depends}, ${misc:Depends}
Description: Python code (not only) for testing of Osmocom programs
.
This package contains the Python 2 version of osmopy libraries.
Package: python2-osmopy-utils
Architecture: all
Depends: ${python:Depends}, ${misc:Depends}, python2-osmopy-libs
Description: Python code (not only) for testing of Osmocom programs
.
This package contains the Python 2 version of osmopy utils.
Package: python3-osmopy-libs Package: python3-osmopy-libs
Architecture: all Architecture: all
Depends: ${python3:Depends}, ${misc:Depends} Depends: ${python3:Depends}, ${misc:Depends}

6
debian/rules vendored
View File

@ -1,9 +1,13 @@
#!/usr/bin/make -f #!/usr/bin/make -f
%: %:
dh $@ --with python3 dh $@ --with python2,python3
override_dh_auto_install: override_dh_auto_install:
python2 setup.py install --install-layout=deb --root=$(CURDIR)/debian/python2-osmopy-libs
rm -rf $(CURDIR)/debian/python2-osmopy-libs/usr/bin
python2 setup.py install --install-layout=deb --root=$(CURDIR)/debian/python2-osmopy-utils
rm -rf $(CURDIR)/debian/python2-osmopy-utils/usr/lib
python3 setup.py install --install-layout=deb --root=$(CURDIR)/debian/python3-osmopy-libs python3 setup.py install --install-layout=deb --root=$(CURDIR)/debian/python3-osmopy-libs
rm -rf $(CURDIR)/debian/python3-osmopy-libs/usr/bin rm -rf $(CURDIR)/debian/python3-osmopy-libs/usr/bin
python3 setup.py install --install-layout=deb --root=$(CURDIR)/debian/python3-osmopy-utils python3 setup.py install --install-layout=deb --root=$(CURDIR)/debian/python3-osmopy-utils

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python
__version__ = '0.1.0' __version__ = '0.1.0'
__all__ = ['obscvty', 'osmoutil', 'osmo_ipa', 'osmo_interact', 'trap_helper', 'twisted_ipa'] __all__ = ['obscvty', 'osmoutil', 'osmo_ipa', 'osmo_interact', 'trap_helper', 'twisted_ipa']

View File

@ -16,6 +16,7 @@
# #
# VTY helper code for OpenBSC # VTY helper code for OpenBSC
# #
from __future__ import print_function
import re import re
import socket import socket
import sys, subprocess import sys, subprocess

View File

@ -1,2 +1,2 @@
#!/usr/bin/env python3 #!/usr/bin/env python
__all__ = ['common', 'vty', 'ctrl'] __all__ = ['common', 'vty', 'ctrl']

View File

@ -24,6 +24,11 @@ This implements all of application interaction, piping and verification.
vty.py and ctrl.py plug VTY and CTRL interface specific bits. vty.py and ctrl.py plug VTY and CTRL interface specific bits.
''' '''
# Our setup.py currently wants everything to be parsable by both py2 and py3.
# IMHO that is not a good idea, but until that changes, let's just keep this
# py2 legacy shim in here so we can syntax-check this py3 module with py2.
from __future__ import print_function
import argparse import argparse
import sys import sys
import os import os

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python
# (C) 2013 by Katerina Barone-Adesi <kat.obsc@gmail.com> # (C) 2013 by Katerina Barone-Adesi <kat.obsc@gmail.com>
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
@ -14,6 +14,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import subprocess import subprocess
import os import os
import sys import sys

View File

@ -1,9 +1,10 @@
#!/usr/bin/env python3 #!/usr/bin/env python
# Make sure this code is in sync with the BTS directory. # Make sure this code is in sync with the BTS directory.
# Fixes may need to be applied to both. # Fixes may need to be applied to both.
"""Start the process and dump the documentation to the doc dir.""" """Start the process and dump the documentation to the doc dir."""
from __future__ import print_function
import subprocess import subprocess
import time import time
import os import os

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python
# (C) 2013 by Katerina Barone-Adesi <kat.obsc@gmail.com> # (C) 2013 by Katerina Barone-Adesi <kat.obsc@gmail.com>
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import os import os
import os.path import os.path
import time import time

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3 #!/usr/bin/env python
# (C) 2013 by Katerina Barone-Adesi <kat.obsc@gmail.com> # (C) 2013 by Katerina Barone-Adesi <kat.obsc@gmail.com>
# This program is free software: you can redistribute it and/or modify # This program is free software: you can redistribute it and/or modify
@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import print_function
import os import os
import time import time
import unittest import unittest

View File

@ -19,20 +19,24 @@ from setuptools import setup, find_packages
from osmopy import __version__ from osmopy import __version__
import sys import sys
scripts = [ if sys.version_info.major == 2:
"scripts/osmodumpdoc.py", scripts = [
"scripts/osmotestvty.py", "scripts/osmodumpdoc.py",
"scripts/osmotestconfig.py", "scripts/osmotestconfig.py",
"scripts/osmo_ctrl.py", "scripts/osmotestvty.py",
"scripts/osmo_rate_ctr2csv.py", ]
"scripts/soap.py", elif sys.version_info.major == 3:
"scripts/ctrl2cgi.py", scripts = [
"scripts/osmo_trap2cgi.py", "scripts/osmo_ctrl.py",
"scripts/osmo_interact_vty.py", "scripts/osmo_rate_ctr2csv.py",
"scripts/osmo_interact_ctrl.py", "scripts/soap.py",
"scripts/osmo_verify_transcript_vty.py", "scripts/ctrl2cgi.py",
"scripts/osmo_verify_transcript_ctrl.py", "scripts/osmo_trap2cgi.py",
] "scripts/osmo_interact_vty.py",
"scripts/osmo_interact_ctrl.py",
"scripts/osmo_verify_transcript_vty.py",
"scripts/osmo_verify_transcript_ctrl.py",
]
setup( setup(
name = 'osmopython', name = 'osmopython',

7
tests/test_py2.py Normal file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env python2
# just import a smoke test for osmopy
import osmopy
print '[Python2] Smoke test PASSED.'