~gary/charms/oneiric/buildbot-slave/run-as-buildbot

« back to all changes in this revision

Viewing changes to tests/open-port.py

  • Committer: Graham Binns
  • Date: 2012-02-07 13:50:37 UTC
  • mfrom: (3.4.9 bbs)
  • Revision ID: graham@canonical.com-20120207135037-6jrkd32hse6e1dg8
Merged Brad's branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
 
 
3
# Copyright 2012 Canonical Ltd.  This software is licensed under the
 
4
# GNU Affero General Public License version 3 (see the file LICENSE).
 
5
 
 
6
# A little python script to open a port on the buildslave so that we can
 
7
# test that it's actually deployed successfully.
 
8
 
 
9
import subprocess
 
10
import SimpleHTTPServer
 
11
import SocketServer
 
12
 
 
13
PORT = 9000
 
14
 
 
15
simple_html = """
 
16
<html>
 
17
    <head>
 
18
        <title>Here's some HTML</title>
 
19
    </head>
 
20
    <body><p>The slave is UP!</p></body>
 
21
</html>
 
22
"""
 
23
 
 
24
with open('/tmp/index.html', 'w') as index_file:
 
25
    index_file.write(simple_html)
 
26
 
 
27
subprocess.call(['open-port', '9000/TCP'])
 
28
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
 
29
httpd = SocketServer.TCPServer(("", PORT), Handler)
 
30
#httpd.serve_forever()
 
31
print "HERE I AM!!!"