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

Unified Diff: infra/services/gsubtreed/__main__.py

Issue 477623003: Add git subtree daemon service. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@add_dtree_support
Patch Set: address comments Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « infra/services/gsubtreed/__init__.py ('k') | infra/services/gsubtreed/gsubtreed.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra/services/gsubtreed/__main__.py
diff --git a/infra/services/gnumbd/__main__.py b/infra/services/gsubtreed/__main__.py
similarity index 66%
copy from infra/services/gnumbd/__main__.py
copy to infra/services/gsubtreed/__main__.py
index 74570d686a2641122d81e70247261dc24cec3500..f3a9b66f459698fb0e62dbbae7bc2b46d909cf34 100644
--- a/infra/services/gnumbd/__main__.py
+++ b/infra/services/gsubtreed/__main__.py
@@ -6,15 +6,13 @@ import argparse
import collections
import json
import os
-import sys
import urlparse
from infra.libs import git2
-from infra.libs import infra_types
from infra.libs import logs
from infra.libs.service_utils import outer_loop
-from infra.services.gnumbd import gnumbd
+from infra.services.gsubtreed import gsubtreed
# Return value of parse_args.
@@ -31,10 +29,10 @@ def parse_args(args): # pragma: no cover
raise argparse.ArgumentTypeError('URL is missing a path?')
return git2.Repo(s)
- parser = argparse.ArgumentParser('python -m %s' % __package__)
+ parser = argparse.ArgumentParser('./run.py %s' % __package__)
parser.add_argument('--dry_run', action='store_true',
help='Do not actually push anything.')
- parser.add_argument('--repo_dir', metavar='DIR', default='gnumbd_repos',
+ parser.add_argument('--repo_dir', metavar='DIR', default='gsubtreed_repos',
help=('The directory to use for git clones '
'(default: %(default)s)'))
parser.add_argument('--json_output', metavar='PATH',
@@ -58,23 +56,16 @@ def parse_args(args): # pragma: no cover
def main(args): # pragma: no cover
opts = parse_args(args)
- cref = gnumbd.GnumbdConfigRef(opts.repo)
+ cref = gsubtreed.GsubtreedConfigRef(opts.repo)
opts.repo.reify()
- all_commits = []
+ summary = collections.defaultdict(int)
def outer_loop_iteration():
- success, commits = gnumbd.inner_loop(opts.repo, cref)
- all_commits.extend(commits)
+ success, paths_counts = gsubtreed.inner_loop(opts.repo, cref)
+ for path, count in paths_counts.iteritems():
+ summary[path] += count
return success
- # TODO(iannucci): sleep_timeout should be an exponential backon/off.
- # Whenever we push, we should decrease the interval at 'backon_rate'
- # until we hit 'min_interval'.
- # Whenever we fail/NOP, we should back off at 'backoff_rate' until we
- # hit 'max_interval'.
- #
- # When all is going well, this should be looping at < 1 sec. If things
- # start going sideways, we should automatically back off.
loop_results = outer_loop.loop(
task=outer_loop_iteration,
sleep_timeout=lambda: cref['interval'],
@@ -84,16 +75,7 @@ def main(args): # pragma: no cover
with open(opts.json_output, 'w') as f:
json.dump({
'error_count': loop_results.error_count,
- 'synthesized_commits': [
- {
- 'commit': c.hsh,
- 'footers': infra_types.thaw(c.data.footers),
- } for c in all_commits
- ],
+ 'summary': summary,
}, f)
- return 0 if loop_results.success else 1
-
-
-if __name__ == '__main__':
- sys.exit(main(sys.argv[1:]))
+ return 0 if loop_results.success else 1
« no previous file with comments | « infra/services/gsubtreed/__init__.py ('k') | infra/services/gsubtreed/gsubtreed.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698