def run(self): pkgs = exs = [] try: pkgs = self.kwargs['package'] except KeyError: pkgs = dapicli.get_installed_daps() if pkgs: logger.info('Updating all DAP packages ...') else: logger.info( 'No installed DAP packages found, nothing to update.') for pkg in pkgs: logger.info('Updating DAP {pkg} ...'.format(pkg=pkg)) try: updated = dapicli.install_dap( pkg, update=True, update_allpaths=self.kwargs['allpaths'], force=self.kwargs['force']) if updated: logger.info( 'DAP {pkg} successfully updated.'.format(pkg=pkg)) else: logger.info( 'DAP {pkg} is already up to date.'.format(pkg=pkg)) except exceptions.DapiError as e: exs.append(utils.exc_as_decoded_string(e)) logger.error(utils.exc_as_decoded_string(e)) if exs: raise exceptions.ExecutionException('; '.join(exs))
def run(self): pkgs = exs = [] try: pkgs = self.kwargs['package'] except KeyError: pkgs = dapicli.get_installed_daps() if pkgs: logger.info('Updating all DAP packages ...') else: logger.info('No installed DAP packages found, nothing to update.') for pkg in pkgs: logger.info('Updating DAP {pkg} ...'.format(pkg=pkg)) try: updated = dapicli.install_dap(pkg, update=True, update_allpaths=self.kwargs['allpaths'], force=self.kwargs['force']) if updated: logger.info('DAP {pkg} successfully updated.'.format(pkg=pkg)) else: logger.info('DAP {pkg} is already up to date.'.format(pkg=pkg)) except exceptions.DapiError as e: exs.append(utils.exc_as_decoded_string(e)) logger.error(utils.exc_as_decoded_string(e)) if exs: raise exceptions.ExecutionException('; '.join(exs))
class DocAction(Action): name = 'doc' description = 'Display documentation for a DAP package.' args = [ argument.Argument('dap', 'dap', choices=sorted(dapicli.get_installed_daps()), help='Packages to get documentation for'), argument.Argument('doc', 'doc', nargs='?', help='Document to display') ] def run(self): dap = self.kwargs['dap'] doc = self.kwargs.get('doc', None) docdir = utils.find_file_in_load_dirs(os.path.join('doc', dap)) all_docs = [] if docdir is not None: all_docs = self._get_doc_files(docdir) if not all_docs: logger.info('DAP {0} has no documentation.'.format(dap)) elif doc is not None: doc_fullpath = os.path.join(docdir, doc) if doc_fullpath in all_docs: self._show_doc(doc_fullpath) else: msg = 'DAP {0} has no document "{1}".'.format(dap, doc) logger.error(msg) raise exceptions.ExecutionException(msg) else: logger.info('DAP {0} has these docs:'.format(dap)) for d in all_docs: logger.info(d[len(docdir):].strip(os.path.sep)) logger.info( 'Use "da doc {0} <DOC>" to see a specific document'.format( dap)) @classmethod def _get_doc_files(cls, docdir): found = [] for root, dirs, files in os.walk(docdir): found.extend([os.path.join(root, f) for f in files]) return sorted(found) @classmethod def _show_doc(cls, fullpath): have_less = True try: subprocess.check_call(['which', 'less'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) except (subprocess.CalledProcessError, OSError): have_less = False if have_less: subprocess.Popen(['less', '-F', '-R', '-S', '-X', '-K', fullpath], stdin=subprocess.PIPE, stdout=sys.stdout).communicate() else: logger.info(open(fullpath).read())
def run(cls, **kwargs): if kwargs['simple']: for pkg in sorted(dapicli.get_installed_daps()): print(pkg) else: for pkg, instances in sorted(dapicli.get_installed_daps_detailed().items()): versions = [] for instance in instances: location = utils.unexpanduser(instance['location']) version = instance['version'] if not versions: # if this is the first version = utils.bold(version) versions.append('{v}:{p}'.format(v=version, p=location)) pkg = utils.bold(pkg) print('{pkg} ({versions})'.format(pkg=pkg, versions=' '.join(versions)))
def run(cls, **kwargs): pkgs = exs = [] try: pkgs = kwargs['package'] except KeyError: logger.info('Updating all packages') pkgs = dapicli.get_installed_daps() for pkg in pkgs: logger.info('Updating {pkg}...'.format(pkg=pkg)) try: dapicli.install_dap(pkg, update=True) logger.info('{pkg} successfully updated'.format(pkg=pkg)) except Exception as e: exs.append(str(e)) logger.error(str(e)) if exs: raise exceptions.ExecutionException('; '.join(exs))
def run(cls, **kwargs): pkgs = exs = [] try: pkgs = kwargs['package'] except KeyError: pkgs = dapicli.get_installed_daps() if pkgs: logger.info('Updating all DAP packages ...') else: logger.info('No installed DAP packages found, nothing to update.') for pkg in pkgs: logger.info('Updating DAP {pkg} ...'.format(pkg=pkg)) try: updated = dapicli.install_dap(pkg, update=True, force=kwargs['force']) if updated: logger.info('DAP {pkg} successfully updated.'.format(pkg=pkg)) else: logger.info('DAP {pkg} is already up to date.'.format(pkg=pkg)) except Exception as e: exs.append(str(e)) logger.error(str(e)) if exs: raise exceptions.ExecutionException('; '.join(exs))
def run(cls, **kwargs): for pkg in dapicli.get_installed_daps(): print(pkg)