Show More
@@ -0,0 +1,29 b'' | |||||
|
1 | #!/bin/sh | |||
|
2 | ||||
|
3 | "$TESTDIR/hghave" pygments || exit 80 | |||
|
4 | ||||
|
5 | cat <<EOF >> $HGRCPATH | |||
|
6 | [extensions] | |||
|
7 | hgext.highlight = | |||
|
8 | EOF | |||
|
9 | ||||
|
10 | hg init test | |||
|
11 | cd test | |||
|
12 | cp $TESTDIR/get-with-headers.py ./ | |||
|
13 | hg ci -Ama | |||
|
14 | ||||
|
15 | echo % hg serve | |||
|
16 | hg serve -p $HGPORT -d -n test --pid-file=hg.pid -A access.log -E errors.log | |||
|
17 | cat hg.pid >> $DAEMON_PIDS | |||
|
18 | ||||
|
19 | echo % hgweb filerevision | |||
|
20 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/file/tip/get-with-headers.py') \ | |||
|
21 | | sed "s/[0-9]* years ago/long ago/g" | |||
|
22 | ||||
|
23 | echo % hgweb fileannotate | |||
|
24 | ("$TESTDIR/get-with-headers.py" localhost:$HGPORT '/annotate/tip/get-with-headers.py') \ | |||
|
25 | | sed "s/[0-9]* years ago/long ago/g" | |||
|
26 | ||||
|
27 | echo % errors encountered | |||
|
28 | cat errors.log | |||
|
29 |
@@ -0,0 +1,129 b'' | |||||
|
1 | adding get-with-headers.py | |||
|
2 | % hg serve | |||
|
3 | % hgweb filerevision | |||
|
4 | 200 Script output follows | |||
|
5 | ||||
|
6 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |||
|
7 | <html> | |||
|
8 | <head> | |||
|
9 | <link rel="icon" href="/static/hgicon.png" type="image/png"> | |||
|
10 | <meta name="robots" content="index, nofollow" /> | |||
|
11 | <link rel="stylesheet" href="/static/style.css" type="text/css" /> | |||
|
12 | ||||
|
13 | <link rel="stylesheet" href="/static/highlight.css" type="text/css" /> | |||
|
14 | <title>test:get-with-headers.py</title> | |||
|
15 | </head> | |||
|
16 | <body> | |||
|
17 | ||||
|
18 | <div class="buttons"> | |||
|
19 | <a href="/log/0">changelog</a> | |||
|
20 | <a href="/shortlog/0">shortlog</a> | |||
|
21 | <a href="/tags">tags</a> | |||
|
22 | <a href="/rev/79ee608ca36d">changeset</a> | |||
|
23 | <a href="/file/79ee608ca36d/">files</a> | |||
|
24 | <a href="/log/79ee608ca36d/get-with-headers.py">revisions</a> | |||
|
25 | <a href="/annotate/79ee608ca36d/get-with-headers.py">annotate</a> | |||
|
26 | <a href="/raw-file/79ee608ca36d/get-with-headers.py">raw</a> | |||
|
27 | </div> | |||
|
28 | ||||
|
29 | <h2>get-with-headers.py</h2> | |||
|
30 | ||||
|
31 | <table> | |||
|
32 | <tr> | |||
|
33 | <td class="metatag">changeset 0:</td> | |||
|
34 | <td><a href="/rev/79ee608ca36d">79ee608ca36d</a></td></tr> | |||
|
35 | ||||
|
36 | ||||
|
37 | <tr> | |||
|
38 | <td class="metatag">author:</td> | |||
|
39 | <td>test</td></tr> | |||
|
40 | <tr> | |||
|
41 | <td class="metatag">date:</td> | |||
|
42 | <td>Thu Jan 01 00:00:00 1970 +0000 (long ago)</td></tr> | |||
|
43 | <tr> | |||
|
44 | <td class="metatag">permissions:</td> | |||
|
45 | <td>-rwxr-xr-x</td></tr> | |||
|
46 | <tr> | |||
|
47 | <td class="metatag">description:</td> | |||
|
48 | <td>a</td> | |||
|
49 | </tr> | |||
|
50 | </table> | |||
|
51 | ||||
|
52 | <pre> | |||
|
53 | <div class="parity0"><a class="lineno" href="#l1" id="l1"> 1</a><span class="c">#!/usr/bin/env python</span></div><div class="parity1"><a class="lineno" href="#l2" id="l2"> 2</a></div><div class="parity0"><a class="lineno" 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"><a class="lineno" 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"><a class="lineno" href="#l5" id="l5"> 5</a></div><div class="parity1"><a class="lineno" href="#l6" id="l6"> 6</a><span class="k">import</span> <span class="nn">httplib</span><span class="o">,</span> <span class="nn">sys</span></div><div class="parity0"><a class="lineno" href="#l7" id="l7"> 7</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="k">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"><a class="lineno" href="#l8" id="l8"> 8</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"><a class="lineno" href="#l9" id="l9"> 9</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"><a class="lineno" href="#l10" id="l10"> 10</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"><a class="lineno" href="#l11" id="l11"> 11</a><span class="k">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"><a class="lineno" href="#l12" id="l12"> 12</a><span class="k">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"><a class="lineno" href="#l13" id="l13"> 13</a> <span class="k">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"><a class="lineno" href="#l14" id="l14"> 14</a> <span class="k">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"><a class="lineno" href="#l15" id="l15"> 15</a><span class="k">print</span></div><div class="parity1"><a class="lineno" href="#l16" id="l16"> 16</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">response</span><span class="o">.</span><span class="n">read</span><span class="p">())</span></div><div class="parity0"><a class="lineno" href="#l17" id="l17"> 17</a></div><div class="parity1"><a class="lineno" href="#l18" id="l18"> 18</a><span class="k">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"><a class="lineno" href="#l19" id="l19"> 19</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"><a class="lineno" href="#l20" id="l20"> 20</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> | |||
|
54 | </pre> | |||
|
55 | ||||
|
56 | ||||
|
57 | <div class="logo"> | |||
|
58 | <a href="http://www.selenic.com/mercurial/"> | |||
|
59 | <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> | |||
|
60 | </div> | |||
|
61 | ||||
|
62 | </body> | |||
|
63 | </html> | |||
|
64 | ||||
|
65 | % hgweb fileannotate | |||
|
66 | 200 Script output follows | |||
|
67 | ||||
|
68 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | |||
|
69 | <html> | |||
|
70 | <head> | |||
|
71 | <link rel="icon" href="/static/hgicon.png" type="image/png"> | |||
|
72 | <meta name="robots" content="index, nofollow" /> | |||
|
73 | <link rel="stylesheet" href="/static/style.css" type="text/css" /> | |||
|
74 | ||||
|
75 | <link rel="stylesheet" href="/static/highlight.css" type="text/css" /> | |||
|
76 | <title>test: get-with-headers.py annotate</title> | |||
|
77 | </head> | |||
|
78 | <body> | |||
|
79 | ||||
|
80 | <div class="buttons"> | |||
|
81 | <a href="/log/0">changelog</a> | |||
|
82 | <a href="/shortlog/0">shortlog</a> | |||
|
83 | <a href="/tags">tags</a> | |||
|
84 | <a href="/rev/79ee608ca36d">changeset</a> | |||
|
85 | <a href="/file/79ee608ca36d/">files</a> | |||
|
86 | <a href="/file/79ee608ca36d/get-with-headers.py">file</a> | |||
|
87 | <a href="/log/79ee608ca36d/get-with-headers.py">revisions</a> | |||
|
88 | <a href="/raw-annotate/79ee608ca36d/get-with-headers.py">raw</a> | |||
|
89 | </div> | |||
|
90 | ||||
|
91 | <h2>Annotate get-with-headers.py</h2> | |||
|
92 | ||||
|
93 | <table> | |||
|
94 | <tr> | |||
|
95 | <td class="metatag">changeset 0:</td> | |||
|
96 | <td><a href="/rev/79ee608ca36d">79ee608ca36d</a></td></tr> | |||
|
97 | ||||
|
98 | ||||
|
99 | <tr> | |||
|
100 | <td class="metatag">author:</td> | |||
|
101 | <td>test</td></tr> | |||
|
102 | <tr> | |||
|
103 | <td class="metatag">date:</td> | |||
|
104 | <td>Thu Jan 01 00:00:00 1970 +0000 (long ago)</td></tr> | |||
|
105 | <tr> | |||
|
106 | <td class="metatag">permissions:</td> | |||
|
107 | <td>-rwxr-xr-x</td></tr> | |||
|
108 | <tr> | |||
|
109 | <td class="metatag">description:</td> | |||
|
110 | <td>a</td> | |||
|
111 | </tr> | |||
|
112 | </table> | |||
|
113 | ||||
|
114 | <br/> | |||
|
115 | ||||
|
116 | <table cellspacing="0" cellpadding="0"> | |||
|
117 | <tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l1">test@0</a></td><td><a class="lineno" href="#l1" id="l1"> 1</a></td><td><pre><span class="c">#!/usr/bin/env python</span></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l2">test@0</a></td><td><a class="lineno" href="#l2" id="l2"> 2</a></td><td><pre></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l3">test@0</a></td><td><a class="lineno" href="#l3" id="l3"> 3</a></td><td><pre><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></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l4">test@0</a></td><td><a class="lineno" href="#l4" id="l4"> 4</a></td><td><pre><span class="s">a subset of the headers plus the body of the result."""</span></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l5">test@0</a></td><td><a class="lineno" href="#l5" id="l5"> 5</a></td><td><pre></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l6">test@0</a></td><td><a class="lineno" href="#l6" id="l6"> 6</a></td><td><pre><span class="k">import</span> <span class="nn">httplib</span><span class="o">,</span> <span class="nn">sys</span></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l7">test@0</a></td><td><a class="lineno" href="#l7" id="l7"> 7</a></td><td><pre><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="k">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></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l8">test@0</a></td><td><a class="lineno" href="#l8" id="l8"> 8</a></td><td><pre><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></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l9">test@0</a></td><td><a class="lineno" href="#l9" id="l9"> 9</a></td><td><pre><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></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l10">test@0</a></td><td><a class="lineno" href="#l10" id="l10"> 10</a></td><td><pre><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></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l11">test@0</a></td><td><a class="lineno" href="#l11" id="l11"> 11</a></td><td><pre><span class="k">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></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l12">test@0</a></td><td><a class="lineno" href="#l12" id="l12"> 12</a></td><td><pre><span class="k">for</span> <span class="n">h</span> <span class="ow">in</span> <span class="n">headers</span><span class="p">:</span></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l13">test@0</a></td><td><a class="lineno" href="#l13" id="l13"> 13</a></td><td><pre> <span class="k">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></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l14">test@0</a></td><td><a class="lineno" href="#l14" id="l14"> 14</a></td><td><pre> <span class="k">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></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l15">test@0</a></td><td><a class="lineno" href="#l15" id="l15"> 15</a></td><td><pre><span class="k">print</span></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l16">test@0</a></td><td><a class="lineno" href="#l16" id="l16"> 16</a></td><td><pre><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">response</span><span class="o">.</span><span class="n">read</span><span class="p">())</span></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l17">test@0</a></td><td><a class="lineno" href="#l17" id="l17"> 17</a></td><td><pre></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l18">test@0</a></td><td><a class="lineno" href="#l18" id="l18"> 18</a></td><td><pre><span class="k">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></pre></td></tr><tr class="parity0"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l19">test@0</a></td><td><a class="lineno" href="#l19" id="l19"> 19</a></td><td><pre> <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></pre></td></tr><tr class="parity1"><td class="annotate"><a href="/annotate/79ee608ca36d/get-with-headers.py#l20">test@0</a></td><td><a class="lineno" href="#l20" id="l20"> 20</a></td><td><pre><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></pre></td></tr> | |||
|
118 | </table> | |||
|
119 | ||||
|
120 | ||||
|
121 | <div class="logo"> | |||
|
122 | <a href="http://www.selenic.com/mercurial/"> | |||
|
123 | <img src="/static/hglogo.png" width=75 height=90 border=0 alt="mercurial"></a> | |||
|
124 | </div> | |||
|
125 | ||||
|
126 | </body> | |||
|
127 | </html> | |||
|
128 | ||||
|
129 | % errors encountered |
@@ -107,6 +107,13 b' def has_unix_permissions():' | |||||
107 | finally: |
|
107 | finally: | |
108 | os.rmdir(d) |
|
108 | os.rmdir(d) | |
109 |
|
109 | |||
|
110 | def has_pygments(): | |||
|
111 | try: | |||
|
112 | import pygments | |||
|
113 | return True | |||
|
114 | except ImportError: | |||
|
115 | return False | |||
|
116 | ||||
110 | checks = { |
|
117 | checks = { | |
111 | "baz": (has_baz, "GNU Arch baz client"), |
|
118 | "baz": (has_baz, "GNU Arch baz client"), | |
112 | "cvs": (has_cvs, "cvs client"), |
|
119 | "cvs": (has_cvs, "cvs client"), | |
@@ -123,6 +130,7 b' checks = {' | |||||
123 | "symlink": (has_symlink, "symbolic links"), |
|
130 | "symlink": (has_symlink, "symbolic links"), | |
124 | "tla": (has_tla, "GNU Arch tla client"), |
|
131 | "tla": (has_tla, "GNU Arch tla client"), | |
125 | "unix-permissions": (has_unix_permissions, "unix-style permissions"), |
|
132 | "unix-permissions": (has_unix_permissions, "unix-style permissions"), | |
|
133 | "pygments": (has_pygments, "Pygments source highlighting library"), | |||
126 | } |
|
134 | } | |
127 |
|
135 | |||
128 | def list_features(): |
|
136 | def list_features(): |
General Comments 0
You need to be logged in to leave comments.
Login now