Skip to content

Commit

Permalink
Adding a simple script to count packagse and return if over a threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
tfoote committed Sep 14, 2012
1 parent 0234019 commit 6c611c4
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
42 changes: 42 additions & 0 deletions scripts/count_ros_packages.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#!/usr/bin/env python

import argparse
import buildfarm.repo
import sys

def parse_options():
parser = argparse.ArgumentParser(description="List all packages available in the repos for each arch. Filter on substring if provided")
parser.add_argument("rosdistro",
help='The ros distro. electric, fuerte, groovy')
parser.add_argument("distro",
help='Ubuntu distro lucid, precise, etc')
parser.add_argument("arch",
help='The arch amd63 i386')
parser.add_argument('--repo', dest='repo_url', action='store', default='http://50.28.27.175/repos/building',
help='The repo url')

parser.add_argument('--count', dest='count', action='store', default=100,
help='Min numberof packages')

args = parser.parse_args()


return args


if __name__ == "__main__":
args = parse_options()



count = buildfarm.repo.count_packages(args.repo_url, args.rosdistro, args.distro, args.arch)
print "Found %d packages matching: %s" % (count, args)

if count > args.count:
print "Count greater than argument, return True"
sys.exit(0)
else:
print "Count not greater than argument, return False"
sys.exit(1)


5 changes: 5 additions & 0 deletions src/buildfarm/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ def get_repo_version(repo_url, distro, os_platform, arch, source=False):
return max(['0'] + [x[1][x[1].find('-')+1:x[1].find('~')] for x in packagelist if x[3] == distro.release_name])


def count_packages(repo_url, rosdistro, os_platform, arch, cache=None):
packagelist = get_Packages(repo_url, os_platform, arch, cache)
M = re.findall('^Package: ros-%s-.*$' % (rosdistro), packagelist, re.MULTILINE)
return len(M)

def deb_in_repo(repo_url, deb_name, deb_version, os_platform, arch, use_regex=True, cache=None, source=False):
"""
@param cache: dictionary to store Packages list for caching
Expand Down

0 comments on commit 6c611c4

Please sign in to comment.