-
Notifications
You must be signed in to change notification settings - Fork 20
/
pasta
executable file
·202 lines (175 loc) · 6.29 KB
/
pasta
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
#!/usr/bin/env python3
"""
PaStA - Patch Stack Analysis
A tool for tracking the evolution of patch stacks
Copyright (c) OTH Regensburg, 2016-2020
Author:
Ralf Ramsauer <[email protected]>
This work is licensed under the terms of the GNU GPL, version 2. See
the COPYING file in the top-level directory.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
"""
import errno
import logging
import sys
from copy import deepcopy
from pypasta import Config
from bin.pasta_analyse import analyse
from bin.pasta_check_connectivity import check_connectivity
from bin.pasta_check_mbox import check_mbox
from bin.pasta_clusterstats import clusterstats
from bin.pasta_compare import compare
from bin.pasta_compare_clusters import compare_clusters
from bin.pasta_maintainers_stats import maintainers_stats
from bin.pasta_optimise_cluster import optimise_cluster
from bin.pasta_prepare_evaluation import prepare_evaluation
from bin.pasta_rate import rate
from bin.pasta_ripup import ripup
from bin.pasta_show_cluster import show_cluster
from bin.pasta_statistics import statistics
from bin.pasta_sync import sync
from bin.pasta_compare_stacks import compare_stacks
from bin.pasta_patch_descriptions import patch_descriptions
from bin.pasta_upstream_duration import upstream_duration
from bin.pasta_upstream_history import pasta_upstream_history
from bin.pasta_web import web
from bin.pasta_form_patchwork_relations import form_patchwork_relations
from bin.pasta_compare_getmaintainers import compare_getmaintainers
__author__ = 'Ralf Ramsauer'
__copyright__ = 'Copyright (c) OTH Regensburg, 2016-2017'
__credits__ = ['Ralf Ramsauer']
__license__ = 'GPLv2'
__version__ = '0.3'
__maintainer__ = 'Ralf Ramsauer'
__email__ = '[email protected]'
__status__ = 'Development'
log = logging.getLogger('PaStA')
config = None
def usage(me, exit_code=errno.EINVAL):
file = sys.stdout
if exit_code != 0:
file = sys.stderr
print('PaStA - The Patch Stack Analysis (PaStA %s)\n'
'\n'
'usage: %s [-d] [-c project_name] sub [-h|--help]\n'
'where sub is one of:\n'
' analyse\n'
' check_connectivity\n'
' check_mbox\n'
' compare\n'
' form_patchwork_relations\n'
' maintainers_stats\n'
' optimise_cluster\n'
' prepare_evaluation\n'
' rate\n'
' sync\n'
' set_config\n'
' show_cluster\n'
' statistics\n'
' compare_stacks\n'
' compare_clusters\n'
' patch_descriptions\n'
' ripup\n'
' upstream_history\n'
' web\n'
' compare_getmaintainers\n'
'\n'
'If -c is not provided, PaStA will choose ./config as config file\n'
'\n'
'%s\n'
'Licensed under %s (See COPYING)\n'
'This is free software: you are free to change and redistribute it.\n'
'There is NO WARRANTY, to the extent permitted by law.\n'
'\n'
'Written by %s.' %
(__version__, me, __copyright__, __license__, __author__), file=file)
sys.exit(exit_code)
def main(argv):
project_name = None
me = argv.pop(0)
level = logging.INFO
while len(argv) and argv[0].startswith('-'):
argument = argv.pop(0)
if argument == '-c':
if not argv:
usage(me)
project_name = argv.pop(0)
elif argument == '-d':
level = logging.DEBUG
fmt = '%(asctime)-15s %(name)-15s %(levelname)-8s %(message)s'
logging.basicConfig(level=level, stream=sys.stdout, format=fmt)
filehandler = logging.FileHandler(filename='./log', mode='a')
filehandler.setFormatter(logging.Formatter(fmt))
logging.getLogger().addHandler(filehandler)
log.info('Cmdline: ' + ' '.join(sys.argv))
if not project_name:
with open('./config', 'r') as f:
project_name = f.read().strip()
if not argv:
usage(me)
sub = argv.pop(0)
if sub == 'compare_clusters':
return compare_clusters(argv)
if sub == 'optimise_cluster':
return optimise_cluster(argv)
if sub == 'set_config':
project_name = argv[0]
try:
config = Config(project_name)
except Exception as e:
log.error('Unable to load configuration %s:' % project_name)
log.error(' %s' % str(e))
return -1
config.set_config()
return 0
config = Config(project_name)
if sub == '-h' or sub == '--help':
usage(me, 0)
elif sub == 'analyse':
return analyse(config, argv)
elif sub == 'check_connectivity':
return check_connectivity(config, argv)
elif sub == 'check_mbox':
return check_mbox(config, argv)
elif sub == 'clusterstats':
return clusterstats(config, argv)
elif sub == 'compare':
return compare(config, argv)
elif sub == 'prepare_evaluation':
return prepare_evaluation(config, argv)
elif sub == 'rate':
return rate(config, argv)
elif sub == 'statistics':
return statistics(config, argv)
elif sub == 'compare_stacks':
return compare_stacks(config, argv)
elif sub == 'form_patchwork_relations':
return form_patchwork_relations(config, argv)
elif sub == 'maintainers_stats':
return maintainers_stats(config, argv)
elif sub == 'patch_descriptions':
return patch_descriptions(config, argv)
elif sub == 'ripup':
return ripup(config, argv)
elif sub == 'show_cluster':
return show_cluster(config, argv)
elif sub == 'sync':
return sync(config, argv)
elif sub == 'upstream_history':
return pasta_upstream_history(config, argv)
elif sub == 'upstream_duration':
return upstream_duration(config, argv)
elif sub == 'web':
return web(config, argv)
elif sub == 'compare_getmaintainers':
return compare_getmaintainers(config, argv)
else:
print('Unknown command: %s' % sub)
usage(me)
if __name__ == '__main__':
ret = main(deepcopy(sys.argv))
log.info('Shutting down')
sys.exit(ret if ret else 0)