From 3e4640f52c24d74179bdacd53fda0b81ecd03146 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=A1clav=20Barto=C5=A1?= <bartos@cesnet.cz> Date: Thu, 16 Sep 2021 10:24:37 +0200 Subject: [PATCH] warden_filer: compatibility with Python3 --- warden_filer/warden_filer.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/warden_filer/warden_filer.py b/warden_filer/warden_filer.py index 9ed1fbc..37e42b0 100755 --- a/warden_filer/warden_filer.py +++ b/warden_filer/warden_filer.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 # -*- coding: utf-8 -*- # # Copyright (C) 2011-2015 Cesnet z.s.p.o @@ -18,7 +18,13 @@ import resource import atexit import argparse from os import path, mkdir -from random import choice, randint; +from random import choice, randint + +# for py2/py3 compatibility +try: + basestring +except NameError: + basestring = str VERSION = "3.0-beta2" @@ -392,7 +398,7 @@ def daemonize( # PID file if pidfile is not None: pidd = os.open(pidfile, os.O_RDWR|os.O_CREAT|os.O_EXCL|os.O_TRUNC) - os.write(pidd, str(os.getpid())+"\n") + os.write(pidd, (str(os.getpid())+"\n").encode()) os.close(pidd) # Define and setup atexit closure @atexit.register -- GitLab