Resolves issue #31

This commit is contained in:
Thomas Williams 2024-07-08 14:34:13 +01:00
parent d1d1a39a30
commit f2249c4f6c
Signed by: thomas
GPG key ID: EB8F975CF60BCBFF

24
main.py
View file

@ -35,7 +35,29 @@ def get_pip_command():
def install_dependencies():
pip_command = get_pip_command()
subprocess.check_call([pip_command, 'install', '-r', 'requirements.txt', '--user'])
with open('requirements.txt', 'r') as req_file:
requirements = req_file.read().splitlines()
try:
with open('installedrequirements.txt', 'r') as installed_file:
installed_requirements = installed_file.read().splitlines()
except FileNotFoundError:
installed_requirements = []
dependencies_to_install = [req for req in requirements if req not in installed_requirements]
if dependencies_to_install:
subprocess.check_call([pip_command, 'install'] + dependencies_to_install + ['--user'])
with open('installedrequirements.txt', 'a') as installed_file:
for dependency in dependencies_to_install:
installed_file.write(dependency + '\n')
def signal_handler(sig, frame):
print('SIGINT/SIGTERM aknowledged. Stopping script gracefully, please wait...')