How to use the pybombs.pb_exception.PBException function in PyBOMBS

To help you get started, we’ve selected a few PyBOMBS examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gnuradio / pybombs / pybombs / fetcher.py View on Github external
if url_type in uri_types:
            url = uri[len(url_type)+1:]
            return (url_type, url)
        # OK, let's try and identify it.
        try: # Is it a file?
            os.stat(uri)
            return ('file', uri)
        except OSError:
            pass
        # No, OK, let's try regexing this guy
        for utype in uri_types:
            for regex in self.available[utype].regexes:
                if re.match(regex, uri):
                    return (utype, uri)
        # Yeah, whatever, I give up.
        raise PBException("Unrecognized URI: {uri}".format(uri=uri))
github gnuradio / pybombs / pybombs / recipe.py View on Github external
self.preq = PBPackageRequirement(pkg_name)
        elif isinstance(self.preq, PBPackageRequirement):
            if self.preq.compare is None:
                self.preq.name = " ".join((self.preq.name, pkg_name))
            else:
                raise PBException("Parsing Error. Did not expect package name here.")
        elif isinstance(self.preq, PBPackageRequirementPair):
            if self.preq.second is None:
                self.preq.second = PBPackageRequirement(pkg_name)
            else:
                if self.preq.second.compare is None:
                    self.preq.second.name = " ".join((self.preq.second.name, pkg_name))
                else:
                    raise PBException("Parsing Error. Did not expect package name here ({0}).".format(self.preq.second))
        else:
            raise PBException("Random Foobar Parsing Error.")
github gnuradio / pybombs / pybombs / packagers / source.py View on Github external
self.log.debug("In cwd - {0}".format(os.getcwd()))
        pre_cmd = recipe.var_replace_all(self.get_command('configure', recipe))
        cmd = self.filter_cmd(pre_cmd, recipe, 'config_filter')
        o_proc = None
        if self.log.getEffectiveLevel() >= pb_logging.DEBUG and not try_again:
            o_proc = output_proc.OutputProcessorMake(preamble="Configuring: ")
        if subproc.monitor_process(cmd, shell=True, o_proc=o_proc) == 0:
            self.log.debug("Configure successful.")
            return True
        # OK, something went wrong.
        if try_again == False:
            self.log.warning("Configuration failed. Re-trying with higher verbosity.")
            return self.configure(recipe, try_again=True)
        else:
            self.log.error("Configuration failed after running at least twice.")
            raise PBException("Configuration failed")
github gnuradio / pybombs / pybombs / inventory.py View on Github external
def get_version(self, pkg, default_version=None):
        """
        Return a package's version.
        This throws a PBException if the package doesn't exist.
        If no version was set, return default_version (defaults to None).
        """
        if not self.has(pkg):
            raise PBException("Cannot get version for package {0} if it's not in the inventory!".format(pkg))
        try:
            return self._invfile.data[pkg]["version"]
        except KeyError:
            return default_version
github gnuradio / pybombs / pybombs / commands / deploy.py View on Github external
'gzip': GZipDeployer,
            'bzip2': BZip2Deployer,
            'xz': XZDeployer,
            #'ssh': SSHDeployer
        }[ttype]
    if re.match(r'.*\.tar\.gz$', target):
        return GZipDeployer
    if re.match(r'.*\.tar\.bz2$', target):
        return BZip2Deployer
    if re.match(r'.*\.tar\.xz$', target):
        return XZDeployer
    if re.match(r'.*\.tar$', target):
        return TarfileDeployer
    if target.find('@') != -1:
        return SSHDeployer
    raise PBException("Cannot determine deployment type for target `{0}'".format(target))
github gnuradio / pybombs / pybombs / packagers / source.py View on Github external
if nuke_builddir:
                # We can't nuke the build dir for in-tree builds, so fall back
                # to make clean:
                nuke_builddir = False
                make_clean = True
        else: # If the build dir is separate:
            if os.path.exists(builddir):
                if nuke_builddir:
                    self.log.info("Removing old build directory.")
                    shutil.rmtree(builddir)
                    os.mkdir(builddir)
                elif warn_if_builddir_exists:
                    self.log.warn("Build dir already exists: {0}".format(builddir))
            else:
                if fail_if_builddir_missing:
                    raise PBException("Can't update package {0}, build directory seems to be missing.".format(recipe.id))
                os.mkdir(builddir)
        os.chdir(builddir)
        recipe.vars['builddir'] = builddir
        ### Run the build process
        if get_state() < self.inventory.STATE_CONFIGURED:
            self.configure(recipe)
            set_state(self.inventory.STATE_CONFIGURED)
        else:
            self.log.debug("Package {0} is already configured.".format(recipe.id))
        if get_state() < self.inventory.STATE_BUILT:
            if make_clean:
                self.make_clean(recipe)
            self.make(recipe)
            set_state(self.inventory.STATE_BUILT)
        else:
            self.log.debug("Package {0} is already built.".format(recipe.id))
github gnuradio / pybombs / pybombs / config_manager.py View on Github external
Order is:
        1) From the command line (-p switch; either an alias, or a directory)
        2) Environment variable (see env_prefix_var)
        3) CWD (if it has a .pybombs subdir and is not the home directory)
        4) The config option called 'default_prefix'

        If all of these fail, we have no prefix.
        """
        if args.prefix is not None:
            if args.prefix in self._cfg_info['prefix_aliases']:
                self.log.debug("Resolving prefix alias {0}.".format(args.prefix))
                self.alias = args.prefix
                args.prefix = self._cfg_info['prefix_aliases'][args.prefix]
            if not os.path.isdir(npath(args.prefix)):
                self.log.error("Not a prefix: {0}".format(args.prefix))
                raise PBException("Can't open prefix: {0}".format(args.prefix))
            self.prefix_dir = npath(args.prefix)
            self.prefix_src = 'cli'
            self.log.debug("Choosing prefix dir from command line: {0}".format(self.prefix_dir))
            return
        if self.env_prefix_var in os.environ and os.path.isdir(os.environ[self.env_prefix_var]):
            self.prefix_dir = npath(os.environ[self.env_prefix_var])
            self.prefix_src = 'env'
            self.log.debug(
                'Using environment variable {0} as prefix ({1})'
                .format(self.env_prefix_var, self.prefix_dir))
            return
        if os.getcwd() != os.path.expanduser('~') and \
                os.path.isdir(os.path.join('.', self.prefix_conf_dir)):
            self.prefix_dir = os.getcwd()
            self.prefix_src = 'cwd'
            self.log.debug('Using CWD as prefix ({0})'.format(self.prefix_dir))
github gnuradio / pybombs / pybombs / commands / prefix.py View on Github external
def register_alias(alias, path):
            " Write the prefix alias to the config file "
            if self.prefix is not None and \
                    self.prefix.prefix_aliases.get(alias) is not None \
                    and not confirm("Alias `{0}' already exists, overwrite?".format(alias)):
                self.log.warn('Aborting.')
                raise PBException("Could not create alias.")
            self.cfg.update_cfg_file({'prefix_aliases': {alias: path}})
        def create_virtualenv(path):
github gnuradio / pybombs / pybombs / recipe.py View on Github external
def pl_pkg(self, pkg_name):
        " Called in a package requirements list, when a package name is found "
        if self.preq is None:
            self.preq = PBPackageRequirement(pkg_name)
        elif isinstance(self.preq, PBPackageRequirement):
            if self.preq.compare is None:
                self.preq.name = " ".join((self.preq.name, pkg_name))
            else:
                raise PBException("Parsing Error. Did not expect package name here.")
        elif isinstance(self.preq, PBPackageRequirementPair):
            if self.preq.second is None:
                self.preq.second = PBPackageRequirement(pkg_name)
            else:
                if self.preq.second.compare is None:
                    self.preq.second.name = " ".join((self.preq.second.name, pkg_name))
                else:
                    raise PBException("Parsing Error. Did not expect package name here ({0}).".format(self.preq.second))
        else:
            raise PBException("Random Foobar Parsing Error.")