Open GUI for running script - python

I have Python script running as service(24/7). This script is executed by LaunchDaemon on start. I would like to implement GUI for this script so I could check progress. How can I recognize my script is running and just open thread with GUI when I start that script again?
Thank You

You could look at Tkinter to run at start up? Using a simple if running display "running" else display "error"

Related

How to troubleshoot why the python script hangs in linux screen

I create a screen in linux and run a python script in that screen.
After running 1 month 24/7, when I check the progress of the python script, the script stops running without being killed or terminated the script. May I know how to troubleshoot why the script stop running in the linux's screen?
Thanks inadvance.

How would I code something in python to automatically close an app upon opening?

I've been coding python for some time now, and I'd like to code a program that would automatically close an app when it opens. For example, I would like a to code something that would automatically close steam or something similar when it opens. How would I do this? I've looked over the internet and can't find my answer. Is this even something to do in python?
You could let python run in the background and check every couple of seconds if a process exists. A list of running processes shows you the name of the program that you want to close. You cannot use a PID because it changes every time you restart the program. See this thread to close a process. If you're running Linux, you can easily run python in the background like this: python main.py &
Or you can create a Linux service to run python: https://medium.com/codex/setup-a-python-script-as-a-service-through-systemctl-systemd-f0cc55a42267

How can I stop and restart python script from another python script?

Is there any way to stop and rerun python script from another python script?
My idea is like this
I have two python script [scanner.py ,vpnchange.py]
Scanner.py I want this scanner to run about 500 request then pause and stop and restart vpnchange.py then continue and so on.

Console window closes abruptly while using windows task schedular to run Python script

I have written some Python code to automate a task. Then I scheduled the Python script to execute twice a week using windows task scheduler. The task runs but there are two issues.
The console prints some error. It is strange because when I run the script manually after opening command prompt everything works as expected. This is what I do manually.
cd directory
directory>script.py
Inside the task scheduler I have directly specified the location of the script to run as C:\full\path\to\script.py
Second issue is that I can't even diagnose the error because the console closes as soon as it executes the script. This is despite the fact that I have added a dummy input command at the end of script like this:
All my Python code
input('Press any key to exit')
I also tried to keep the console open by using time.sleep(60) after importing the time module.
Can anyone tell me how can I keep the console open. Let me repeat that I am running the script using windows task scheduler. Running the script manually generates no error.
Thanks.

How do I run a python script using an already running blender?

Normally, I would use "blender -P script.py" to run a python script. In this case, a new blender process is started to execute the script. What I am trying to do now is to run a script using a blender process that is already running, instead of starting a new one.
I have not seen any source on this issue so far, which makes me concern about the actual feasibility of this approach.
Any help would be appreciated.
Blender isn't designed to be started from the cli and to then keep receiving more commands from the cli as it is running. It does however include a text editor that can open text files and run the text block as a python script, it also includes a python console that can be used to interactively type in commands while blender is running. You may also find this addon useful as it lets you to run a text block in the python console, this leaves you with an interactive session that contains the variables as they exist at the end of the scripts execution.
There is a cli option to run blender as a python console blender --python-console - the gui does not get updated while this console is running, so you could open and exec several scripts and then when you exit the console, blender will update it's gui and allow interactive use, or if you start in background mode -b then it will quit when you exit the console.
My solution was to launch Blender via console with a python script (blender --python script.py) that contains a while loop and creates a server socket to receive requests to process some specific code. The loop will prevent blender from opening the GUI, and the socket will handle the multiple requests inside the same blender process.

Categories