From 7e2900ad784df2055115e53fa999f34df1e3e0f8 Mon Sep 17 00:00:00 2001 From: Thomas Williams Date: Mon, 8 Jul 2024 14:59:35 +0100 Subject: [PATCH] Handles cases where pip may not be wanted --- README.md | 2 +- config.py.sample | 1 + main.py | 7 +++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f7cc9e2..e01b075 100644 --- a/README.md +++ b/README.md @@ -38,4 +38,4 @@ See the available configuration options, which should be specified in config.py. - **hostMonitorEndTime** - the end time which the host monitor should shut down. This does not stop the script itself and this monitor will restart at the start time. - **urlMonitorStartTime** - the start time which the url monitor should start at the earliest. - **urlMonitorEndTime** - the end time which the url monitor would shut down. This does not stop the script itself and this monitor will restart at the start time. - +- **usePip** - whether or not to use pip to install dependencies. Set to false if your environment is externally managed diff --git a/config.py.sample b/config.py.sample index 312f5a7..b1455d4 100644 --- a/config.py.sample +++ b/config.py.sample @@ -25,3 +25,4 @@ hostMonitorStartTime = "00:00:00" hostMonitorEndTime = "23:59:59" urlMonitorStartTime = "00:00:00" urlMonitorEndTime = "23:59:59" +usePip = True diff --git a/main.py b/main.py index 75a8208..13e44fb 100755 --- a/main.py +++ b/main.py @@ -34,6 +34,9 @@ def get_pip_command(): def install_dependencies(): + if not config.usePip: + return + pip_command = get_pip_command() with open('requirements.txt', 'r') as req_file: @@ -250,12 +253,12 @@ if __name__ == "__main__": import sys import subprocess + import config install_dependencies() - import config - import psutil import os + import psutil import time import log import requests