Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Side by Side Diff: scripts/tools/make_manhole.py

Issue 2084383003: Move 'buildbot.tac' and 'buildbot' files to a common directory. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/build.git@master
Patch Set: Don't ignore .new Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 """Generate a .manhole for all masters."""
7
8 import getpass
9 import os
10 import optparse
11 import subprocess
12 import sys
13
14
15 def check_output(cmd):
16 p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
17 stdout = p.communicate(None)[0]
18 if p.returncode:
19 raise subprocess.CalledProcessError(p.returncode, cmd)
20 return stdout
21
22
23 def main():
24 parser = optparse.OptionParser()
25 parser.add_option('-u', '--user', default=getpass.getuser())
26 parser.add_option('-p', '--port', type='int', help='Base port')
27 parser.add_option('-r', '--root', default=os.getcwd(), help='Path to masters')
28 options, args = parser.parse_args(None)
29
30 if args:
31 parser.error('Have you tried not using the wrong argument?')
32 if not options.port:
33 parser.error('Use --port to specify a base port')
34 if not os.path.basename(options.root) == 'masters':
35 parser.error('Use --root or cd into the masters directory')
36
37 try:
38 check_output(['apg', '-q', '-n', '1'])
39 except subprocess.CalledProcessError:
40 parser.error('Run sudo apt-get install apg')
41
42 for i in os.listdir(options.root):
43 if i.startswith('.'):
44 continue
45 dirpath = os.path.join(options.root, i)
46 if not os.path.isdir(dirpath):
47 continue
48 if not os.path.isfile(os.path.join(dirpath, 'buildbot.tac')):
49 print '%-30s has no buildbot config' % i
50 continue
51 filepath = os.path.join(dirpath, '.manhole')
52 if os.path.isfile(filepath):
53 print '%-30s already had .manhole' % i
54 continue
55 print '%-30s Generating password' % i
56 password = check_output(['apg', '-q', '-n', '1']).strip()
57 content = "user='%s'\npassword='/!%s'\nport=%d\n" % (
58 options.user, password, options.port)
59 options.port += 1
60 open(filepath, 'w').write(content)
61 return 0
62
63
64 if __name__ == '__main__':
65 sys.exit(main())
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698