lossless1024 / StreaMonitor

Adult live stream downloader for advanced people. I could have chosen a better name.
GNU General Public License v3.0
198 stars 52 forks source link

Quit command not recognized in Controller.py #29

Closed eldepor closed 1 year ago

eldepor commented 1 year ago

Not working for me. I think its not added to controller.py and manager.py

eldepor commented 1 year ago

Not working in the console either. Notice how start/stop/add/remove/status commands are added in manager.py but not "quit" command.

DerBunteBall commented 1 year ago

Did you pull the git repo again? And restarted the app cleanly?

Also keep in mind that signaling on Windows is very differnt. I think it's not to expect that the code will work on Windows cleanly or as expected.

See Note for Popen.send_signal:

Note

On Windows, SIGTERM is an alias for [terminate()](https://docs.python.org/3/library/subprocess.html#subprocess.Popen.terminate). CTRL_C_EVENT and CTRL_BREAK_EVENT can be sent to processes started with a creationflags parameter which includes CREATE_NEW_PROCESS_GROUP.

Also notes for os.kill:

Windows: The [signal.CTRL_C_EVENT](https://docs.python.org/3/library/signal.html#signal.CTRL_C_EVENT) and [signal.CTRL_BREAK_EVENT](https://docs.python.org/3/library/signal.html#signal.CTRL_BREAK_EVENT) signals are special signals which can only be sent to console processes which share a common console window, e.g., some subprocesses. Any other value for sig will cause the process to be unconditionally killed by the TerminateProcess API, and the exit code will be set to sig. The Windows version of [kill()](https://docs.python.org/3/library/os.html#os.kill) additionally takes process handles to be killed.

See also [signal.pthread_kill()](https://docs.python.org/3/library/signal.html#signal.pthread_kill)

I read more about that because of the ffmpeg stopping issue. I think to handle proccess cleanly on Windows the code need to be made Windows able. Eventually subprocess in combination with win32process package or so. Process handling is definitly really different on Linux/Unix. It seems it's one of the things which need to be done platform specific in Python.

Best Regards

eldepor commented 1 year ago

It's implemented in the managers/climanager.py

I see, but then I don't know why but it says unknown command

eldepor commented 1 year ago

OK nvm, it works now I don't know why lol

But Controller.py still not recognizing "quit"

eldepor commented 1 year ago

Edit: Controller.py still not recognizing "quit" command

eldepor commented 1 year ago

Yes and it is by design. But if you really need it, I can make it work

I would appreciate it yes, because I use all commands through Controller.py

DerBunteBall commented 1 year ago

As told it's wanted in that way just the CLIManager has this. To give Controller the ability it would lead to the possibility to shutdown the Downloader from everywhere when network access is given. It's enough to have it in Downloader. Controller is just a remote CLI tool. It should not be able to shutdown the server as long there is no authentication and authorization.

eldepor commented 1 year ago

Oh ok right, I understand. I use to use controller.py because the console (Downloader.py) is constantly scrolling while monitoring streamers and I can't see what I'm typing (that's why maybe I was misstyping "quit" and didn't noticed it)

eldepor commented 1 year ago

Did you pull the git repo again? And restarted the app cleanly?

Also keep in mind that signaling on Windows is very differnt. I think it's not to expect that the code will work on Windows cleanly or as expected.

See Note for Popen.send_signal:

Note

On Windows, SIGTERM is an alias for [terminate()](https://docs.python.org/3/library/subprocess.html#subprocess.Popen.terminate). CTRL_C_EVENT and CTRL_BREAK_EVENT can be sent to processes started with a creationflags parameter which includes CREATE_NEW_PROCESS_GROUP.

Also notes for os.kill:

Windows: The [signal.CTRL_C_EVENT](https://docs.python.org/3/library/signal.html#signal.CTRL_C_EVENT) and [signal.CTRL_BREAK_EVENT](https://docs.python.org/3/library/signal.html#signal.CTRL_BREAK_EVENT) signals are special signals which can only be sent to console processes which share a common console window, e.g., some subprocesses. Any other value for sig will cause the process to be unconditionally killed by the TerminateProcess API, and the exit code will be set to sig. The Windows version of [kill()](https://docs.python.org/3/library/os.html#os.kill) additionally takes process handles to be killed.

See also [signal.pthread_kill()](https://docs.python.org/3/library/signal.html#signal.pthread_kill)

I read more about that because of the ffmpeg stopping issue. I think to handle proccess cleanly on Windows the code need to be made Windows able. Eventually subprocess in combination with win32process package or so. Process handling is definitly really different on Linux/Unix. It seems it's one of the things which need to be done platform specific in Python.

Best Regards

I'm really no expert but I think I understand you. Hope the stopping issue gets fixed with the "two step" you proposed.

DerBunteBall commented 1 year ago

Do you use PowerShell or just cmd?

For Windows I would recommand using PowerShell for some reasons. It's still a terminal emulator which behaves a bit wild but much better then cmd.

The CLI is a bit missleading. At the inital start you get no > which gives you the signal I take commands. I know that the Logging is annoying. So Controller is more comfortable.

But to quit it should be always possible to type quit into the PowerShell/cmd Downloader runs at.

Also on Unix/Linux quit in Downloader gives no feedback. You should get back to your PowerShell/CMD prompt.