Skip to content

Commit

Permalink
tests/*.py: support Python 2 again while preferring Python 3
Browse files Browse the repository at this point in the history
This makes it possible to use the Python-based test servers
again in legacy environments which do not have modern Python.

Install Python package impacket in relevant CI workflows.

Follow up to curl#7602 which broke Python 2 support
Follow up to curl#7935 which fixed impacket support
  • Loading branch information
mback2k committed Dec 13, 2021
1 parent 2300ad2 commit b35fcd7
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 14 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/linux-hyper.yml
Expand Up @@ -28,6 +28,9 @@ jobs:
- run: sudo apt-get install libtool autoconf automake pkg-config
name: install prereqs

- run: python3 -m pip install impacket
name: 'pip3 install'

- run: (cd $HOME;
git clone --depth=1 https://github.com/hyperium/hyper.git;
curl https://sh.rustup.rs -sSf | sh -s -- -y;
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/macos.yml
Expand Up @@ -76,6 +76,9 @@ jobs:
- run: brew update && for i in 1 2 3; do brew bundle install --no-lock --file /tmp/Brewfile && break || sleep 1; done
name: 'brew install'

- run: python3 -m pip install impacket
name: 'pip3 install'

- uses: actions/checkout@v2

- run: ./buildconf && ./configure --enable-warnings --enable-werror ${{ matrix.build.configure }}
Expand Down Expand Up @@ -123,6 +126,9 @@ jobs:
- run: brew update && brew bundle install --no-lock --file /tmp/Brewfile
name: 'brew install'

- run: python3 -m pip install impacket
name: 'pip3 install'

- uses: actions/checkout@v2

- run: cmake -H. -Bbuild -DCURL_WERROR=ON -DPICKY_COMPILER=ON ${{ matrix.build.generate }}
Expand Down
13 changes: 8 additions & 5 deletions tests/dictserver.py
@@ -1,6 +1,5 @@
#!/usr/bin/env python3
#!/bin/sh
# -*- coding: utf-8 -*-
#***************************************************************************
# _ _ ____ _
# Project ___| | | | _ \| |
# / __| | | | |_) | |
Expand All @@ -20,13 +19,17 @@
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
###########################################################################
#
""" DICT server """

# The following 3 lines implement a fallback from the interpreter named python3
# to the interpreter named python. This way we prefer Python 3 over Python 2.
# It works by executing the 2nd line using a shell which then executes Python.
""":"
exec "$(command -v python3 || command -v python)" "$0" "$@"
":"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)

""" DICT server"""
import argparse
import logging
import os
Expand Down
12 changes: 9 additions & 3 deletions tests/negtelnetserver.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/bin/sh
# -*- coding: utf-8 -*-
#
# Project ___| | | | _ \| |
Expand All @@ -19,11 +19,17 @@
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
""" A telnet server which negotiates"""

#
# The following 3 lines implement a fallback from the interpreter named python3
# to the interpreter named python. This way we prefer Python 3 over Python 2.
# It works by executing the 2nd line using a shell which then executes Python.
""":"
exec "$(command -v python3 || command -v python)" "$0" "$@"
":"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)

""" A telnet server which negotiates"""
import argparse
import logging
import os
Expand Down
12 changes: 9 additions & 3 deletions tests/smbserver.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/bin/sh
# -*- coding: utf-8 -*-
#
# Project ___| | | | _ \| |
Expand All @@ -19,11 +19,17 @@
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
"""Server for testing SMB"""

#
# The following 3 lines implement a fallback from the interpreter named python3
# to the interpreter named python. This way we prefer Python 3 over Python 2.
# It works by executing the 2nd line using a shell which then executes Python.
""":"
exec "$(command -v python3 || command -v python)" "$0" "$@"
":"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)

"""Server for testing SMB"""
import argparse
import logging
import os
Expand Down
12 changes: 9 additions & 3 deletions tests/util.py
@@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/bin/sh
# -*- coding: utf-8 -*-
#
# Project ___| | | | _ \| |
Expand All @@ -19,11 +19,17 @@
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.
#
"""Module for extracting test data from the test data folder and other utils"""

#
# The following 3 lines implement a fallback from the interpreter named python3
# to the interpreter named python. This way we prefer Python 3 over Python 2.
# It works by executing the 2nd line using a shell which then executes Python.
""":"
exec "$(command -v python3 || command -v python)" "$0" "$@"
":"""
from __future__ import (absolute_import, division, print_function,
unicode_literals)

"""Module for extracting test data from the test data folder and other utils"""
import logging
import os
import re
Expand Down

0 comments on commit b35fcd7

Please sign in to comment.