annotate commitwatcher/main.py @ 17:9ec036da252e

commitwatcher/agent.py
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 28 Sep 2013 10:19:12 -0700
parents 4cb3971d9d9d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
1 #!/usr/bin/env python
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
3
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
4 """
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
5 new service to monitor mozbase commits
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
6 """
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
7
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
8 import optparse
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
9 import os
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
10 import subprocess
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
11 import sys
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
12
2
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
13 from .agent import FeedAgent
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
14
0
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
15 def add_options(parser):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
16 """add options to the OptionParser instance"""
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
17
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
18 def main(args=sys.argv[1:]):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
19
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
20 # parse command line options
2
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
21 usage = '%prog [options] url://of.repository/'
0
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
22 class PlainDescriptionFormatter(optparse.IndentedHelpFormatter):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
23 """description formatter for console script entry point"""
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
24 def format_description(self, description):
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
25 if description:
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
26 return description.strip() + '\n'
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
27 else:
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
28 return ''
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
29 parser = optparse.OptionParser(usage=usage, description=__doc__, formatter=PlainDescriptionFormatter())
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
30 options, args = parser.parse_args(args)
2
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
31 if len(args) != 1:
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
32 parser.error("Please specify a single repository")
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
33 # TODO : multiple repos
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
34
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
35 repo = args[0]
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
36
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
37 # watch the damn thing
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
38 watcher = FeedAgent(repository=repo)
4cb3971d9d9d commitwatcher/__init__.py commitwatcher/agent.py commitwatcher/main.py setup.py commitwatcher/commit.py commitwatcher/store.py mozbasewatcher.py
Jeff Hammel <jhammel@mozilla.com>
parents: 0
diff changeset
39 watcher.update()
0
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
40
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
41 if __name__ == '__main__':
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
42 main()
Jeff Hammel <jhammel@mozilla.com>
parents:
diff changeset
43