Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added a --server-only option to develop.py.

  • Loading branch information...
commit 8deaf2d37aab14e30d7d641dd554ce1fb96a2115 1 parent 91b32d3
@toolness authored
Showing with 28 additions and 17 deletions.
  1. +28 −17 develop.py
View
45 develop.py
@@ -20,7 +20,9 @@ def get_git_commit():
except Exception:
return "unknown"
+HOST = 'localhost'
PORT = 8888
+BASE_URL = 'http://%s:%d/' % (HOST, PORT)
ROOT = os.path.abspath(os.path.dirname(__file__))
path = lambda *x: os.path.join(ROOT, *x)
@@ -32,30 +34,39 @@ def get_git_commit():
SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map.update(types)
-def run(server_class=BaseHTTPServer.HTTPServer,
- handler_class=SimpleHTTPServer.SimpleHTTPRequestHandler,
- port=PORT):
+def run_web_server(server_class=BaseHTTPServer.HTTPServer,
+ handler_class=SimpleHTTPServer.SimpleHTTPRequestHandler):
os.chdir(path('website'))
- server_address = ('', port)
- print "Serving files in '%s' on port %d." % (os.getcwd(), port)
+ server_address = (HOST, PORT)
+ print "Serving files in '%s' at %s." % (os.getcwd(), BASE_URL)
httpd = server_class(server_address, handler_class)
httpd.serve_forever()
-if __name__ == '__main__':
- if 'CUDDLEFISH_ROOT' not in os.environ:
- print "WARNING: You don't seem to have the Add-on SDK activated. To learn how to activate it, visit: https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/addon-development/installation.html"
- print
- t = threading.Thread(target=run)
- t.setDaemon(True)
- t.start()
-
+def write_deployment_json():
dep = open(path('data', 'deployment.json'), 'w')
dep.write(json.dumps({
'name': 'development',
'commit': get_git_commit(),
- 'url': 'http://localhost:%d/' % PORT,
- 'xpi_url': 'http://localhost:%d/xpi/' % PORT
+ 'url': BASE_URL,
+ 'xpi_url': BASE_URL + 'xpi/'
}))
dep.close()
-
- sys.exit(subprocess.call(['cfx', 'run'] + sys.argv[1:], cwd=ROOT))
+
+def run_firefox(args):
+ if 'CUDDLEFISH_ROOT' not in os.environ:
+ print "WARNING: You don't seem to have the Add-on SDK activated. To learn how to activate it, visit: https://addons.mozilla.org/en-US/developers/docs/sdk/latest/dev-guide/addon-development/installation.html"
+ print
+ return subprocess.call(['cfx', 'run'] + args, cwd=ROOT)
+
+if __name__ == '__main__':
+ write_deployment_json()
+ if '--help' in sys.argv or '-h' in sys.argv:
+ print "usage: %s [--server-only] [cfx options]" % sys.argv[0]
+ sys.exit(1)
+ if '--server-only' in sys.argv:
+ run_web_server()
+ else:
+ t = threading.Thread(target=run_web_server)
+ t.setDaemon(True)
+ t.start()
+ sys.exit(run_firefox(sys.argv[1:]))
Please sign in to comment.
Something went wrong with that request. Please try again.