Skip to content

Commit 769b6a2

Browse files
authored
Merge pull request hpcugent#337 from wdpypere/py3only
python3 only
2 parents db114c4 + c6554d6 commit 769b6a2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+208
-490
lines changed

.github/workflows/unittest.yml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1-
name: run python tests
2-
on: [push, pull_request]
3-
1+
# .github/workflows/unittest.yml: configuration file for github actions worflow
2+
# This file was automatically generated using 'python -m vsc.install.ci'
3+
# DO NOT EDIT MANUALLY
44
jobs:
55
python_unittests:
6-
runs-on: ubuntu-20.04
7-
strategy:
8-
matrix:
9-
python: [2.7, 3.6, 3.7, 3.8, 3.9]
10-
steps:
11-
- name: Checkout code
12-
uses: actions/checkout@v2
13-
- name: Setup Python
14-
uses: actions/setup-python@v2
15-
with:
16-
python-version: ${{ matrix.python }}
17-
- name: install tox
18-
run: pip install tox
19-
- name: add mandatory git remote
20-
# 'hpcugent' is a mandatory remote for setup.py to work (because of get_name_url)
21-
run: git remote add hpcugent https://github.com/hpcugent/vsc-base.git
22-
- name: Run tox
23-
# Run tox using the version of Python in `PATH`
24-
run: tox -e py
6+
runs-on: ubuntu-20.04
7+
steps:
8+
- name: Checkout code
9+
uses: actions/checkout@v3
10+
- name: Setup Python
11+
uses: actions/setup-python@v4
12+
with:
13+
python-version: ${{ matrix.python }}
14+
- name: install tox
15+
run: pip install tox
16+
- name: add mandatory git remote
17+
run: git remote add hpcugent https://github.com/hpcugent/vsc-base.git
18+
- name: Run tox
19+
run: tox -e py
20+
strategy:
21+
matrix:
22+
python:
23+
- 3.6
24+
- 3.9
25+
name: run python tests
26+
'on':
27+
- push
28+
- pull_request

Jenkinsfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ node {
99
sh 'git clean -fxd'
1010
}
1111
stage('test') {
12-
sh 'python2.7 -V'
1312
sh 'pip3 install --ignore-installed --prefix $PWD/.vsc-tox tox'
1413
sh 'export PATH=$PWD/.vsc-tox/bin:$PATH && export PYTHONPATH=$PWD/.vsc-tox/lib/python$(python3 -c "import sys; print(\\"%s.%s\\" % sys.version_info[:2])")/site-packages:$PYTHONPATH && tox -v -c tox.ini'
1514
sh 'rm -r $PWD/.vsc-tox'

README.md

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
# vsc-base
22

3-
### Build Status
4-
5-
- Python 2.6 : [![Build Status](https://jenkins1.ugent.be/job/vsc-base-python26/badge/icon)](https://jenkins1.ugent.be/job/vsc-base-python26/)
6-
- Python 2.7 : [![Build Status](https://jenkins1.ugent.be/job/vsc-base-python27/badge/icon)](https://jenkins1.ugent.be/job/vsc-base-python27/)
7-
83
# Description
94

105
Common tools used within our organization.
11-
Originally created by the HPC team of Ghent University (http://ugent.be/hpc).
12-
13-
# Documentation
14-
https://jenkins1.ugent.be/job/vsc-base-python26/Documentation/
6+
Originally created by the HPC team of Ghent University (https://ugent.be/hpc).
157

168
# Namespaces and tools
179

@@ -60,12 +52,9 @@ A collection of python scripts, these are examples of how you could use fancylog
6052
- __logdaemon.py__: A daemon that listens on a port for udp packets and logs them to file, works toghether with fancylogger.
6153
- __startlogdaemon.py__ : Script that will start the logdaemon for you and set environment variables for fancylogger.
6254

63-
# License
64-
vsc-base is made available under the GNU Library General Public License (LGPL) version 2 or any later version.
65-
6655
# Acknowledgements
67-
vsc-base was created with support of [Ghent University](http://www.ugent.be/en),
56+
vsc-base was created with support of [Ghent University](https://www.ugent.be/en),
6857
the [Flemish Supercomputer Centre (VSC)](https://vscentrum.be/nl/en),
69-
the [Flemish Research Foundation (FWO)](http://www.fwo.be/en),
70-
and [the Department of Economy, Science and Innovation (EWI)](http://www.ewi-vlaanderen.be/en).
58+
the [Flemish Research Foundation (FWO)](https://www.fwo.be/en),
59+
and [the Department of Economy, Science and Innovation (EWI)](https://www.ewi-vlaanderen.be/en).
7160

bin/logdaemon.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env python
22
#
3-
# Copyright 2011-2022 Ghent University
3+
# Copyright 2011-2023 Ghent University
44
#
55
# This file is part of vsc-base,
66
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
@@ -36,7 +36,6 @@
3636
3737
@author: Jens Timmerman (Ghent University)
3838
"""
39-
from __future__ import print_function
4039
from optparse import OptionParser
4140
from vsc.utils import fancylogger
4241
from vsc.utils.daemon import Daemon
@@ -79,9 +78,8 @@ def start(self):
7978
"""
8079
# Check for a pidfile to see if the daemon already runs
8180
try:
82-
pidf = open(self.pidfile, 'r')
83-
pid = int(pidf.read().strip())
84-
pidf.close()
81+
with open(self.pidfile, 'r') as pidf:
82+
pid = int(pidf.read().strip())
8583
except IOError:
8684
pid = None
8785

lib/vsc/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2015-2022 Ghent University
2+
# Copyright 2015-2023 Ghent University
33
#
44
# This file is part of vsc-base,
55
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),

lib/vsc/utils/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2015-2022 Ghent University
2+
# Copyright 2015-2023 Ghent University
33
#
44
# This file is part of vsc-base,
55
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),

lib/vsc/utils/affinity.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2012-2022 Ghent University
2+
# Copyright 2012-2023 Ghent University
33
#
44
# This file is part of vsc-base,
55
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),

lib/vsc/utils/asyncprocess.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@
7373
import subprocess
7474
import time
7575

76-
from vsc.utils.py2vs3 import is_py3
77-
78-
7976
PIPE = subprocess.PIPE
8077
STDOUT = subprocess.STDOUT
8178
MESSAGE = "Other end disconnected!"
@@ -190,17 +187,12 @@ def send_all(p, data):
190187
"""
191188
allsent = 0
192189

193-
# in Python 3, we must use a bytestring
194-
if is_py3():
195-
data = data.encode()
190+
data = data.encode()
196191

197192
while len(data):
198193
sent = p.send(data)
199194
if sent is None:
200195
raise Exception(MESSAGE)
201196
allsent += sent
202-
if is_py3():
203-
data = memoryview(data)[sent:]
204-
else:
205-
data = buffer(data, sent) # noqa (to avoid prospector failing on undefined 'buffer' in Python 3)
197+
data = memoryview(data)[sent:]
206198
return allsent

lib/vsc/utils/daemon.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,18 @@ def daemonize(self):
6363
# redirect standard file descriptors
6464
sys.stdout.flush()
6565
sys.stderr.flush()
66-
si = open(self.stdin, 'r')
67-
so = open(self.stdout, 'a+')
68-
se = open(self.stderr, 'ba+', 0)
69-
os.dup2(si.fileno(), sys.stdin.fileno())
70-
os.dup2(so.fileno(), sys.stdout.fileno())
71-
os.dup2(se.fileno(), sys.stderr.fileno())
66+
with open(self.stdin, 'r') as sti:
67+
os.dup2(sti.fileno(), sys.stdin.fileno())
68+
with open(self.stdout, 'a+') as sto:
69+
os.dup2(sto.fileno(), sys.stdout.fileno())
70+
with open(self.stderr, 'ba+', 0) as ste:
71+
os.dup2(ste.fileno(), sys.stderr.fileno())
7272

7373
# write pidfile
7474
atexit.register(self.delpid)
7575
pid = str(os.getpid())
76-
open(self.pidfile, 'w+').write("%s\n" % pid)
76+
with open(self.pidfile, 'w+') as pidf:
77+
pidf.write("%s\n" % pid)
7778

7879
def delpid(self):
7980
os.remove(self.pidfile)
@@ -84,9 +85,8 @@ def start(self):
8485
"""
8586
# Check for a pidfile to see if the daemon already runs
8687
try:
87-
pf = open(self.pidfile, 'r')
88-
pid = int(pf.read().strip())
89-
pf.close()
88+
with open(self.pidfile, 'r') as pidf:
89+
pid = int(pidf.read().strip())
9090
except IOError:
9191
pid = None
9292

@@ -105,9 +105,8 @@ def stop(self):
105105
"""
106106
# Get the pid from the pidfile
107107
try:
108-
pf = open(self.pidfile, 'r')
109-
pid = int(pf.read().strip())
110-
pf.close()
108+
with open(self.pidfile, 'r') as pidf:
109+
pid = int(pidf.read().strip())
111110
except IOError:
112111
pid = None
113112

lib/vsc/utils/dateandtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright 2012-2022 Ghent University
2+
# Copyright 2012-2023 Ghent University
33
#
44
# This file is part of vsc-base,
55
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),

0 commit comments

Comments
 (0)