def _download(self): ''' Run right before a package action takes place. We see if we have a package directory and if not, tell the repository to unpack it from the filesystem. Then verify all the pieces and parts are there for a good type-4 package ''' if not self.downloaded: self.repository.get_type_5(self.full_name, self.injectors_info, self.libs_info) pkg_dir = make_path(get_package_path(self.instance_name), self.full_name) injector_dir = make_path(pkg_dir, "injectors") if os.path.isdir(injector_dir): self.working_dir = injector_dir else: self.status = FAIL errmsg = "The injector directory does not exist for [%s]" raise BadPackage(self.name, errmsg % self.full_name) self.downloaded = True
def get_type_4(self, full_name): ''' Get a type-4 package from the filesystem, and process it full_name -- name of package (with version) ''' pkg_dir = get_package_path(self.instance_name) os.system('bash -c "mkdir -p %s"' % pkg_dir) pkg_path = make_path(pkg_dir, full_name) if not os.path.isfile(pkg_path + ".spkg"): erstr = "No package file in %s." % (pkg_path + ".spkg") Logger.error(erstr) raise Exceptions.BadPackage(full_name, erstr) if sys.platform != 'win32': cmd = 'bash -c "cd %s && tar -mxzf %s.spkg"' % (pkg_dir, full_name) Logger.info("Untarring with command: %s" %cmd) if not os.system(cmd) == OK: raise Exceptions.BadPackage(full_name, "Could not unpack") return OK if self.unzip_type_5(pkg_path, full_name) == FAIL: raise Exceptions.BadPackage(full_name, "could not unzip") # tar = tarfile.open(pkg_path + ".tar", "r") # tar.errorlevel = 2 cwd = get_slash_cwd() os.chdir(pkg_dir) # for tarinfo in tar: # try: # tar.extract(tarinfo) # except tarfile.ExtractError, err: # Logger.warning("Error with package %s,%s: "\ # "%s" % (full_name, tarinfo.name, err)) # tar.close() if not os.path.isdir(make_path(pkg_path, full_name)): erstr = "Package %s is malformed." % (full_name) os.chdir(cwd) raise Exceptions.BadPackage(full_name, erstr) os.chdir(cwd) # os.unlink(pkg_path + ".tar") return OK
def _download(self): ''' Run right before a package action takes place. We see if we have a package directory and if not, tell the repository to unpack it from the filesystem. Then verify all the pieces and parts are there for a good type-4 package ''' if not self.downloaded: pkg_dir = make_path(get_package_path(self.instance_name), self.full_name) if not os.path.isdir(pkg_dir): self.repository.get_type_4(self.full_name) self.scripts_dir = make_path(pkg_dir, "scripts") self.maint_dir = make_path(pkg_dir, "maint") injector_dir = make_path(pkg_dir, "injector") for required_dir in [self.scripts_dir, injector_dir]: if not os.path.isdir(required_dir): errmsg = "Required directory %s does not exist" errmsg = errmsg % required_dir self.status = FAIL raise BadPackage(self.name, errmsg) self.working_dir = injector_dir self.downloaded = True
def get_path(self): 'find place on the disk where this package can be accessed' path = make_path(get_package_path(self.instance_name), self.full_name) return path