00001
00002
00003 PKG = 'release'
00004 NAME='is_excluded.py'
00005 import roslib; roslib.load_manifest(PKG)
00006
00007 import os
00008 import sys
00009 import yaml
00010 import urllib2
00011
00012 from rosdistro import Distro
00013
00014 def load_distro(distro_name):
00015 distro_uri = "https://code.ros.org/svn/release/trunk/distros/%s.rosdistro"%(distro_name)
00016 return Distro(distro_uri)
00017
00018 def load_excluded(distro_name):
00019 try:
00020 uri = "https://code.ros.org/svn/release/trunk/distros/%s.excludes"%(distro_name)
00021 return yaml.load(urllib2.urlopen(uri)) or {}
00022 except urllib2.HTTPError:
00023
00024 return {}
00025
00026 def is_excluded(stack_name, distro_name, os_platform, os_arch):
00027 try:
00028 d = load_distro(distro_name)
00029 except:
00030 raise Exception("cannot load distro [%s]"%(distro_name))
00031 e = load_excluded(distro_name)
00032 if type(e) == dict:
00033 if stack_name in e:
00034 key = "%s-%s"%(os_platform, os_arch)
00035 if key in e[stack_name]:
00036 return True
00037 return False
00038
00039 def ex_main():
00040 from optparse import OptionParser
00041 parser = OptionParser(usage="usage: %prog <stack> <release-name> <os-platform> <os-arch>", prog=NAME)
00042 options, args = parser.parse_args()
00043 stack_name, distro_name, os_platform, os_arch = args
00044
00045 if is_excluded(stack_name, distro_name, os_platform, os_arch):
00046 print "excluded"
00047 sys.exit(1)
00048 else:
00049 print "not excluded"
00050
00051 if __name__ == '__main__':
00052 ex_main()