/
test_count_deps.py
executable file
·54 lines (38 loc) · 1.36 KB
/
test_count_deps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#! /usr/bin/env python
import jenkins_cache
import urllib
import yaml
import sys
import os
import time
import count_deps
from rospkg import environment
def main():
if len(sys.argv) < 2:
print "Usage: %s cache_dir job1 job2 job3 ..."%(sys.argv[0])
sys.exit(0)
cache_dir_orig = sys.argv[1]
cache_dir = os.path.expanduser(cache_dir_orig)
job_list = sys.argv[2:]
# create jenkins instance
with open(os.path.join(environment.get_ros_home(), 'catkin-debs', 'server.yaml')) as f:
info = yaml.load(f)
#jenkins_url = 'http://jenkins.willowgarage.com:8080/'
jenkins_url = 'http://50.28.61.61:8080/'
cache = jenkins_cache.JenkinsCache(jenkins_url, cache_dir, info['username'], info['password'])
print "Created Jenkins cache instance"
num_deps, deps = count_deps.count_deps(cache, job_list)
depth_counts = {}
for depth in deps.values():
depth_counts[depth] = depth_counts.get(depth, 0) + 1
max_depth = max(depth_counts.keys())
for depth in range(max_depth):
depth_counts[depth] = depth_counts.get(depth, 0)
print "Calculated deps for:"
print "".join([ "%s\n" % x for x in job_list ])
print "Found %i total deps" % num_deps
print "Depth Counts:"
for depth, count in depth_counts.items():
print "%i) %i" % (depth, count)
if __name__ == "__main__":
main()