forked from toolness/hackasaurus-puppet-data
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path__init__.py
71 lines (56 loc) · 1.89 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import sys
import os
import imp
from fabric.context_managers import cd
from fabric.utils import abort
from fabric.api import task, env
from fabric.operations import run, put
from fabric.contrib.project import upload_project
from . import testing, hackpub, jsbin, secrets
ROOT = os.path.abspath(os.path.dirname(__file__))
def path(*x):
return os.path.join(ROOT, *x)
def import_fabfile(pathname):
fabfilename = os.path.join(pathname, 'fabfile.py')
fabfile = open(fabfilename)
desc = ('.py', 'r', imp.PY_SOURCE)
modname = os.path.basename(pathname)
module = imp.load_module(modname, fabfile, fabfilename, desc)
fabfile.close()
return module
htmlpad = import_fabfile(path('..', 'htmlpad'))
hackasaurus = import_fabfile(path('..', 'hackasaurus.org'))
webxray = import_fabfile(path('..', 'webxray'))
@task
def configure():
"configure the Hackasaurus server"
secrets.build_secrets_manifest(env['host'])
run('rm -rf /root/deployment')
run('mkdir /root/deployment')
with cd('/root/deployment'):
upload_project(path('..', 'manifests'))
upload_project(path('..', 'modules'))
put(path('run-on-server', 'bootstrap.py'), '.')
run('python bootstrap.py')
@task
def deploy():
"deploy the entire Hackasaurus server and all its apps"
configure()
hackasaurus.deploy()
htmlpad.deploy()
hackpub.deploy()
webxray.deploy()
@task
def test(run=None):
"""
test the Hackasaurus server
Examples:
fab -H baz.org test run all tests on baz.org.
fab -H baz.org test:MyTestSuite run suite 'MyTestSuite'.
fab -H baz.org test:MyTest.testFoo run MyTest.testFoo.
"""
if env['host'] is None:
abort('please specify a host.')
result = testing.run_tests(defaultTest=run, verbosity=2)
if not result.wasSuccessful():
abort('some tests failed on %s.' % env['host'])