Docker Detection

This commit is contained in:
Alex Orid 2021-04-15 17:03:55 -04:00
parent 46de27aca8
commit cfd0b84872
4 changed files with 19 additions and 5 deletions

View File

@ -7,4 +7,4 @@ RUN pip3 install -r requirements.txt
COPY . .
#CMD [ "python3", "main.py"] #Uncomment to start with the Docker Container
CMD [ "python3", "main.py"] #Uncomment to start with the Docker Container

11
main.py
View File

@ -100,16 +100,19 @@ def thread_main():
thread_.start()
if config.user_module == True:
thread_ = threading.Thread(target=user_module_init, args=(dbCert, None))
threads.append(thread_)
thread_.start()
if utility.isRunningInDocker() == False:
config.user_module = False
thread_ = threading.Thread(target=user_module_init, args=(dbCert, None))
threads.append(thread_)
thread_.start()
print("---Post Thread Creation Test---")
for t in threads:
t.join()
print("---Point of no return---")
input()
if utility.isRunningInDocker() == False:
input()

View File

@ -9,6 +9,8 @@ from commands.command_base import AbstractCommand
from cooldowns import Cooldown_Module
import utilities_script as utility
class User_Module():
def __init__(self):
super().__init__()
@ -19,6 +21,9 @@ class User_Module():
def main(self):
print("\nWaiting on User input...\n")
inputLoop = True
if utility.isRunningInDocker() == False:
inputLoop = False
print("\nNo User's Input Allowed")
while inputLoop:
keyboardInput = input()
message = UserMessage()

View File

@ -65,6 +65,12 @@ def contains_slur(input: str):
print("<{ slur detected! }> ")
return containsSlur
def isRunningInDocker():
isD = os.getenv('ISDOCKER')
if isD is None:
return False
return isD == "cat"
def hard_shutdown():
current_system_pid = os.getpid()