示例#1
0
    def setUp(self):
        self.local_path = self.makeDir()
        self.fetcher = Fetcher()
        self.fetcher.setLocalPathPrefix(self.local_path + "/")

        # Smart changes SIGPIPE handling due to a problem which otherwise
        # happens when running external scripts.  Check out smart/__init__.py.
        # We want the normal handling here because in some cases we may
        # get SIGPIPE due to broken sockets on tests.
        signal.signal(signal.SIGPIPE, signal.SIG_IGN)
示例#2
0
    def setUp(self):
        self.progress = Progress()
        self.fetcher = Fetcher()
        self.cache = Cache()

        self.download_dir = self.makeDir()
        self.fetcher.setLocalPathPrefix(self.download_dir + "/")

        # Disable caching so that things blow up when not found.
        self.fetcher.setCaching(NEVER)

        sysconf.set("deb-arch", "i386")
示例#3
0
    def setUp(self):
        self.progress = Progress()
        self.fetcher = Fetcher()
        self.cache = Cache()

        self.download_dir = self.makeDir()
        self.fetcher.setLocalPathPrefix(self.download_dir + "/")

        # Disable caching so that things blow up when not found.
        self.fetcher.setCaching(NEVER)

        sysconf.set("deb-arch", "i386")
        self.trustdb = open("%s/aptdeb/trustdb.gpg" % TESTDATADIR).read()
示例#4
0
文件: yumrpm.py 项目: pombreda/smart
    def setUp(self):
        self.progress = Progress()
        self.fetcher = Fetcher()
        self.cache = Cache()

        self.download_dir = self.makeDir()
        self.fetcher.setLocalPathPrefix(self.download_dir + "/")

        # Disable caching so that things blow up when not found.
        self.fetcher.setCaching(NEVER)

        # Make sure to trigger old bugs in debug error reporting.
        sysconf.set("log-level", DEBUG)
示例#5
0
    def __init__(self, confpath=None, forcelocks=False):
        self._confpath = None
        self._channels = {}  # alias -> Channel()
        self._sysconfchannels = {}  # alias -> data dict
        self._dynamicchannels = {}  # alias -> Channel()
        self._pathlocks = PathLocks(forcelocks)
        self._cache = Cache()

        self.loadSysConf(confpath)

        self._fetcher = Fetcher()
        self._mediaset = self._fetcher.getMediaSet()
        self._achanset = AvailableChannelSet(self._fetcher)
        self._cachechanged = False
示例#6
0
    def setUp(self):
        self.channel = createChannel(
            "alias", {
                "type": "apt-deb",
                "baseurl": "file://%s/deb" % TESTDATADIR,
                "distribution": "./"
            })

        class TestInterface(Interface):
            output = []

            def message(self, level, msg):
                self.output.append((level, msg))

            def showOutput(self, data):
                self.output.append(data)

        self.iface = TestInterface(ctrl)

        self.progress = Progress()
        self.fetcher = Fetcher()
        self.cache = Cache()

        self.channel.fetch(self.fetcher, self.progress)
        self.loader = self.channel.getLoaders()[0]
        self.cache.addLoader(self.loader)

        self.old_iface = iface.object
        self.old_sysconf = pickle.dumps(sysconf.object)

        iface.object = self.iface

        self.cache.load()

        self.pm = DebPackageManager()

        # skip test if dpkg is unavailable
        dpkg = sysconf.get("dpkg", "dpkg")
        output = tempfile.TemporaryFile()
        status = self.pm.dpkg([dpkg, "--version"], output)
        if not os.WIFEXITED(status) or os.WEXITSTATUS(status) != 0:
            if not hasattr(self, 'skipTest'):  # Python < 2.7
                self.skipTest = self.fail  # error
            self.skipTest("%s not found" % dpkg)
示例#7
0
 def getCachedSize(self):
     fetcher = Fetcher()
     localdir = os.path.join(sysconf.get("data-dir"), "packages/")
     fetcher.setLocalDir(localdir, mangle=False)
     total = 0
     for pkg in self.install:
         for loader in pkg.loaders:
             if not loader.getInstalled():
                 break
         else:
             continue
         info = loader.getInfo(pkg)
         for url in info.getURLs():
             mirror = fetcher.getMirrorSystem().get(url)
             item = FetchItem(fetcher, url, mirror)
             path = fetcher.getLocalPath(item)
             if os.path.exists(path):
                 total += os.path.getsize(path)
     return total
示例#8
0
def fetch_urpmi_cfg(filename):
    fetcher = Fetcher()
    if os.path.isfile(URPMI_MIRRORS_CACHE):
        mirrorsfile = open(URPMI_MIRRORS_CACHE)
        mirrorscache = eval(mirrorsfile.read().replace('=>',
                                                       ':').replace(';', ''))
        mirrorsfile.close()
    else:
        mirrorscache = None

    config = []
    in_block = False
    skip = False
    urpmi_cfg_f = open(filename)
    for line in urpmi_cfg_f.readlines():
        line = line.strip()
        if len(line) <= 0:
            continue
        if line[-1] == "}":
            in_block = False
            skip = False
        if skip:
            continue
        if line[-1] == "{":
            in_block = True
            s = line.split(" ")
            if len(s) == 1:
                skip = True
                continue
            config.append(dict())
            config[-1]["name"] = " ".join(s[0:-2]).replace("\\", "")
            if s[-2]:
                config[-1]["url"] = s[-2]
            continue
        if not in_block:
            continue
        if line.find(": ") > 0:
            (key, value) = line.strip().split(": ")
            config[-1][key.strip()] = value
            if key == "mirrorlist":
                if mirrorscache:
                    if mirrorscache.has_key(value):
                        value = mirrorscache[value]
                        # Make sure to find a mirror using a protocol that we
                        # actually handle...
                        scheme = value["chosen"].split(":")[0]
                        if fetcher.getHandler(scheme, None):
                            config[-1]["url"] = value["chosen"]
                        else:
                            config[-1]["url"] = None

                        for mirror in value["list"]:
                            scheme = mirror["url"].split(":")[0]
                            if fetcher.getHandler(scheme, None):
                                if not config[-1]["url"]:
                                    config[-1]["url"] = mirror["url"]
                                else:
                                    sysconf.add(("mirrors", config[-1]["url"]),
                                                mirror["url"],
                                                unique=True)
        else:
            config[-1][line.strip()] = True
    urpmi_cfg_f.close()
    return config