#!/usr/bin/pythonfrom ConfigParser import ConfigParserfrom urllib import FancyURLopenerimport osimport redef checkConfig(): config=ConfigParser() if config.read(os.path.expanduser('~/.fever')) == []: print "Config file (%s) does not exist.\nPlease create it." % os.path.expanduser('~/.fever') raise SystemExit, 1 for section in [section for section in config.sections() if section != 'global']: if 'site' and 'filename' not in config.options(section): print '%s section is incorrect.\nYou have to add "site" or "filename" option.' % section raise SystemExit, 1 ret={} for section in config.sections(): ret[section]=config.items(section) return ret #print 'Checking %s' % section #file=download(config.get(section,'site')) #reg=re.compile(config.get(section,'filename')) #search=reg.findall(file) #search.sort() #print 'The newest version of %s is %s' % (section,search[search.__len__()-1])def download(address): url=FancyURLopener() file=url.open(address).read() return fileif __name__ == "__main__": checkconfig=checkConfig() #sections=[section for section in checkconfig.items() if section != 'global'] versions={} for (name, values) in checkconfig.items(): for (varname,varval) in values: globals()[varname]=varval if name == "global": continue #print 'Checking %s' % name file=download(site) reg=re.compile(filename) search=reg.findall(file) search.sort() version=search[search.__len__()-1] versions[name]=version if globals().has_key(repourl) != True: repourl='http://fedoraproject.org/extras/development/SRPMS/' reposite=download(repourl) for name in versions.keys(): reg=re.compile("%s-(.*?)-.*?.src.rpm" % name) version=reg.search(reposite).group(1) if version != versions[name]: print 'The newest version of %s (%s) is available in repo.' % (name,version) else: print 'You have to update %s! Repo version is %s, but %s is available.' % (name,version,versions[name])