def getHostWithDir(self, hostDir): """ Returns the HostInfo object that corresponds to the indicated on-disk host directory. This would be used when reading a host directory from disk, instead of downloading it from a server. Supply the full path to the host directory, as a Filename. Returns None if the contents.xml in the indicated host directory cannot be read or doesn't seem consistent. """ host = HostInfo(None, hostDir=hostDir, appRunner=self) if not host.hasContentsFile: if not host.readContentsFile(): # Couldn't read the contents.xml file return None if not host.hostUrl: # The contents.xml file there didn't seem to indicate the # same host directory. return None host2 = self.hosts.get(host.hostUrl) if host2 is None: # No such host already; store this one. self.hosts[host.hostUrl] = host return host if host2.hostDir != host.hostDir: # Hmm, we already have that host somewhere else. return None # We already have that host, and it's consistent. return host2
def getHost(self, hostUrl, hostDir=None): """ Returns a new HostInfo object corresponding to the indicated host URL. If we have already seen this URL previously, returns the same object. This returns the literal referenced host. To return the mapped host, which is the one we should actually download from, see getHostWithAlt(). """ if not hostUrl: hostUrl = self.pandaHostUrl host = self.hosts.get(hostUrl, None) if not host: host = HostInfo(hostUrl, appRunner=self, hostDir=hostDir) self.hosts[hostUrl] = host return host
def getHost(self, hostUrl): if hostUrl in self.hosts: return self.hosts[hostUrl] host = HostInfo(hostUrl, appRunner=appRunner, hostDir=self.hostDir, asMirror=False, perPlatform=False) if not host.hasContentsFile: if not host.readContentsFile(): if not host.downloadContentsFile(self.http): Installer.notify.error("couldn't read host %s" % host.hostUrl) return None self.hosts[hostUrl] = host return host
def __init__(self, p3dfile, tokens={}): self.p3dfile = Filename(p3dfile) self.basename = self.p3dfile.getBasenameWoExtension() self.tokens = tokens self.tempDir = Filename.temporary("", self.basename, "") + "/" self.tempDir.makeDir() self.host = HostInfo(PandaSystem.getPackageHostUrl(), appRunner=appRunner, hostDir=self.tempDir, asMirror=False, perPlatform=True) self.http = HTTPClient.getGlobalPtr() if not self.host.hasContentsFile: if not self.host.readContentsFile(): if not self.host.downloadContentsFile(self.http): Standalone.notify.error("couldn't read host") return