Skip to content

Commit

Permalink
switch update.cgi to python
Browse files Browse the repository at this point in the history
  • Loading branch information
RussTedrake committed Jan 24, 2025
1 parent fdb1f5d commit 3ff89a9
Showing 1 changed file with 31 additions and 25 deletions.
56 changes: 31 additions & 25 deletions book/update.cgi
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
#!/usr/bin/perl
#!/usr/bin/env python3

use strict;
use warnings;
import cgitb
import os
import subprocess

use CGI;
my $r = new CGI;
cgitb.enable()

print $r->header();
print "<p>pulling repo...<br/>";
system 'git fetch origin && git reset --hard origin/master';
system 'git submodule update --init --recursive';
print "<br/>done.</p>";
print("Content-Type: text/html\n")
print("<html><body>")

print "<p>building documentation...<br/>";
chdir "..";
print("<p>pulling repo...<br/>")
subprocess.run(["git", "fetch", "origin"], check=True)
subprocess.run(["git", "reset", "--hard", "origin/master"], check=True)
subprocess.run(["git", "submodule", "update", "--init", "--recursive"], check=True)
print("<br/>done.</p>")

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
');
print("<p>building documentation...<br/>")
os.chdir("..")

if ($status == 0) {
print "<br/>done.</p>";
} else {
print "<br/>Error occurred: $status</p>";
}
try:
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("<br/>done.</p>")
except subprocess.CalledProcessError as e:
print(f"<br/>Error occurred: {e.returncode}</p>")

print $r->end_html;
print("</body></html>")

0 comments on commit 3ff89a9

Please sign in to comment.