-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfabfile.py
More file actions
168 lines (130 loc) · 3.87 KB
/
fabfile.py
File metadata and controls
168 lines (130 loc) · 3.87 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
from fabric.api import *
from fabric.contrib.console import confirm
from sh import git as _git
import os
import webbrowser
import platform
import sys
#
# SETTING THE BROWSER BASED ON PLATFORM
#
browser = "firefox"
if sys.platform == 'darwin':
browser = "open"
#
# VERSION MANAGEMENT
#
#
# we are no longer doing version management with the VERSION.txt file,
# but instead including it in setup.py we need to change the code
# here, so do not use the version increment
#
#filename = "VERSION.txt"
#version = open(filename).read()
SERVER = "server"
"""
def _next_version(version):
numbers = version.split(".")
numbers[-1] = str(int(numbers[-1]) + 1)
newversion = ".".join(numbers)
return newversion
def _write_version(version):
file = open(filename, 'w')
print >> file, version
file.close()
"""
def _cleantest():
"""wipe out the database and rerun the test. not recommended."""
local("python cloud_mesh.py")
cm()
def cm():
"""run the server and look at the output with the browser"""
file = open("Makefile~", "w")
print >> file, """
all: server view
server:
python flask_cm/server.py
view:
sleep 10
%s http://127.0.0.1:5000/table/
""" % browser
#webbrowser.open("http://127.0.0.1:5000")
file.close()
os.system("make -j -f Makefile~ all")
def deltag(tag):
local("git tag -d %s" % tag)
local("git push origin :refs/tags/%s" % tag)
def view():
"""run the browser"""
local("sleep 1")
local("%s http://localhost:5000/table" % browser)
def clean():
"""clean the directory"""
local("find . -name \"#*\" -exec rm {} \\;")
local("find . -name \"*~\" -exec rm {} \\;")
local("find . -name \"*.pyc\" -exec rm {} \\;")
local("rm -rf build dist *.egg-info")
local("rm -rf doc/build ")
def git():
"""upload the changes to git"""
clean()
_git("add", ".")
os.system("git commit")
_git("push")
'''
def tag():
"""introduce a new tag and upload it to git. run fab changes first and
add that to CHANGES.txt"""
global version
local("make clean")
new_version = _next_version(version)
_write_version(new_version)
_git("add", ".")
_git("tag", "%s" % new_version)
_git("commit", "-m", "adding version %s" % new_version)
_git("push")
changes()
'''
def changes():
"""look at the changes in github since the last taged version"""
gitversion = _git("describe", "--abbrev=0", "--tags").strip()
tags = _git("tag").split("\n")
tags = tags[:-1]
versions = {'previous': tags[-1],
'head': 'HEAD',
'next': _next_version(tags[-1])}
print versions
headline = "CHANGES %(previous)s -> %(next)s" % versions
print headline
print len(headline) * "="
print
change = _git("log",
"%(previous)s...%(head)s" % versions,
"--no-merges", "--format=* %B")
change = change.replace("\n\n", "\n")
print change
def dist():
clean()
local("python setup.py sdist")
def force():
dist()
local("pip install -U dist/*.tar.gz")
def pypi():
force()
# python setup.py register
local("python setup.py sdist upload")
def install():
"""install Flask Frozen-Flask Flask-FlatPages"""
local("pip install Flask Frozen-Flask Flask-FlatPages")
local(
"pip install --upgrade -e git://github.com/openstack/python-novaclient.git#egg=python-novaclient")
def installmongodb():
local('ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"')
local('brew update')
local('brew install mongodb')
def installmongodb_ubuntu():
local('sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10')
local(
'sudo sh -c "echo \'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen\' > /etc/apt/sources.list.d/10gen.list"')
local('sudo apt-get update')
local('sudo apt-get install mongodb-10gen')