Merge pull request #2 from F-WuTS/feature/locking

Add Locking
This commit is contained in:
itssme 2022-02-13 18:51:38 +01:00 committed by GitHub
commit 6687d1afba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 49 additions and 10 deletions

View file

@ -1,9 +1,10 @@
__version__ = "0.4.0-0"
import sys
import importlib
import compLib.LogstashLogging
import compLib.MetricsLogging
from compLib.Lock import Lock
apt_found = importlib.util.find_spec("apt") is not None
spi_found = importlib.util.find_spec("spidev") is not None
@ -25,6 +26,12 @@ if apt_found:
else:
print("apt is not installed! This is for local development only!")
if Lock.is_locked():
print("Another program using compLib is still running! Delete /root/complib.lock if this is an error. Exiting...")
sys.exit()
else:
Lock.lock()
if spi_found:
from compLib.Spi import Spi
from compLib.Reset import Reset