Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: kick.py

Issue 6569732794744832: Issue 2200 - PART I/II - Migrate to argparse (Closed)
Left Patch Set: Issue 2200 - PART I/II - Migrate to argparse Created April 7, 2015, 3:36 p.m.
Right Patch Set: Issue 2200 - PART I/II - Migrate to argparse Created April 7, 2015, 3:55 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | run.py » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 import sys 4 import sys
5 import getopt 5 import getopt
6 from run import resolveHostList, runCommand, createArgumentParser 6 from run import resolveHostList, runCommand, createArgumentParser
7 7
8 def parseOptions(args): 8 def parseOptions(args):
9 description = 'Run provisioning on the given hosts or groups of hosts' 9 description = 'Run provisioning on the given hosts or groups of hosts'
10 parser = createArgumentParser(description=description) 10 parser = createArgumentParser(description=description)
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 ]) 46 ])
47 runCommand(user, 'puppetmaster.adblockplus.org', remoteCommand) 47 runCommand(user, 'puppetmaster.adblockplus.org', remoteCommand)
48 48
49 def updateClient(user, host, mode): 49 def updateClient(user, host, mode):
50 print 'Provisioning %s...' % host 50 print 'Provisioning %s...' % host
51 remoteCommand = 'sudo puppet agent%s' % mode 51 remoteCommand = 'sudo puppet agent%s' % mode
52 52
53 # Have to ignore errors here, Puppet will return non-zero for successful runs 53 # Have to ignore errors here, Puppet will return non-zero for successful runs
54 runCommand(user, host, remoteCommand, ignore_errors=True) 54 runCommand(user, host, remoteCommand, ignore_errors=True)
55 55
56 if __name__ == "__main__": 56 if __name__ == '__main__':
Wladimir Palant 2015/04/07 15:50:25 Nit: We should use single quotes here as well if y
mathias 2015/04/07 15:56:22 Done.
57 options = parseOptions(sys.argv[1:]) 57 options = parseOptions(sys.argv[1:])
58 needKicking = resolveHostList(options.hosts) 58 needKicking = resolveHostList(options.hosts)
59 if len(needKicking) == 0: 59 if len(needKicking) == 0:
60 print >>sys.stderr, 'No valid hosts or groups specified, nothing to do' 60 print >>sys.stderr, 'No valid hosts or groups specified, nothing to do'
61 sys.exit(0) 61 sys.exit(0)
62 updateMaster(options.user) 62 updateMaster(options.user)
63 for host in needKicking: 63 for host in needKicking:
64 updateClient(options.user, host, options.mode) 64 updateClient(options.user, host, options.mode)
LEFTRIGHT
« no previous file | run.py » ('j') | Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Toggle Comments ('s')

Powered by Google App Engine
This is Rietveld