Replies: 1 comment
-
Yes, it is possible, but I doubt that this will be implemented because of security concerns (you are effectively executing untrusted code from the Part-DB perspective). That said, you just need to append <br /><a class="btn btn-danger mt-2" href="{{ path('part_custom_script', {'id': part.id}) }}">Execute custom script</a> to #[Route(path: '/{id}/custom_script', name: 'part_custom_script')]
public function custom_script(Part $part, Request $request): Response
{
// do a sensible permission check so not everyone can execute the script!
$this->denyAccessUnlessGranted('edit', $part);
$command = escapeshellcmd("python3 /path/to/your/script.py ".$part->getID());
$res = shell_exec($command."; echo $?");
$this->addFlash('success', 'script returned '.$res);
return $this->redirectToRoute('part_info', ['id' => $part->getID()]);
} to |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
Is it possible to have a custom button in the page which can run a python script? I would like a button in the part info page which can run custom scripts installed in the docker container.
Beta Was this translation helpful? Give feedback.
All reactions