Show More
@@ -1,89 +1,89 b'' | |||
|
1 | 1 | #!/bin/sh |
|
2 | 2 | |
|
3 | 3 | "$TESTDIR/hghave" pygments || exit 80 |
|
4 | 4 | |
|
5 | 5 | cat <<EOF >> $HGRCPATH |
|
6 | 6 | [extensions] |
|
7 | 7 | hgext.highlight = |
|
8 | 8 | [web] |
|
9 | 9 | pygments_style = friendly |
|
10 | 10 | EOF |
|
11 | 11 | |
|
12 | 12 | hg init test |
|
13 | 13 | cd test |
|
14 | 14 | cp $TESTDIR/get-with-headers.py ./ |
|
15 | 15 | |
|
16 | 16 | # check for UnicodeDecodeError with iso-8859-1 file contents |
|
17 | python -c 'fp = open("isolatin", "w"); fp.write("h\xFCbsch\n"); fp.close();' | |
|
17 | python -c 'fp = open("isolatin.txt", "w"); fp.write("h\xFCbsch\n"); fp.close();' | |
|
18 | 18 | |
|
19 | 19 | hg ci -Ama |
|
20 | 20 | |
|
21 | 21 | echo % hg serve |
|
22 | 22 | hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log |
|
23 | 23 | cat hg.pid >> $DAEMON_PIDS |
|
24 | 24 | |
|
25 | 25 | echo % hgweb filerevision, html |
|
26 | 26 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/get-with-headers.py') \ |
|
27 | 27 | | sed "s/class=\"k\"/class=\"kn\"/g" |
|
28 | 28 | |
|
29 | 29 | echo % hgweb filerevision, html |
|
30 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/isolatin') \ | |
|
30 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/isolatin.txt') \ | |
|
31 | 31 | | sed "s/class=\"k\"/class=\"kn\"/g" |
|
32 | 32 | |
|
33 | 33 | echo % hgweb fileannotate, html |
|
34 | 34 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/get-with-headers.py') \ |
|
35 | 35 | | sed "s/class=\"k\"/class=\"kn\"/g" |
|
36 | 36 | |
|
37 | 37 | echo % hgweb fileannotate, raw |
|
38 | 38 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/get-with-headers.py?style=raw') \ |
|
39 | 39 | | sed "s/test@//" > a |
|
40 | 40 | |
|
41 | 41 | echo "200 Script output follows" > b |
|
42 | 42 | echo "" >> b |
|
43 | 43 | echo "" >> b |
|
44 | 44 | hg annotate "get-with-headers.py" >> b |
|
45 | 45 | echo "" >> b |
|
46 | 46 | echo "" >> b |
|
47 | 47 | echo "" >> b |
|
48 | 48 | echo "" >> b |
|
49 | 49 | |
|
50 | 50 | diff -u b a |
|
51 | 51 | |
|
52 | 52 | echo |
|
53 | 53 | echo % hgweb filerevision, raw |
|
54 | 54 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/get-with-headers.py?style=raw') \ |
|
55 | 55 | > a |
|
56 | 56 | |
|
57 | 57 | echo "200 Script output follows" > b |
|
58 | 58 | echo "" >> b |
|
59 | 59 | hg cat get-with-headers.py >> b |
|
60 | 60 | |
|
61 | 61 | diff -u b a |
|
62 | 62 | |
|
63 | 63 | echo |
|
64 | 64 | echo % hgweb highlightcss friendly |
|
65 | 65 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/highlightcss' > out |
|
66 | 66 | head -n 4 out |
|
67 | 67 | rm out |
|
68 | 68 | |
|
69 | 69 | echo % errors encountered |
|
70 | 70 | cat errors.log |
|
71 | 71 | "$TESTDIR/killdaemons.py" |
|
72 | 72 | |
|
73 | 73 | # Change the pygments style |
|
74 | 74 | cat > .hg/hgrc <<EOF |
|
75 | 75 | [web] |
|
76 | 76 | pygments_style = fruity |
|
77 | 77 | EOF |
|
78 | 78 | |
|
79 | 79 | echo % hg serve again |
|
80 | 80 | hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log |
|
81 | 81 | cat hg.pid >> $DAEMON_PIDS |
|
82 | 82 | |
|
83 | 83 | echo % hgweb highlightcss fruity |
|
84 | 84 | "$TESTDIR/get-with-headers.py" localhost:$HGPORT '/highlightcss' > out |
|
85 | 85 | head -n 4 out |
|
86 | 86 | rm out |
|
87 | 87 | |
|
88 | 88 | echo % errors encountered |
|
89 | 89 | cat errors.log |
@@ -1,282 +1,282 b'' | |||
|
1 | 1 | adding get-with-headers.py |
|
2 | adding isolatin | |
|
2 | adding isolatin.txt | |
|
3 | 3 | % hg serve |
|
4 | 4 | % hgweb filerevision, html |
|
5 | 5 | 200 Script output follows |
|
6 | 6 | |
|
7 | 7 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|
8 | 8 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> |
|
9 | 9 | <head> |
|
10 | 10 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> |
|
11 | 11 | <meta name="robots" content="index, nofollow" /> |
|
12 | 12 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> |
|
13 | 13 | |
|
14 | 14 | <link rel="stylesheet" href="/highlightcss" type="text/css" /> |
|
15 |
<title>test: |
|
|
15 | <title>test: 7c3facd7c58a get-with-headers.py</title> | |
|
16 | 16 | </head> |
|
17 | 17 | <body> |
|
18 | 18 | |
|
19 | 19 | <div class="container"> |
|
20 | 20 | <div class="menu"> |
|
21 | 21 | <div class="logo"> |
|
22 | 22 | <a href="http://www.selenic.com/mercurial/"> |
|
23 | 23 | <img src="/static/hglogo.png" alt="mercurial" /></a> |
|
24 | 24 | </div> |
|
25 | 25 | <ul> |
|
26 |
<li><a href="/shortlog/ |
|
|
27 |
<li><a href="/graph/ |
|
|
26 | <li><a href="/shortlog/7c3facd7c58a">log</a></li> | |
|
27 | <li><a href="/graph/7c3facd7c58a">graph</a></li> | |
|
28 | 28 | <li><a href="/tags">tags</a></li> |
|
29 | 29 | </ul> |
|
30 | 30 | <ul> |
|
31 |
<li><a href="/rev/ |
|
|
32 |
<li><a href="/file/ |
|
|
31 | <li><a href="/rev/7c3facd7c58a">changeset</a></li> | |
|
32 | <li><a href="/file/7c3facd7c58a/">browse</a></li> | |
|
33 | 33 | </ul> |
|
34 | 34 | <ul> |
|
35 | 35 | <li class="active">file</li> |
|
36 |
<li><a href="/diff/ |
|
|
37 |
<li><a href="/annotate/ |
|
|
38 |
<li><a href="/log/ |
|
|
39 |
<li><a href="/raw-file/ |
|
|
36 | <li><a href="/diff/7c3facd7c58a/get-with-headers.py">diff</a></li> | |
|
37 | <li><a href="/annotate/7c3facd7c58a/get-with-headers.py">annotate</a></li> | |
|
38 | <li><a href="/log/7c3facd7c58a/get-with-headers.py">file log</a></li> | |
|
39 | <li><a href="/raw-file/7c3facd7c58a/get-with-headers.py">raw</a></li> | |
|
40 | 40 | </ul> |
|
41 | 41 | </div> |
|
42 | 42 | |
|
43 | 43 | <div class="main"> |
|
44 | 44 | <h2><a href="/">test</a></h2> |
|
45 |
<h3>view get-with-headers.py @ 0: |
|
|
45 | <h3>view get-with-headers.py @ 0:7c3facd7c58a</h3> | |
|
46 | 46 | |
|
47 | 47 | <form class="search" action="/log"> |
|
48 | 48 | |
|
49 | 49 | <p><input name="rev" id="search1" type="text" size="30" /></p> |
|
50 | 50 | <div id="hint">find changesets by author, revision, |
|
51 | 51 | files, or words in the commit message</div> |
|
52 | 52 | </form> |
|
53 | 53 | |
|
54 | 54 | <div class="description">a</div> |
|
55 | 55 | |
|
56 | 56 | <table id="changesetEntry"> |
|
57 | 57 | <tr> |
|
58 | 58 | <th class="author">author</th> |
|
59 | 59 | <td class="author">test</td> |
|
60 | 60 | </tr> |
|
61 | 61 | <tr> |
|
62 | 62 | <th class="date">date</th> |
|
63 | 63 | <td class="date">Thu Jan 01 00:00:00 1970 +0000 (many years ago)</td> |
|
64 | 64 | </tr> |
|
65 | 65 | <tr> |
|
66 | 66 | <th class="author">parents</th> |
|
67 | 67 | <td class="author"></td> |
|
68 | 68 | </tr> |
|
69 | 69 | <tr> |
|
70 | 70 | <th class="author">children</th> |
|
71 | 71 | <td class="author"></td> |
|
72 | 72 | </tr> |
|
73 | 73 | |
|
74 | 74 | </table> |
|
75 | 75 | |
|
76 | 76 | <div class="overflow"> |
|
77 | 77 | <div class="sourcefirst"> line source</div> |
|
78 | 78 | <div class="parity0 source"><a href="#l1" id="l1"> 1</a> <span class="c">#!/usr/bin/env python</span></div><div class="parity1 source"><a href="#l2" id="l2"> 2</a> </div><div class="parity0 source"><a href="#l3" id="l3"> 3</a> <span class="n">__doc__</span> <span class="o">=</span> <span class="s">"""This does HTTP get requests given a host:port and path and returns</span></div><div class="parity1 source"><a href="#l4" id="l4"> 4</a> <span class="s">a subset of the headers plus the body of the result."""</span></div><div class="parity0 source"><a href="#l5" id="l5"> 5</a> </div><div class="parity1 source"><a href="#l6" id="l6"> 6</a> <span class="kn">import</span> <span class="nn">httplib</span><span class="o">,</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">re</span></div><div class="parity0 source"><a href="#l7" id="l7"> 7</a> </div><div class="parity1 source"><a href="#l8" id="l8"> 8</a> <span class="kn">try</span><span class="p">:</span></div><div class="parity0 source"><a href="#l9" id="l9"> 9</a> <span class="kn">import</span> <span class="nn">msvcrt</span><span class="o">,</span> <span class="nn">os</span></div><div class="parity1 source"><a href="#l10" id="l10"> 10</a> <span class="n">msvcrt</span><span class="o">.</span><span class="n">setmode</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">fileno</span><span class="p">(),</span> <span class="n">os</span><span class="o">.</span><span class="n">O_BINARY</span><span class="p">)</span></div><div class="parity0 source"><a href="#l11" id="l11"> 11</a> <span class="n">msvcrt</span><span class="o">.</span><span class="n">setmode</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="o">.</span><span class="n">fileno</span><span class="p">(),</span> <span class="n">os</span><span class="o">.</span><span class="n">O_BINARY</span><span class="p">)</span></div><div class="parity1 source"><a href="#l12" id="l12"> 12</a> <span class="kn">except</span> <span class="ne">ImportError</span><span class="p">:</span></div><div class="parity0 source"><a href="#l13" id="l13"> 13</a> <span class="kn">pass</span></div><div class="parity1 source"><a href="#l14" id="l14"> 14</a> </div><div class="parity0 source"><a href="#l15" id="l15"> 15</a> <span class="n">headers</span> <span class="o">=</span> <span class="p">[</span><span class="n">h</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="kn">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">3</span><span class="p">:]]</span></div><div class="parity1 source"><a href="#l16" id="l16"> 16</a> <span class="n">conn</span> <span class="o">=</span> <span class="n">httplib</span><span class="o">.</span><span class="n">HTTPConnection</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">1</span><span class="p">])</span></div><div class="parity0 source"><a href="#l17" id="l17"> 17</a> <span class="n">conn</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="s">"GET"</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">2</span><span class="p">])</span></div><div class="parity1 source"><a href="#l18" id="l18"> 18</a> <span class="n">response</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">getresponse</span><span class="p">()</span></div><div class="parity0 source"><a href="#l19" id="l19"> 19</a> <span class="kn">print</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">reason</span></div><div class="parity1 source"><a href="#l20" id="l20"> 20</a> <span class="kn">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">headers</span><span class="p">:</span></div><div class="parity0 source"><a href="#l21" id="l21"> 21</a> <span class="kn">if</span> <span class="n">response</span><span class="o">.</span><span class="n">getheader</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span></div><div class="parity1 source"><a href="#l22" id="l22"> 22</a> <span class="kn">print</span> <span class="s">"</span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">getheader</span><span class="p">(</span><span class="n">h</span><span class="p">))</span></div><div class="parity0 source"><a href="#l23" id="l23"> 23</a> <span class="kn">print</span></div><div class="parity1 source"><a href="#l24" id="l24"> 24</a> <span class="n">data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">read</span><span class="p">()</span></div><div class="parity0 source"><a href="#l25" id="l25"> 25</a> <span class="n">data</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="s">'\d+ years'</span><span class="p">,</span> <span class="s">'many years'</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span></div><div class="parity1 source"><a href="#l26" id="l26"> 26</a> <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span></div><div class="parity0 source"><a href="#l27" id="l27"> 27</a> </div><div class="parity1 source"><a href="#l28" id="l28"> 28</a> <span class="kn">if</span> <span class="mf">200</span> <span class="o"><=</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span> <span class="o"><=</span> <span class="mf">299</span><span class="p">:</span></div><div class="parity0 source"><a href="#l29" id="l29"> 29</a> <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mf">0</span><span class="p">)</span></div><div class="parity1 source"><a href="#l30" id="l30"> 30</a> <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mf">1</span><span class="p">)</span></div> |
|
79 | 79 | <div class="sourcelast"></div> |
|
80 | 80 | </div> |
|
81 | 81 | </div> |
|
82 | 82 | </div> |
|
83 | 83 | |
|
84 | 84 | |
|
85 | 85 | |
|
86 | 86 | </body> |
|
87 | 87 | </html> |
|
88 | 88 | |
|
89 | 89 | % hgweb filerevision, html |
|
90 | 90 | 200 Script output follows |
|
91 | 91 | |
|
92 | 92 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|
93 | 93 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> |
|
94 | 94 | <head> |
|
95 | 95 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> |
|
96 | 96 | <meta name="robots" content="index, nofollow" /> |
|
97 | 97 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> |
|
98 | 98 | |
|
99 | 99 | <link rel="stylesheet" href="/highlightcss" type="text/css" /> |
|
100 |
<title>test: |
|
|
100 | <title>test: 7c3facd7c58a isolatin.txt</title> | |
|
101 | 101 | </head> |
|
102 | 102 | <body> |
|
103 | 103 | |
|
104 | 104 | <div class="container"> |
|
105 | 105 | <div class="menu"> |
|
106 | 106 | <div class="logo"> |
|
107 | 107 | <a href="http://www.selenic.com/mercurial/"> |
|
108 | 108 | <img src="/static/hglogo.png" alt="mercurial" /></a> |
|
109 | 109 | </div> |
|
110 | 110 | <ul> |
|
111 |
<li><a href="/shortlog/ |
|
|
112 |
<li><a href="/graph/ |
|
|
111 | <li><a href="/shortlog/7c3facd7c58a">log</a></li> | |
|
112 | <li><a href="/graph/7c3facd7c58a">graph</a></li> | |
|
113 | 113 | <li><a href="/tags">tags</a></li> |
|
114 | 114 | </ul> |
|
115 | 115 | <ul> |
|
116 |
<li><a href="/rev/ |
|
|
117 |
<li><a href="/file/ |
|
|
116 | <li><a href="/rev/7c3facd7c58a">changeset</a></li> | |
|
117 | <li><a href="/file/7c3facd7c58a/">browse</a></li> | |
|
118 | 118 | </ul> |
|
119 | 119 | <ul> |
|
120 | 120 | <li class="active">file</li> |
|
121 |
<li><a href="/diff/ |
|
|
122 |
<li><a href="/annotate/ |
|
|
123 |
<li><a href="/log/ |
|
|
124 |
<li><a href="/raw-file/ |
|
|
121 | <li><a href="/diff/7c3facd7c58a/isolatin.txt">diff</a></li> | |
|
122 | <li><a href="/annotate/7c3facd7c58a/isolatin.txt">annotate</a></li> | |
|
123 | <li><a href="/log/7c3facd7c58a/isolatin.txt">file log</a></li> | |
|
124 | <li><a href="/raw-file/7c3facd7c58a/isolatin.txt">raw</a></li> | |
|
125 | 125 | </ul> |
|
126 | 126 | </div> |
|
127 | 127 | |
|
128 | 128 | <div class="main"> |
|
129 | 129 | <h2><a href="/">test</a></h2> |
|
130 |
<h3>view isolatin |
|
|
130 | <h3>view isolatin.txt @ 0:7c3facd7c58a</h3> | |
|
131 | 131 | |
|
132 | 132 | <form class="search" action="/log"> |
|
133 | 133 | |
|
134 | 134 | <p><input name="rev" id="search1" type="text" size="30" /></p> |
|
135 | 135 | <div id="hint">find changesets by author, revision, |
|
136 | 136 | files, or words in the commit message</div> |
|
137 | 137 | </form> |
|
138 | 138 | |
|
139 | 139 | <div class="description">a</div> |
|
140 | 140 | |
|
141 | 141 | <table id="changesetEntry"> |
|
142 | 142 | <tr> |
|
143 | 143 | <th class="author">author</th> |
|
144 | 144 | <td class="author">test</td> |
|
145 | 145 | </tr> |
|
146 | 146 | <tr> |
|
147 | 147 | <th class="date">date</th> |
|
148 | 148 | <td class="date">Thu Jan 01 00:00:00 1970 +0000 (many years ago)</td> |
|
149 | 149 | </tr> |
|
150 | 150 | <tr> |
|
151 | 151 | <th class="author">parents</th> |
|
152 | 152 | <td class="author"></td> |
|
153 | 153 | </tr> |
|
154 | 154 | <tr> |
|
155 | 155 | <th class="author">children</th> |
|
156 | 156 | <td class="author"></td> |
|
157 | 157 | </tr> |
|
158 | 158 | |
|
159 | 159 | </table> |
|
160 | 160 | |
|
161 | 161 | <div class="overflow"> |
|
162 | 162 | <div class="sourcefirst"> line source</div> |
|
163 | 163 | <div class="parity0 source"><a href="#l1" id="l1"> 1</a> h?bsch</div> |
|
164 | 164 | <div class="sourcelast"></div> |
|
165 | 165 | </div> |
|
166 | 166 | </div> |
|
167 | 167 | </div> |
|
168 | 168 | |
|
169 | 169 | |
|
170 | 170 | |
|
171 | 171 | </body> |
|
172 | 172 | </html> |
|
173 | 173 | |
|
174 | 174 | % hgweb fileannotate, html |
|
175 | 175 | 200 Script output follows |
|
176 | 176 | |
|
177 | 177 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
|
178 | 178 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US"> |
|
179 | 179 | <head> |
|
180 | 180 | <link rel="icon" href="/static/hgicon.png" type="image/png" /> |
|
181 | 181 | <meta name="robots" content="index, nofollow" /> |
|
182 | 182 | <link rel="stylesheet" href="/static/style-paper.css" type="text/css" /> |
|
183 | 183 | |
|
184 | 184 | <link rel="stylesheet" href="/highlightcss" type="text/css" /> |
|
185 | 185 | <title>test: get-with-headers.py annotate</title> |
|
186 | 186 | </head> |
|
187 | 187 | <body> |
|
188 | 188 | |
|
189 | 189 | <div class="container"> |
|
190 | 190 | <div class="menu"> |
|
191 | 191 | <div class="logo"> |
|
192 | 192 | <a href="http://www.selenic.com/mercurial/"> |
|
193 | 193 | <img src="/static/hglogo.png" alt="mercurial" /></a> |
|
194 | 194 | </div> |
|
195 | 195 | <ul> |
|
196 |
<li><a href="/shortlog/ |
|
|
197 |
<li><a href="/graph/ |
|
|
196 | <li><a href="/shortlog/7c3facd7c58a">log</a></li> | |
|
197 | <li><a href="/graph/7c3facd7c58a">graph</a></li> | |
|
198 | 198 | <li><a href="/tags">tags</a></li> |
|
199 | 199 | </ul> |
|
200 | 200 | |
|
201 | 201 | <ul> |
|
202 |
<li><a href="/rev/ |
|
|
203 |
<li><a href="/file/ |
|
|
202 | <li><a href="/rev/7c3facd7c58a">changeset</a></li> | |
|
203 | <li><a href="/file/7c3facd7c58a/">browse</a></li> | |
|
204 | 204 | </ul> |
|
205 | 205 | <ul> |
|
206 |
<li><a href="/file/ |
|
|
207 |
<li><a href="/diff/ |
|
|
206 | <li><a href="/file/7c3facd7c58a/get-with-headers.py">file</a></li> | |
|
207 | <li><a href="/diff/7c3facd7c58a/get-with-headers.py">diff</a></li> | |
|
208 | 208 | <li class="active">annotate</li> |
|
209 |
<li><a href="/log/ |
|
|
210 |
<li><a href="/raw-annotate/ |
|
|
209 | <li><a href="/log/7c3facd7c58a/get-with-headers.py">file log</a></li> | |
|
210 | <li><a href="/raw-annotate/7c3facd7c58a/get-with-headers.py">raw</a></li> | |
|
211 | 211 | </ul> |
|
212 | 212 | </div> |
|
213 | 213 | |
|
214 | 214 | <div class="main"> |
|
215 | 215 | <h2><a href="/">test</a></h2> |
|
216 |
<h3>annotate get-with-headers.py @ 0: |
|
|
216 | <h3>annotate get-with-headers.py @ 0:7c3facd7c58a</h3> | |
|
217 | 217 | |
|
218 | 218 | <form class="search" action="/log"> |
|
219 | 219 | |
|
220 | 220 | <p><input name="rev" id="search1" type="text" size="30" /></p> |
|
221 | 221 | <div id="hint">find changesets by author, revision, |
|
222 | 222 | files, or words in the commit message</div> |
|
223 | 223 | </form> |
|
224 | 224 | |
|
225 | 225 | <div class="description">a</div> |
|
226 | 226 | |
|
227 | 227 | <table id="changesetEntry"> |
|
228 | 228 | <tr> |
|
229 | 229 | <th class="author">author</th> |
|
230 | 230 | <td class="author">test</td> |
|
231 | 231 | </tr> |
|
232 | 232 | <tr> |
|
233 | 233 | <th class="date">date</th> |
|
234 | 234 | <td class="date">Thu Jan 01 00:00:00 1970 +0000 (many years ago)</td> |
|
235 | 235 | </tr> |
|
236 | 236 | <tr> |
|
237 | 237 | <th class="author">parents</th> |
|
238 | 238 | <td class="author"></td> |
|
239 | 239 | </tr> |
|
240 | 240 | <tr> |
|
241 | 241 | <th class="author">children</th> |
|
242 | 242 | <td class="author"></td> |
|
243 | 243 | </tr> |
|
244 | 244 | |
|
245 | 245 | </table> |
|
246 | 246 | |
|
247 | 247 | <br/> |
|
248 | 248 | |
|
249 | 249 | <div class="overflow"> |
|
250 | 250 | <table class="bigtable"> |
|
251 | 251 | <tr> |
|
252 | 252 | <th class="annotate">rev</th> |
|
253 | 253 | <th class="line"> line source</th> |
|
254 | 254 | </tr> |
|
255 |
<tr class="parity0"><td class="annotate"><a href="/annotate/ |
|
|
255 | <tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#1" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l1" id="l1"> 1</a> <span class="c">#!/usr/bin/env python</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#2" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l2" id="l2"> 2</a> </td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#3" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l3" id="l3"> 3</a> <span class="n">__doc__</span> <span class="o">=</span> <span class="s">"""This does HTTP get requests given a host:port and path and returns</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#4" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l4" id="l4"> 4</a> <span class="s">a subset of the headers plus the body of the result."""</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#5" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l5" id="l5"> 5</a> </td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#6" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l6" id="l6"> 6</a> <span class="kn">import</span> <span class="nn">httplib</span><span class="o">,</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">re</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#7" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l7" id="l7"> 7</a> </td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#8" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l8" id="l8"> 8</a> <span class="kn">try</span><span class="p">:</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#9" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l9" id="l9"> 9</a> <span class="kn">import</span> <span class="nn">msvcrt</span><span class="o">,</span> <span class="nn">os</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#10" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l10" id="l10"> 10</a> <span class="n">msvcrt</span><span class="o">.</span><span class="n">setmode</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">fileno</span><span class="p">(),</span> <span class="n">os</span><span class="o">.</span><span class="n">O_BINARY</span><span class="p">)</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#11" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l11" id="l11"> 11</a> <span class="n">msvcrt</span><span class="o">.</span><span class="n">setmode</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="o">.</span><span class="n">fileno</span><span class="p">(),</span> <span class="n">os</span><span class="o">.</span><span class="n">O_BINARY</span><span class="p">)</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#12" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l12" id="l12"> 12</a> <span class="kn">except</span> <span class="ne">ImportError</span><span class="p">:</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#13" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l13" id="l13"> 13</a> <span class="kn">pass</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#14" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l14" id="l14"> 14</a> </td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#15" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l15" id="l15"> 15</a> <span class="n">headers</span> <span class="o">=</span> <span class="p">[</span><span class="n">h</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span> <span class="kn">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">3</span><span class="p">:]]</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#16" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l16" id="l16"> 16</a> <span class="n">conn</span> <span class="o">=</span> <span class="n">httplib</span><span class="o">.</span><span class="n">HTTPConnection</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">1</span><span class="p">])</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#17" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l17" id="l17"> 17</a> <span class="n">conn</span><span class="o">.</span><span class="n">request</span><span class="p">(</span><span class="s">"GET"</span><span class="p">,</span> <span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mf">2</span><span class="p">])</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#18" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l18" id="l18"> 18</a> <span class="n">response</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">getresponse</span><span class="p">()</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#19" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l19" id="l19"> 19</a> <span class="kn">print</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">reason</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#20" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l20" id="l20"> 20</a> <span class="kn">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">headers</span><span class="p">:</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#21" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l21" id="l21"> 21</a> <span class="kn">if</span> <span class="n">response</span><span class="o">.</span><span class="n">getheader</span><span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#22" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l22" id="l22"> 22</a> <span class="kn">print</span> <span class="s">"</span><span class="si">%s</span><span class="s">: </span><span class="si">%s</span><span class="s">"</span> <span class="o">%</span> <span class="p">(</span><span class="n">h</span><span class="p">,</span> <span class="n">response</span><span class="o">.</span><span class="n">getheader</span><span class="p">(</span><span class="n">h</span><span class="p">))</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#23" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l23" id="l23"> 23</a> <span class="kn">print</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#24" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l24" id="l24"> 24</a> <span class="n">data</span> <span class="o">=</span> <span class="n">response</span><span class="o">.</span><span class="n">read</span><span class="p">()</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#25" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l25" id="l25"> 25</a> <span class="n">data</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="s">'\d+ years'</span><span class="p">,</span> <span class="s">'many years'</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#26" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l26" id="l26"> 26</a> <span class="n">sys</span><span class="o">.</span><span class="n">stdout</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">data</span><span class="p">)</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#27" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l27" id="l27"> 27</a> </td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#28" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l28" id="l28"> 28</a> <span class="kn">if</span> <span class="mf">200</span> <span class="o"><=</span> <span class="n">response</span><span class="o">.</span><span class="n">status</span> <span class="o"><=</span> <span class="mf">299</span><span class="p">:</span></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#29" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l29" id="l29"> 29</a> <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mf">0</span><span class="p">)</span></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/7c3facd7c58a/get-with-headers.py#30" title="7c3facd7c58a: a">test@0</a></td><td class="source"><a href="#l30" id="l30"> 30</a> <span class="n">sys</span><span class="o">.</span><span class="n">exit</span><span class="p">(</span><span class="mf">1</span><span class="p">)</span></td></tr> | |
|
256 | 256 | </table> |
|
257 | 257 | </div> |
|
258 | 258 | </div> |
|
259 | 259 | </div> |
|
260 | 260 | |
|
261 | 261 | |
|
262 | 262 | |
|
263 | 263 | </body> |
|
264 | 264 | </html> |
|
265 | 265 | |
|
266 | 266 | % hgweb fileannotate, raw |
|
267 | 267 | |
|
268 | 268 | % hgweb filerevision, raw |
|
269 | 269 | |
|
270 | 270 | % hgweb highlightcss friendly |
|
271 | 271 | 200 Script output follows |
|
272 | 272 | |
|
273 | 273 | /* pygments_style = friendly */ |
|
274 | 274 | |
|
275 | 275 | % errors encountered |
|
276 | 276 | % hg serve again |
|
277 | 277 | % hgweb highlightcss fruity |
|
278 | 278 | 200 Script output follows |
|
279 | 279 | |
|
280 | 280 | /* pygments_style = fruity */ |
|
281 | 281 | |
|
282 | 282 | % errors encountered |
General Comments 0
You need to be logged in to leave comments.
Login now