diff --git a/book/update.cgi b/book/update.cgi index a6b078d4..93ee625b 100755 --- a/book/update.cgi +++ b/book/update.cgi @@ -1,32 +1,63 @@ -#!/usr/bin/perl - -use strict; -use warnings; - -use CGI; -my $r = new CGI; - -print $r->header(); -print "
pulling repo...
";
-system 'git fetch origin && git reset --hard origin/master';
-system 'git submodule update --init --recursive';
-print "
done.
building documentation...
";
-chdir "..";
-
-my $status = system('/bin/bash', '-c', '
- source venv/bin/activate &&
- poetry install --only docs &&
- sphinx-build -M html underactuated /tmp/underactuated_doc &&
- rm -rf book/python &&
- cp -r /tmp/underactuated_doc/html book/python
-');
-
-if ($status == 0) {
- print "
done.
Current working directory: " + os.getcwd() + "
") + print("Python version: " + sys.version + "
") + + print("pulling repo...
")
+ # Capture output from git commands
+ result = subprocess.run(
+ ["git", "fetch", "origin"], capture_output=True, text=True, check=True
+ )
+ result = subprocess.run(
+ ["git", "reset", "--hard", "origin/master"],
+ capture_output=True,
+ text=True,
+ check=True,
+ )
+ result = subprocess.run(
+ ["git", "submodule", "update", "--init", "--recursive"],
+ capture_output=True,
+ text=True,
+ check=True,
+ )
+ print("
done.
building documentation...
")
+ os.chdir("..")
+
+ subprocess.run(
+ [
+ "/bin/bash",
+ "-c",
+ "source venv/bin/activate && "
+ "poetry install --only docs && "
+ "sphinx-build -M html underactuated /tmp/underactuated_doc && "
+ "rm -rf book/python && "
+ "cp -r /tmp/underactuated_doc/html book/python",
+ ],
+ check=True,
+ )
+ print("
done.
Error: " + str(e) + "
") + import traceback + + print("") + traceback.print_exc() + print("") + +finally: + print("")