Interactive shell detection method
Summary
The interactive shell detection of crafty-controller might want a slight improvement when it comes to systemd services running on Linux machines, as stdout is spammed with Jul 12 13:30:41 archinstall python[630]: Crafty Controller v4.4.11 > *** Unknown syntax: EOF, hence CPU is constantly at 100%.
Area of the system
Within the core of the application
How does this currently work?
In main.py line 25 to 35, this detection is used:
if getattr(sys, "frozen", False):
APPLICATION_PATH = os.path.dirname(sys.executable)
RUNNING_MODE = "Frozen/executable"
else:
try:
app_full_path = os.path.realpath(__file__)
APPLICATION_PATH = os.path.dirname(app_full_path)
RUNNING_MODE = "Non-interactive (e.g. 'python main.py')"
except NameError:
APPLICATION_PATH = os.getcwd()
RUNNING_MODE = "Interactive"
What is the desired way of working?
Uncertain what happens. Note that a workdirectory was specified in the service as well. In the service the following execution line is used:ExecStart=/opt/crafty-controller/venv/bin/python /opt/crafty-controller/main.py. Hence a better implementation may be used for picking between interactive and non-interactive. Do note that this doesn't deal with the paths, hence this isn't more than a draft (hence no MR).
if sys.stdin.isatty():
RUNNING_MODE = "Interactive"
else:
RUNNING_MODE = "Non-interactive"
Priority/Severity
-
High (This will bring a huge increase in performance/productivity/usability) -
Medium (This will bring a good increase in performance/productivity/usability) -
Low (anything else e.g., trivial, minor improvements)