This repository has been archived by the owner on Apr 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathramona-dev.py
executable file
·108 lines (88 loc) · 2.97 KB
/
ramona-dev.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
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
#!/usr/bin/env python
#
# Released under the BSD license. See LICENSE.txt file for details.
#
import os
import sys
import fnmatch
import shutil
import ramona
class RamonaDevConsoleApp(ramona.console_app):
@ramona.tool
def clean(self):
"""Clean project directory from intermediate files (*.pyc)"""
for root, dirnames, filenames in os.walk('.'):
for filename in fnmatch.filter(filenames, '*.pyc'):
filename = os.path.join(root, filename)
if not os.path.isfile(filename): continue
os.unlink(filename)
try:
shutil.rmtree('dist')
except:
pass
try:
shutil.rmtree('build')
except:
pass
for f in ['MANIFEST', 'demo_history', 'ramonadev_history']:
try:
os.unlink(f)
except:
pass
@ramona.tool
def unittests(self):
"""Seek for all unit tests and execute them"""
import unittest
tl = unittest.TestLoader()
ts = tl.discover('.', '__utest__.py')
tr = unittest.runner.TextTestRunner(verbosity=2)
res = tr.run(ts)
return 0 if res.wasSuccessful() else 1
@ramona.tool
def sdist(self):
"""Prepare the distribution package"""
os.execl(sys.executable, sys.executable, 'setup.py', 'sdist', '--formats=gztar,zip', '--owner=root', '--group=root')
@ramona.tool
def upload_test(self):
"""Upload (register) a new version to TestPyPi"""
os.system("LC_ALL=en_US.UTF-8 {0} setup.py \
sdist --formats=gztar,zip --owner=root --group=root \
register -r http://testpypi.python.org/pypi \
upload -r http://testpypi.python.org/pypi \
".format(sys.executable)
)
@ramona.tool
def upload(self):
"""Upload (register) a new version to PyPi"""
os.system("LC_ALL=en_US.UTF-8 {0} setup.py \
sdist --formats=gztar,zip --owner=root --group=root \
register -r http://pypi.python.org/pypi \
upload -r http://pypi.python.org/pypi \
".format(sys.executable)
)
@ramona.tool
def version(self):
"""Returns the Ramona version number"""
print ramona.version
@ramona.tool
def manual(self):
"""Build a HTML version of the manual"""
if os.path.isdir('docs/manual/_build'):
shutil.rmtree('docs/manual/_build')
os.system('LC_ALL=en_US.UTF-8 make -C docs/manual html')
@ramona.tool
def gource(self):
"""Creates visualizations about the Ramona development"""
import subprocess, re
cmd= r"""git log --pretty=format:user:%aN%n%ct --reverse --raw --encoding=UTF-8 --no-renames"""
gitlog = subprocess.check_output(cmd, shell=True)
gitlog = re.sub(r'\nuser:Ales Teska\n','\nuser:ateska\n',gitlog)
gitlog = re.sub(r'\nuser:Jan Stastny\n','\nuser:jstastny\n',gitlog)
cmd = r"""gource -1280x720 --stop-at-end --highlight-users --seconds-per-day .5 --title "Ramona" --log-format git -o - -"""
cmd += " | "
cmd += r"ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 16 -threads 0 -bf 0 gource.mp4"
x = subprocess.Popen(cmd, stdin=subprocess.PIPE, shell=True)
x.communicate(gitlog)
if __name__ == '__main__':
app = RamonaDevConsoleApp(configuration='./ramona.conf')
app.run()