import copy import sys import catalog import cookielib import platform import ourlogging #We emulate Mozilla Firefox on Windows 7 64 bit as our UA red=urllib2.HTTPRedirectHandler() userAgent=[('User-Agent',' Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20100101 Firefox/15.0')] cj = cookielib.CookieJar() opener=urllib2.build_opener(urllib2.HTTPCookieProcessor(cj),red) opener.addheaders=userAgent ourlogging.config() logger = ourlogging.logger("utils") def getPage(url): """Returns the contents of a url as a string. This currently doesn't do anything to handle exceptions. @param url The url to grab a page from. @return A string containing the page contents of url. """ try: opener.addheaders=userAgent + [('Referer', url)] f=opener.open(url) page = f.read() f.close()
import os, sys, argparse import catalog, utils import ourlogging logger = ourlogging.logger("command") def all_packages(): return catalog.full_list class Packages(): @staticmethod def calc_packages(args): if args['all-except']: return list(set(all_packages()) - set(args['packages'])) else: return args['packages'] def __init__(self, args): self.packages = self.calc_packages(args) self.args = args def dofor(self, func): #TODO make parallel version d = {} for p in self.packages: d[p] = func(p, self.args) return d def find_file(package, location): # read through all the file names.