mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Python3 Module Dependency Check (#11544)
* Python3 Modul Dependency Check * code climate * binary existance check * move Python Modul Version Check * . * adding verbose argument * args parser nicement * enhance Validator for detailed approvements * Update Python.php * Update check_requirements.py * python version to Version class use Process Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
@@ -1,17 +1,27 @@
|
||||
#! /usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
import pkg_resources
|
||||
from pkg_resources import DistributionNotFound, VersionConflict
|
||||
|
||||
args = sys.argv
|
||||
|
||||
# verbose flag
|
||||
verbose = '-v' in args
|
||||
|
||||
target = os.path.realpath(os.path.dirname(__file__) + '/../requirements.txt')
|
||||
|
||||
with open(target, 'r') as file:
|
||||
requirements = file.read().rstrip().split("\n")
|
||||
try:
|
||||
pkg_resources.require(requirements)
|
||||
except DistributionNotFound:
|
||||
except DistributionNotFound as req:
|
||||
if verbose:
|
||||
print(req)
|
||||
exit(1)
|
||||
except VersionConflict:
|
||||
except VersionConflict as req:
|
||||
if verbose:
|
||||
print(req)
|
||||
exit(2)
|
||||
exit(0)
|
||||
|
||||
|
Reference in New Issue
Block a user