Skip to content

Commit 2682ec3

Browse files
committed
fix webhook for automatically updating website
Resolves #483
1 parent 262c8d8 commit 2682ec3

File tree

3 files changed

+47
-14
lines changed

3 files changed

+47
-14
lines changed

book/.htaccess

Lines changed: 0 additions & 2 deletions
This file was deleted.

book/force.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ <h1><a href="index.html" style="text-decoration:none;">Robotic Manipulation</a><
5959
<chapter style="counter-reset: chapter 7">
6060
<h1>Manipulator Control</h1>
6161

62+
<p> this is a test </p>
63+
6264
<p>Over the last few chapters, we've developed a great initial toolkit for
6365
perceiving objects (or piles of objects) in a scene, planning grasps, and
6466
moving the arm to grasp. In the last chapters, we started designing motion

book/update.cgi

Lines changed: 45 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
#!/usr/bin/env python3
22

3+
import html
34
import os
45
import subprocess
6+
import sys
7+
8+
# Disable chunked encoding - must be set before any output
9+
os.environ["no-gzip"] = "1"
10+
os.environ["no-chunked-encoding"] = "1"
11+
os.environ["HTTP_NO_CHUNKED_ENCODING"] = "1"
512

613
try:
714
# Do all work first
@@ -37,22 +44,48 @@ try:
3744
"rm -rf book/python && "
3845
"cp -r /tmp/manip_doc/html book/python",
3946
],
47+
stdin=subprocess.DEVNULL,
4048
stdout=log_file,
4149
stderr=subprocess.STDOUT,
4250
start_new_session=True,
51+
close_fds=True,
4352
)
4453

45-
print("Content-Type: text/html\n")
46-
print("<html><body>")
47-
print("<p>pulling repo...</p>")
48-
print(f"<pre>{git_output}</pre>")
49-
print("<p>done.</p>")
50-
print("<p>Documentation build started in the background.</p>")
51-
print("<p>Check /tmp/manipulation_build_docs.log for progress.</p>")
52-
print("</body></html>")
54+
# Build response body first
55+
body = (
56+
"<html><body>\n"
57+
"<p>pulling repo...</p>\n"
58+
f"<pre>{html.escape(git_output)}</pre>\n"
59+
"<p>done.</p>\n"
60+
"<p>Documentation build started in the background.</p>\n"
61+
"<p>Check /tmp/manipulation_build_docs.log for progress.</p>\n"
62+
"</body></html>\n"
63+
)
64+
65+
# Build complete response
66+
response = (
67+
"Content-Type: text/html\r\n"
68+
"\r\n"
69+
"<html><body>\n"
70+
"<p>pulling repo...</p>\n"
71+
f"<pre>{html.escape(git_output)}</pre>\n"
72+
"<p>done.</p>\n"
73+
"<p>Documentation build started in the background.</p>\n"
74+
"<p>Check /tmp/manipulation_build_docs.log for progress.</p>\n"
75+
"</body></html>\n"
76+
)
77+
78+
# Write response and immediately exit
79+
sys.stdout.write(response)
80+
sys.stdout.flush()
5381

5482
except Exception as e:
55-
print("Content-Type: text/html\n")
56-
print("<html><body>")
57-
print(f"<p>Error: {str(e)}</p>")
58-
print("</body></html>")
83+
error_response = (
84+
"Content-Type: text/html\r\n"
85+
"\r\n"
86+
"<html><body>\n"
87+
f"<p>Error: {html.escape(str(e))}</p>\n"
88+
"</body></html>\n"
89+
)
90+
sys.stdout.write(error_response)
91+
sys.stdout.flush()

0 commit comments

Comments
 (0)