def get_server_dir(self): """ Either downloads and/or unzips the server if necessary return: the directory of the unzipped server """ if not self.args.server: if self.args.skipunzip: raise Stop(0, "Unzip disabled, exiting") log.info("Downloading server") artifacts = Artifacts(self.args) server = artifacts.download("server") else: progress = 0 if self.args.verbose: progress = 20 ptype, server = fileutils.get_as_local_path( self.args.server, self.args.overwrite, progress=progress, httpuser=self.args.httpuser, httppassword=self.args.httppassword, ) if ptype == "file": if self.args.skipunzip: raise Stop(0, "Unzip disabled, exiting") log.info("Unzipping %s", server) server = fileutils.unzip(server, match_dir=True, destdir=self.args.unzipdir) log.debug("Server directory: %s", server) return server
def get_server_dir(self): """ Either downloads and/or unzips the server if necessary return: the directory of the unzipped server """ if not self.args.server: if self.args.skipunzip: raise Stop(0, 'Unzip disabled, exiting') log.info('Downloading server') artifacts = Artifacts(self.args) server = artifacts.download('server') else: progress = 0 if self.args.verbose: progress = 20 ptype, server = fileutils.get_as_local_path( self.args.server, self.args.overwrite, progress=progress, httpuser=self.args.httpuser, httppassword=self.args.httppassword) if ptype == 'file': if self.args.skipunzip: raise Stop(0, 'Unzip disabled, exiting') log.info('Unzipping %s', server) server = fileutils.unzip(server, match_dir=True, destdir=self.args.unzipdir) log.debug('Server directory: %s', server) return server
def download(self, component): componenturl = self.artifacts.get(component) if not componenturl: raise Exception("No %s found" % component) filename = os.path.basename(componenturl) unzipped = filename.replace(".zip", "") if os.path.exists(unzipped): self.create_symlink(unzipped) return unzipped log.info("Checking %s", componenturl) if self.args.dry_run: return progress = 0 if self.args.verbose: progress = 20 ptype, localpath = fileutils.get_as_local_path( componenturl, self.args.overwrite, progress=progress, httpuser=self.args.httpuser, httppassword=self.args.httppassword) if ptype != 'file': raise ArtifactException('Expected local file', localpath) if not self.args.skipunzip: if localpath.endswith('.zip'): try: log.info('Unzipping %s', localpath) unzipped = fileutils.unzip(localpath, match_dir=True, destdir=self.args.unzipdir) self.create_symlink(unzipped) return unzipped except Exception as e: log.error('Unzip failed: %s', e) print e raise Stop(20, 'Unzip failed, try unzipping manually') else: log.warn('Not unzipping %s', localpath) return localpath
def download(self, component): componenturl = self.artifacts.get(component) if not componenturl: raise Exception("No %s found" % component) filename = os.path.basename(componenturl) unzipped = filename.replace(".zip", "") if os.path.exists(unzipped): self.create_symlink(unzipped) return unzipped log.info("Checking %s", componenturl) if self.args.dry_run: return progress = 0 if self.args.verbose: progress = 20 ptype, localpath = fileutils.get_as_local_path( componenturl, self.args.overwrite, progress=progress, httpuser=self.args.httpuser, httppassword=self.args.httppassword) if ptype != 'file': raise ArtifactException('Expected local file', localpath) if not self.args.skipunzip: if localpath.endswith('.zip'): try: log.info('Unzipping %s', localpath) unzipped = fileutils.unzip( localpath, match_dir=True, destdir=self.args.unzipdir) self.create_symlink(unzipped) return unzipped except Exception as e: log.error('Unzip failed: %s', e) print e raise Stop(20, 'Unzip failed, try unzipping manually') else: log.warn('Not unzipping %s', localpath) return localpath
def configure(self, copyold, prestartfile): def samecontents(a, b): # os.path.samefile is not available on Windows try: return os.path.samefile(a, b) except AttributeError: with open(a) as fa: with open(b) as fb: return fa.read() == fb.read() target = self.dir / "etc" / "grid" / "config.xml" if copyold: from path import path old_grid = path(self.args.sym) / "etc" / "grid" old_cfg = old_grid / "config.xml" log.info("Copying old configuration from %s", old_cfg) if not old_cfg.exists(): raise Stop(40, 'config.xml not found') if target.exists() and samecontents(old_cfg, target): # This likely is caused by the symlink being # created early on an initial install. pass else: old_cfg.copy(target) else: if target.exists(): log.info('Deleting configuration file %s', target) target.remove() if prestartfile: for f in prestartfile: log.info('Loading prestart file %s', f) ftype, fpath = fileutils.get_as_local_path(f, 'backup') if ftype != 'file': raise Stop(50, 'Expected file, found: %s %s' % ( ftype, f)) self.run(['load', fpath]) self.configure_ports()
def get_server_dir(self): """ Either downloads and/or unzips the server if necessary return: the directory of the unzipped server """ if not self.args.server: if self.args.skipunzip: raise Stop(0, 'Unzip disabled, exiting') log.info('Downloading server') # The downloader automatically symlinks the server, however if # we are upgrading we want to delay the symlink swap, so this # overrides args.sym # TODO: Find a nicer way to do this? artifact_args = copy.copy(self.args) artifact_args.sym = '' artifacts = Artifacts(artifact_args) server = artifacts.download('server') else: progress = 0 if self.args.verbose: progress = 20 ptype, server = fileutils.get_as_local_path( self.args.server, self.args.overwrite, progress=progress, httpuser=self.args.httpuser, httppassword=self.args.httppassword) if ptype == 'file': if self.args.skipunzip: raise Stop(0, 'Unzip disabled, exiting') log.info('Unzipping %s', server) server = fileutils.unzip(server, match_dir=True, destdir=self.args.unzipdir) log.debug('Server directory: %s', server) return server
def configure(self, copyold, prestartfile): def samecontents(a, b): # os.path.samefile is not available on Windows try: return os.path.samefile(a, b) except AttributeError: with open(a) as fa: with open(b) as fb: return fa.read() == fb.read() target = self.dir / "etc" / "grid" / "config.xml" if copyold: from path import path old_grid = path(self.args.sym) / "etc" / "grid" old_cfg = old_grid / "config.xml" log.info("Copying old configuration from %s", old_cfg) if not old_cfg.exists(): raise Stop(40, 'config.xml not found') if target.exists() and samecontents(old_cfg, target): # This likely is caused by the symlink being # created early on an initial install. pass else: old_cfg.copy(target) else: if target.exists(): log.info('Deleting configuration file %s', target) target.remove() if prestartfile: for f in prestartfile: log.info('Loading prestart file %s', f) ftype, fpath = fileutils.get_as_local_path(f, 'backup') if ftype != 'file': raise Stop(50, 'Expected file, found: %s %s' % (ftype, f)) self.run(['load', fpath])
def get_server_dir(self): """ Either downloads and/or unzips the server if necessary return: the directory of the unzipped server """ if not self.args.server: if self.args.skipunzip: raise Stop(0, 'Unzip disabled, exiting') log.info('Downloading server') # The downloader automatically symlinks the server, however if # we are upgrading we want to delay the symlink swap, so this # overrides args.sym # TODO: Find a nicer way to do this? artifact_args = copy.copy(self.args) artifact_args.sym = '' artifacts = Artifacts(artifact_args) server = artifacts.download('server') else: progress = 0 if self.args.verbose: progress = 20 ptype, server = fileutils.get_as_local_path( self.args.server, self.args.overwrite, progress=progress, httpuser=self.args.httpuser, httppassword=self.args.httppassword) if ptype == 'file': if self.args.skipunzip: raise Stop(0, 'Unzip disabled, exiting') log.info('Unzipping %s', server) server = fileutils.unzip( server, match_dir=True, destdir=self.args.unzipdir) log.debug('Server directory: %s', server) return server