diff options
author | Tobias C. Berner <tcberner@FreeBSD.org> | 2020-07-15 15:47:41 +0000 |
---|---|---|
committer | Tobias C. Berner <tcberner@FreeBSD.org> | 2020-07-15 15:47:41 +0000 |
commit | 16b47526e80251f9968002d82fbe5daf9139a944 (patch) | |
tree | 5e63e8a8ce7f2b890db2012359b49b9ea4ddd8b1 /news | |
parent | b8405741ebe5f1a4d8853a720f956a956f99c539 (diff) | |
download | freebsd-ports-16b47526e80251f9968002d82fbe5daf9139a944.zip |
news/nzbhydra2: Update to to 2.25.0
Changelog can be viewed at:
https://github.com/theotherp/nzbhydra2/blob/master/changelog.md
nzbhydra2wrapper.py has been replaced with the updated nzbhydra2wrapperPy3.py script
supporting Python 3.5 or higher and removing Python 2 support.
Submitted by: Daniel Shafer <daniel@shafer.cc> (maintainer)
Differential Revision: https://reviews.freebsd.org/D25674
Diffstat (limited to 'news')
-rw-r--r-- | news/nzbhydra2/Makefile | 15 | ||||
-rw-r--r-- | news/nzbhydra2/distinfo | 6 | ||||
-rw-r--r-- | news/nzbhydra2/files/nzbhydra2.in | 2 | ||||
-rw-r--r-- | news/nzbhydra2/files/nzbhydra2wrapperPy3.py.in (renamed from news/nzbhydra2/files/nzbhydra2wrapper.py.in) | 82 |
4 files changed, 54 insertions, 51 deletions
diff --git a/news/nzbhydra2/Makefile b/news/nzbhydra2/Makefile index e7828f18cf14..ba051a8502f5 100644 --- a/news/nzbhydra2/Makefile +++ b/news/nzbhydra2/Makefile @@ -1,7 +1,7 @@ # $FreeBSD$ PORTNAME= nzbhydra2 -DISTVERSION= 2.7.2 +DISTVERSION= 2.25.0 DISTVERSIONSUFFIX= -linux CATEGORIES= news java MASTER_SITES= https://github.com/theotherp/${PORTNAME}/releases/download/v${DISTVERSION}/ @@ -12,19 +12,16 @@ COMMENT= Usenet meta search LICENSE= APACHE20 LICENSE_FILE= ${WRKSRC}/LICENSE -DEPRECATED= Uses deprecated version of python -EXPIRATION_DATE= 2020-09-15 - ONLY_FOR_ARCHS= amd64 -USES= python:2.7 shebangfix zip +USES= python:3.5+ shebangfix zip USE_JAVA= yes USE_RC_SUBR= nzbhydra2 NO_BUILD= yes NO_WRKSUBDIR= yes -SUB_FILES= nzbhydra2 nzbhydra2wrapper.py +SUB_FILES= nzbhydra2 nzbhydra2wrapperPy3.py SUB_LIST= PYTHON_CMD=${PYTHON_CMD} \ JAVA=${JAVA} @@ -37,19 +34,19 @@ GROUPS= nzbhydra2 PLIST_FILES= ${DATADIR}/lib/core-${DISTVERSION}-exec.jar \ ${DATADIR}/nzbhydra2 \ - ${DATADIR}/nzbhydra2wrapper.py \ + ${DATADIR}/nzbhydra2wrapperPy3.py \ ${DATADIR}/changelog.md \ ${DATADIR}/readme.md \ ${DATADIR}/LICENSE post-extract: # Cleanup unnecessary files - @${RM} -r ${WRKSRC}/systemd ${WRKSRC}/sysv ${WRKSRC}/rc.d ${WRKSRC}/upstart + @${RM} -r ${WRKSRC}/systemd ${WRKSRC}/sysv ${WRKSRC}/rc.d ${WRKSRC}/upstart ${WRKSRC}/nzbhydra2wrapper.py do-install: @${MKDIR} ${STAGEDIR}/${DATADIR} ${INSTALL} -d -m 755 ${STAGEDIR}/${DATADIR} cd ${WRKSRC} && ${COPYTREE_SHARE} \* ${STAGEDIR}/${DATADIR} - ${INSTALL_DATA} ${WRKDIR}/nzbhydra2wrapper.py ${STAGEDIR}/${DATADIR} + ${INSTALL_DATA} ${WRKDIR}/nzbhydra2wrapperPy3.py ${STAGEDIR}/${DATADIR} .include <bsd.port.mk> diff --git a/news/nzbhydra2/distinfo b/news/nzbhydra2/distinfo index 22e1fb7a0170..7f8d747fdabd 100644 --- a/news/nzbhydra2/distinfo +++ b/news/nzbhydra2/distinfo @@ -1,3 +1,3 @@ -TIMESTAMP = 1570424554 -SHA256 (nzbhydra2-2.7.2-linux.zip) = 863823651eb2b949ec12476e62d34d8d600563bc651b13f52bea9d783b80f3d9 -SIZE (nzbhydra2-2.7.2-linux.zip) = 71191941 +TIMESTAMP = 1594771837 +SHA256 (nzbhydra2-2.25.0-linux.zip) = d4e8c6e28d3b53c2a49381aa3a939930b92a9ba2b06be68d19c41e1e177cfa55 +SIZE (nzbhydra2-2.25.0-linux.zip) = 64983862 diff --git a/news/nzbhydra2/files/nzbhydra2.in b/news/nzbhydra2/files/nzbhydra2.in index cf60b53eef29..5c7c66041b1f 100644 --- a/news/nzbhydra2/files/nzbhydra2.in +++ b/news/nzbhydra2/files/nzbhydra2.in @@ -39,7 +39,7 @@ load_rc_config ${name} pidfile="/var/run/nzbhydra2/nzbhydra2.pid" command="%%PYTHON_CMD%%" -command_args="${nzbhydra2_dir}/nzbhydra2wrapper.py --datafolder ${nzbhydra2_data_dir} --pidfile ${pidfile} --daemon --nobrowser --java %%JAVA%%" +command_args="${nzbhydra2_dir}/nzbhydra2wrapperPy3.py --datafolder ${nzbhydra2_data_dir} --pidfile ${pidfile} --daemon --nobrowser --java %%JAVA%%" start_precmd=nzbhydra2_precmd nzbhydra2_precmd() diff --git a/news/nzbhydra2/files/nzbhydra2wrapper.py.in b/news/nzbhydra2/files/nzbhydra2wrapperPy3.py.in index d4d6e83da834..4d0606586b61 100644 --- a/news/nzbhydra2/files/nzbhydra2wrapper.py.in +++ b/news/nzbhydra2/files/nzbhydra2wrapperPy3.py.in @@ -1,12 +1,12 @@ #!%%PYTHON_CMD%% -from __future__ import print_function + import sys CURRENT_PYTHON = sys.version_info[:2] -REQUIRED_PYTHON = (2, 7) +REQUIRED_PYTHON = (3, 5) -# This check and everything above must remain compatible with Python 2.7 and above. -if CURRENT_PYTHON > REQUIRED_PYTHON: +# This check and everything above must remain compatible with Python and above. +if CURRENT_PYTHON < REQUIRED_PYTHON: sys.stderr.write("This script requires Python {}.{}, but you're trying to run it on Python {}.{}.".format(*(REQUIRED_PYTHON + CURRENT_PYTHON))) sys.exit(1) @@ -19,7 +19,6 @@ import re import shutil import subprocess import zipfile -from __builtin__ import file from logging.handlers import RotatingFileHandler jarFile = None @@ -28,7 +27,7 @@ args = [] unknownArgs = [] terminatedByWrapper = False -LOGGER_DEFAULT_FORMAT = u'%(asctime)s %(levelname)s - %(message)s' +LOGGER_DEFAULT_FORMAT = '%(asctime)s %(levelname)s - %(message)s' LOGGER_DEFAULT_LEVEL = 'INFO' logger = logging.getLogger('root') console_logger = logging.StreamHandler(sys.stdout) @@ -39,11 +38,12 @@ file_logger = None logger.setLevel(LOGGER_DEFAULT_LEVEL) consoleLines = [] + def getBasePath(): global basepath if basepath is not None: return basepath - if "HYDRAWORKINGFOLDER" in os.environ.keys(): + if "HYDRAWORKINGFOLDER" in list(os.environ.keys()): return os.environ["HYDRAWORKINGFOLDER"] import sys if sys.executable: @@ -110,9 +110,9 @@ def daemonize(pidfile, nopidfile): if not nopidfile: pid = str(os.getpid()) try: - file(pidfile, 'w').write("%s\n" % pid) + open(pidfile, 'w').write("%s\n" % pid) except IOError as e: - sys.stderr.write(u"Unable to write PID file: " + pidfile + ". Error: " + str(e.strerror) + " [" + str(e.errno) + "]") + sys.stderr.write("Unable to write PID file: " + pidfile + ". Error: " + str(e.strerror) + " [" + str(e.errno) + "]") sys.exit(1) else: print("no pid file") @@ -122,9 +122,9 @@ def daemonize(pidfile, nopidfile): sys.stderr.flush() devnull = getattr(os, 'devnull', '/dev/null') - stdin = file(devnull, 'r') - stdout = file(devnull, 'a+') - stderr = file(devnull, 'a+') + stdin = open(devnull, 'r') + stdout = open(devnull, 'a+') + stderr = open(devnull, 'a+') os.dup2(stdin.fileno(), sys.stdin.fileno()) os.dup2(stdout.fileno(), sys.stdout.fileno()) os.dup2(stderr.fileno(), sys.stderr.fileno()) @@ -216,8 +216,8 @@ def restore(): oldDatabaseFile = os.path.join(dataFolder, "database", "nzbhydra.mv.db") logger.info("Deleting old database file " + oldDatabaseFile) os.remove(oldDatabaseFile) - except Exception as e: - logger.critical("Error while deleting old data folder: %r", e) + except Exception as ex: + logger.critical("Error while deleting old data folder: %r", ex) sys.exit(-1) for f in os.listdir(restoreFolder): source = os.path.join(restoreFolder, f) @@ -343,22 +343,25 @@ def startup(): arguments.append("--baseurl") arguments.append(args.baseurl) yamlPath = os.path.join(args.datafolder, "nzbhydra.yml") + + xmx = None + logGc = False if args.xmx: xmx = args.xmx - elif os.path.exists(yamlPath): - with open(yamlPath, "r") as f: + if os.path.exists(yamlPath): + with open(yamlPath, "rb") as f: for line in f.readlines(): + line = line.decode("UTF-8") index = line.find("xmx:") if index > -1: xmx = line[index + 5:].rstrip("\n\r ") - break - else: - logger.warn("Didn't find XMX in YAML file, using default of 256") - xmx = 256 - else: - logger.info("No file nzbhydra.yml found. Using 256M XMX") + index = line.find("logGc: ") + if index > -1: + logGc = line[index + 7:].rstrip("\n\r ") == "true" + if xmx is None: xmx = 256 xmx = str(xmx) + if xmx.lower().endswith("m"): logger.info("Removing superfluous M from XMX value " + xmx) xmx = xmx[:-1] @@ -390,7 +393,8 @@ def startup(): "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=" + os.path.join(args.datafolder, "logs") ] - java_arguments.extend(gcArguments) + if logGc: + java_arguments.extend(gcArguments) if args.debugport: java_arguments.append("-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:" + args.debugport) if not args.nocolors and not isWindows: @@ -418,15 +422,16 @@ def startup(): while True: # Handle error first in case startup of main process returned only an error (on stderror) nextline = process.stdout.readline() - if nextline == '' and process.poll() is not None: + nextlineString = process.stdout.readline().decode("utf-8") + if nextlineString == '' and process.poll() is not None: break - if nextline != "": - consoleLines.append(nextline) + if nextlineString != "": + consoleLines.append(nextlineString) if len(consoleLines) > 100: consoleLines = consoleLines[-100:] if not args.quiet: - sys.stdout.write(nextline) + sys.stdout.write(nextlineString) sys.stdout.flush() process.wait() @@ -443,7 +448,7 @@ def escape_parameter(is_windows, parameter): def list_files(startpath): for root, dirs, files in os.walk(startpath): level = root.replace(startpath, '').count(os.sep) - indent = ' ' * 4 * (level) + indent = ' ' * 4 * level logger.info('{}{}/'.format(indent, os.path.basename(root))) subindent = ' ' * 4 * (level + 1) for f in files: @@ -476,17 +481,19 @@ def getJavaVersion(javaExecutable): # shell=true: pass string, shell=false: pass arguments try: lines = [] - process = subprocess.Popen([javaExecutable, "-version"], shell=False, bufsize=-1, **subprocess_args()) + javaProcess = subprocess.Popen([javaExecutable, "-version"], shell=False, bufsize=-1, **subprocess_args()) # atexit.register(killProcess) while True: # Handle error first in case startup of main process returned only an error (on stderror) - nextline = process.stdout.readline() - if nextline == '' and process.poll() is not None: + nextline = javaProcess.stdout.readline().decode("ascii") + if nextline == '' and javaProcess.poll() is not None: break - if nextline != "": + if nextline != "" and nextline != b'': lines.append(nextline) - process.wait() + else: + break + javaProcess.wait() if len(lines) == 0: raise Exception("Unable to get output from call to java -version") versionLine = lines[0].replace("\n", "").replace("\r", "") @@ -496,7 +503,7 @@ def getJavaVersion(javaExecutable): javaMajor = int(match.group("major")) javaMinor = int(match.group("minor")) if match.group("minor") is not None else 0 javaVersion = 0 - if (javaMajor == 1 and javaMinor < 8) or (javaMajor > 1 and javaMajor < 8): + if (javaMajor == 1 and javaMinor < 8) or (1 < javaMajor < 8): logger.error("Found incompatible java version '" + versionLine + "'") sys.exit(-1) if javaMajor == 1 and javaMinor == 8: @@ -505,8 +512,8 @@ def getJavaVersion(javaExecutable): javaVersion = javaMajor logger.info("Determined java version as '%d' from version string '%s'", javaVersion, versionLine) return javaVersion - except Exception as e: - logger.error("Unable to determine java version; make sure Java is installed and callable. Error message: " + str(e)) + except Exception as ex: + logger.error("Unable to determine java version; make sure Java is installed and callable. Error message: " + str(ex)) sys.exit(-1) @@ -597,7 +604,7 @@ if __name__ == '__main__': except Exception as e: controlCode = process.returncode if not (args.version or args.repairdb): - logger.warn("Unable to read control ID from %s: %s. Falling back to process return code %d", controlIdFilePath, e, controlCode) + logger.warning("Unable to read control ID from %s: %s. Falling back to process return code %d", controlIdFilePath, e, controlCode) if os.path.exists(controlIdFilePath): try: logger.debug("Deleting old control ID file %s", controlIdFilePath) @@ -616,7 +623,6 @@ if __name__ == '__main__': logger.info("NZBHydra main process has terminated for restoration") doStart = restore() logger.info("Restoration successful") - doStart = True elif args.version or args.repairdb: # Just quit without further ado, help was printed by main process doStart = False |