Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add run python3 #520

Closed
wants to merge 4 commits into from
Closed

Conversation

khromenokroman
Copy link

This commit includes a new function cli_start_python3 which executes Python3 scripts from within the CLI. The function operates as a new command in the CLI interface, accepting a path to the script as an argument. This enhancement improves the versatility of the Clixon CLI interface by allowing direct execution of Python scripts.

Хроменок Роман Владимирович added 2 commits May 22, 2024 08:03
This commit includes a new function `cli_start_python3` which executes Python3 scripts from within the CLI. The function operates as a new command in the CLI interface, accepting a path to the script as an argument. This enhancement improves the versatility of the Clixon CLI interface by allowing direct execution of Python scripts.
This commit includes a new function `cli_start_python3` which executes Python3 scripts from within the CLI. The function operates as a new command in the CLI interface, accepting a path to the script as an argument. This enhancement improves the versatility of the Clixon CLI interface by allowing direct execution of Python scripts.
@krihal
Copy link
Collaborator

krihal commented May 22, 2024

What are the advantage over adding a shebang for Python3 in the script and then use something like this in the CLI specification?

shell("System command"), cli_start_shell("bash");{
  <source:rest>("Single shell command"), cli_start_shell("bash");
}

Any Python script can then be called as long as #!/bin/env python3 or similar are added to the top of the file and the file is executable and "shell" can of course be renamed.

debian@khn-dev /> shell /tmp/test.py
foo

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a generated file and should most probably not be here (unless you changed configure.ac)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this is a mistake, I'm sorry

@olofhagsand
Copy link
Member

It would be nice to add a documentation section somewhere here: https://clixon-docs.readthedocs.io/en/latest/cli.html on how to use scripts (specifically python) as callbacks.

@khromenokroman
Copy link
Author

What are the advantage over adding a shebang for Python3 in the script and then use something like this in the CLI specification?

shell("System command"), cli_start_shell("bash");{
  <source:rest>("Single shell command"), cli_start_shell("bash");
}

Any Python script can then be called as long as #!/bin/env python3 or similar are added to the top of the file and the file is executable and "shell" can of course be renamed.

debian@khn-dev /> shell /tmp/test.py
foo

That's right, you can do this. But then it will be like this
Снимок экрана от 2024-05-22 13-16-10

And with my version it will be like this
Снимок экрана от 2024-05-22 13-18-23

I think it's better this way. But I could be wrong :)

@khromenokroman
Copy link
Author

It would be nice to add a documentation section somewhere here: https://clixon-docs.readthedocs.io/en/latest/cli.html on how to use scripts (specifically python) as callbacks.

I'll try to do it now

@olofhagsand
Copy link
Member

It would be nice to add a documentation section somewhere here: https://clixon-docs.readthedocs.io/en/latest/cli.html on how to use scripts (specifically python) as callbacks.

I'll try to do it now

You need to checkout the old version of configure for tests to parse

@olofhagsand
Copy link
Member

I think it's better this way. But I could be wrong :)
Yes, but
can you do it more generalized, so that it is not hardcoded to /usr/bin/python3? I can see it being useful for other scripts (or even if python is installed elsewhere.u
This is the advantage of the existing cli_start_shell.

@olofhagsand
Copy link
Member

I see you close this PR. I think it is important to improve the scripting interface, and also its documentation, and I think your comments made sense. Are you planning to make a new PR?

@khromenokroman
Copy link
Author

I see you close this PR. I think it is important to improve the scripting interface, and also its documentation, and I think your comments made sense. Are you planning to make a new PR?

yes, I will correct the comments, they were correct, and make a new pool request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants