From cfd0b84872f0e0cd580d67956ad02cf85bce05d2 Mon Sep 17 00:00:00 2001 From: Alex Orid Date: Thu, 15 Apr 2021 17:03:55 -0400 Subject: [PATCH] Docker Detection --- Dockerfile | 2 +- main.py | 11 +++++++---- user_module.py | 5 +++++ utilities_script.py | 6 ++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 08421bf..3f7084b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,4 +7,4 @@ RUN pip3 install -r requirements.txt COPY . . -#CMD [ "python3", "main.py"] #Uncomment to start with the Docker Container \ No newline at end of file +CMD [ "python3", "main.py"] #Uncomment to start with the Docker Container \ No newline at end of file diff --git a/main.py b/main.py index f9a47c4..e22f2e3 100644 --- a/main.py +++ b/main.py @@ -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() diff --git a/user_module.py b/user_module.py index 7891130..3e7becc 100644 --- a/user_module.py +++ b/user_module.py @@ -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() diff --git a/utilities_script.py b/utilities_script.py index fa77b76..6bcf362 100644 --- a/utilities_script.py +++ b/utilities_script.py @@ -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()