def doInstall(self, path = None, name = None): # Set up a tmpname to download to h = tempfile.NamedTemporaryFile() tmpname = h.name h.close() source = self.getProperty("Source") if name is None and "Name" in self.properties: name = self.getProperty("Name") if path is None and "Path" in self.properties: path = self.getProperty("Path") self.filename = self.getFilename(source, path, name) # Do the download with the file resource downloader = UrlDownloader(source) downloader.download(tmpname) # Check if there is compression. If so, decompress it if self.getCompressionType(source) is None: g.feedback.log(LogLevels.DEBUG, "File from %s is not an archive - just copying to %s" % (source,self.filename)) directory = os.path.dirname(self.filename) if not os.path.exists(directory) : os.makedirs(directory) shutil.move(tmpname, self.filename) else: g.feedback.log(LogLevels.DEBUG, "File from %s is compressed so decompressing" % source) if not self.decompress(tmpname, source, path, name): return False # Once we have decompressed it, delete the downloaded archive self.delete(tmpname) return True
def getFile(self, location, path, name): g.feedback.log(LogLevels.DEBUG, "Getting file from %s - %s - %s" % (location, path, name)) fullPath = self.getFilename(location, path, name) g.feedback.log(LogLevels.DEBUG, "File's full path is %s" % fullPath) if self.exists(fullPath): g.feedback.log(LogLevels.DEBUG, "File at %s exists" % fullPath) self.delete(fullPath) if self.isPathUrl(location): downloader = UrlDownloader(location) return downloader.download(fullPath) else: self.copyFile(location, fullPath) return fullPath
def doBinaryUpdate(self): g.feedback.userMessage("MSG", "A binary update is available. Downloading...") fileUrl = self.new_manifest.jinn.getBinary(self.os, self.arch, self.osver) g.feedback.log(LogLevels.DEBUG, "Downloading file from %s" % fileUrl) downloader = UrlDownloader(fileUrl) downloadTarget = self.getInstallTargetFile() + ".tmp" if self.os == OperatingSystem().OSX: downloadTarget = self.getInstallTargetFile() + ".pkg.tmp" filename = downloader.download(downloadTarget) if self.os is OperatingSystem().OSX: filename = self.getInstallTargetFile() g.feedback.log(LogLevels.DEBUG, "File downloaded to %s" % filename) if platform.system() == "Darwin": # if on os x we also need the pkg file downloader = UrlDownloader(fileUrl + ".pkg") filename = downloader.download(self.getInstallTargetFile() + ".tmp.pkg") g.feedback.log(LogLevels.DEBUG, "File downloaded to %s" % filename) if self.os is not OperatingSystem().OSX: if not self.makeExecutable(filename): g.feedback.log(LogLevels.ERROR, "Unable to make filename %s executable" % filename) args = copy.copy(sys.argv) args.pop(0) new_args = [filename, "-binaryupdate", self.getCurrentFile()] if args is not None and len(args) > 0: new_args.extend(args) g.feedback.log(LogLevels.DEBUG, "Sys args: %s" % sys.argv) g.feedback.log(LogLevels.DEBUG, "New args: %s" % new_args) if not self.new_manifest.save(): g.feedback.log(LogLevels.ERROR, "Unable to save new manifest file") self.done() self.finished(1) return g.feedback.userMessage("MSG", "Binary update complete.") if type(g.feedback) == QTUIFeedback: self.finished(-2) # tell the UI to completely quit self.done() StartProcess(new_args) sys.exit()
def doDownload(self, url, path, name): fullPath = self.getFilename(url, path, name) if self.exists(fullPath): self.delete(fullPath) downloader = UrlDownloader(url) return downloader.download(fullPath)