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

Side by Side Diff: client/third_party/infra_libs/event_mon/checkouts.py

Issue 2673613003: luci-py: Roll infra_libs. (Closed)
Patch Set: rolll Created 3 years, 10 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
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 # Functions in this file relies on depot_tools been checked-out as a sibling 5 # Functions in this file relies on depot_tools been checked-out as a sibling
6 # of infra.git. 6 # of infra.git.
7 7
8 import logging
9 import os
10 import re 8 import re
11 import subprocess
12
13
14 BASE_DIR = os.path.dirname(
15 os.path.dirname(
16 os.path.dirname(
17 os.path.dirname(os.path.realpath(__file__)))))
18 9
19 10
20 def parse_revinfo(revinfo): 11 def parse_revinfo(revinfo):
21 """Parse the output of "gclient revinfo -a" 12 """Parse the output of "gclient revinfo -a"
22 13
23 Args: 14 Args:
24 revinfo (str): string containing gclient stdout. 15 revinfo (str): string containing gclient stdout.
25 16
26 Returns: 17 Returns:
27 revinfo_d (dict): <directory>: (URL, revision) 18 revinfo_d (dict): <directory>: (URL, revision)
(...skipping 11 matching lines...) Expand all
39 url, revision = revision_expr.match(line).groups() 30 url, revision = revision_expr.match(line).groups()
40 revision = revision.strip() 31 revision = revision.strip()
41 else: 32 else:
42 # Split at the last @ 33 # Split at the last @
43 url, revision = line.strip(), None 34 url, revision = line.strip(), None
44 35
45 path = path.strip() 36 path = path.strip()
46 url = url.strip() 37 url = url.strip()
47 revinfo_d[path] = {'source_url': url, 'revision': revision} 38 revinfo_d[path] = {'source_url': url, 'revision': revision}
48 return revinfo_d 39 return revinfo_d
49
50
51 def get_revinfo(cwd=None): # pragma: no cover
52 """Call gclient to get the list of all revisions actually checked out on disk.
53
54 gclient is expected to be under depot_tools/ sibling to infra/.
55 If gclient can't be found or fail to run returns {}.
56
57 Args:
58 cwd (str): working directory where to run gclient. If None, use the
59 current working directory.
60 Returns:
61 revinfo (dict): keys are local paths, values are dicts with keys:
62 'source_url' or 'revision'.
63 """
64
65 cmd = [os.path.join(BASE_DIR, 'depot_tools', 'gclient'), 'revinfo', '-a']
66 logging.debug('Running: %s', ' '.join(cmd))
67 revinfo = ''
68 try:
69 revinfo = subprocess.check_output(cmd, cwd=cwd)
70 except (subprocess.CalledProcessError, OSError):
71 logging.exception('Command failed to run: %s', ' '.join(cmd))
72 return parse_revinfo(revinfo)
OLDNEW
« no previous file with comments | « client/third_party/infra_libs/event_mon/__init__.py ('k') | client/third_party/infra_libs/ts_mon/common/interface.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698