예제 #1
0
    def __init__(self,
                 repourl=None,
                 mode='incremental',
                 method=None,
                 username=None,
                 password=None,
                 extra_args=None,
                 keep_on_purge=None,
                 depth=None,
                 preferLastChangedRev=False,
                 **kwargs):

        self.repourl = repourl
        self.username = username
        self.password = password
        self.extra_args = extra_args
        self.keep_on_purge = keep_on_purge or []
        self.depth = depth
        self.method = method
        self.mode = mode
        self.preferLastChangedRev = preferLastChangedRev
        Source.__init__(self, **kwargs)
        errors = []
        if not self._hasAttrGroupMember('mode', self.mode):
            errors.append("mode %s is not one of %s" %
                          (self.mode, self._listAttrGroupMembers('mode')))
        if self.method not in self.possible_methods:
            errors.append("method %s is not one of %s" %
                          (self.method, self.possible_methods))

        if repourl is None:
            errors.append("you must provide repourl")

        if errors:
            raise ConfigErrors(errors)
예제 #2
0
    def __init__(self, repourl=None, branch=None, progress=False,
                 mode='incremental', method=None, **kwargs):

        self.repourl = repourl
        self.method = method
        self.mode = mode
        self.branch = branch
        self.sourcedata = "{}?{}".format(self.repourl, self.branch)
        self.database = 'db.mtn'
        self.progress = progress
        super().__init__(**kwargs)
        errors = []

        if not self._hasAttrGroupMember('mode', self.mode):
            errors.append("mode {} is not one of {}".format(self.mode,
                                                            self._listAttrGroupMembers('mode')))
        if self.mode == 'incremental' and self.method:
            errors.append("Incremental mode does not require method")

        if self.mode == 'full':
            if self.method is None:
                self.method = 'copy'
            elif self.method not in self.possible_methods:
                errors.append("Invalid method for mode == {}".format(self.mode))

        if repourl is None:
            errors.append("you must provide repourl")

        if branch is None:
            errors.append("you must provide branch")

        if errors:
            raise ConfigErrors(errors)
예제 #3
0
파일: darcs.py 프로젝트: zanssa/buildbot
    def __init__(self,
                 repourl=None,
                 mode='incremental',
                 method=None,
                 **kwargs):

        self.repourl = repourl
        self.method = method
        self.mode = mode
        Source.__init__(self, **kwargs)
        errors = []

        if not self._hasAttrGroupMember('mode', self.mode):
            errors.append("mode %s is not one of %s" %
                          (self.mode, self._listAttrGroupMembers('mode')))
        if self.mode == 'incremental' and self.method:
            errors.append("Incremental mode does not require method")

        if self.mode == 'full':
            if self.method is None:
                self.method = 'copy'
            elif self.method not in self.possible_methods:
                errors.append("Invalid method for mode == %s" % (self.mode))

        if repourl is None:
            errors.append("you must provide repourl")

        if errors:
            raise ConfigErrors(errors)
예제 #4
0
    def __init__(self,
                 repourl=None,
                 mode='incremental',
                 method=None,
                 defaultBranch=None,
                 branchType='dirname',
                 clobberOnBranchChange=True,
                 **kwargs):
        """
        @type  repourl: string
        @param repourl: the URL which points at the Mercurial repository.
                        if 'dirname' branches are enabled, this is the base URL
                        to which a branch name will be appended. It should
                        probably end in a slash.

        @param defaultBranch: if branches are enabled, this is the branch
                              to use if the Build does not specify one
                              explicitly.
                              For 'dirname' branches, It will simply be
                              appended to C{repourl} and the result handed to
                              the 'hg update' command.
                              For 'inrepo' branches, this specifies the named
                              revision to which the tree will update after a
                              clone.

        @param branchType: either 'dirname' or 'inrepo' depending on whether
                           the branch name should be appended to the C{repourl}
                           or the branch is a mercurial named branch and can be
                           found within the C{repourl}

        @param clobberOnBranchChange: boolean, defaults to True. If set and
                                      using inrepos branches, clobber the tree
                                      at each branch change. Otherwise, just
                                      update to the branch.
        """

        self.repourl = repourl
        self.defaultBranch = self.branch = defaultBranch
        self.branchType = branchType
        self.method = method
        self.clobberOnBranchChange = clobberOnBranchChange
        self.mode = mode
        Source.__init__(self, **kwargs)

        errors = []
        if not self._hasAttrGroupMember('mode', self.mode):
            errors.append("mode %s is not one of %s" %
                          (self.mode, self._listAttrGroupMembers('mode')))
        if self.method not in self.possible_methods:
            errors.append("method %s is not one of %s" %
                          (self.method, self.possible_methods))
        if self.branchType not in self.possible_branchTypes:
            errors.append("branchType %s is not one of %s" %
                          (self.branchType, self.possible_branchTypes))

        if repourl is None:
            errors.append("you must provide a repourl")

        if errors:
            raise ConfigErrors(errors)
예제 #5
0
파일: configs.py 프로젝트: xhochy/ursabot
def collect_global_errors(and_raise=False):
    global _errors
    _errors = errors = ConfigErrors()

    try:
        yield errors
    except ConfigErrors as e:
        errors.merge(e)
    finally:
        _errors = None
        if errors and and_raise:
            raise errors
예제 #6
0
    def __init__(self,
                 repourl=None,
                 mode='incremental',
                 method=None,
                 username=None,
                 password=None,
                 extra_args=None,
                 keep_on_purge=None,
                 depth=None,
                 **kwargs):

        self.repourl = repourl
        self.username = username
        self.password = password
        self.extra_args = extra_args
        self.keep_on_purge = keep_on_purge or []
        self.depth = depth
        self.method = method
        self.mode = mode
        Source.__init__(self, **kwargs)
        self.addFactoryArguments(
            repourl=repourl,
            mode=mode,
            method=method,
            password=password,
            username=username,
            extra_args=extra_args,
            keep_on_purge=keep_on_purge,
            depth=depth,
        )
        errors = []
        if self.mode not in self.possible_modes:
            errors.append("mode %s is not one of %s" %
                          (self.mode, self.possible_modes))
        if self.method not in self.possible_methods:
            errors.append("method %s is not one of %s" %
                          (self.method, self.possible_methods))

        if repourl is None:
            errors.append("you must provide repourl")

        if errors:
            raise ConfigErrors(errors)
예제 #7
0
    def __init__(self,
                 repourl=None,
                 branch=None,
                 progress=False,
                 mode='incremental',
                 method=None,
                 **kwargs):

        self.repourl = repourl
        self.method = method
        self.mode = mode
        self.branch = branch
        self.sourcedata = "%s?%s" % (self.repourl, self.branch)
        self.databasename = 'db.mtn'
        self.database = '../db.mtn'
        self.progress = progress
        Source.__init__(self, **kwargs)
        errors = []

        if self.mode not in self.possible_modes:
            errors.append("mode %s is not one of %s" %
                          (self.mode, self.possible_modes))
        if self.mode == 'incremental' and self.method:
            errors.append("Incremental mode does not require method")

        if self.mode == 'full':
            if self.method == None:
                self.method = 'copy'
            elif self.method not in self.possible_methods:
                errors.append("Invalid method for mode == %s" % (self.mode))

        if repourl is None:
            errors.append("you must provide repourl")

        if branch is None:
            errors.append("you must provide branch")

        if errors:
            raise ConfigErrors(errors)
예제 #8
0
파일: p4.py 프로젝트: thuanbk2010/katana
    def __init__(self,
                 mode='incremental',
                 method=None,
                 p4base=None,
                 p4branch=None,
                 p4port=None,
                 p4user=None,
                 p4passwd=None,
                 p4extra_views=(),
                 p4line_end='local',
                 p4viewspec=None,
                 p4client=Interpolate(
                     'buildbot_%(prop:slavename)s_%(prop:buildername)s'),
                 p4bin='p4',
                 **kwargs):
        self.method = method
        self.mode = mode
        self.p4branch = p4branch
        self.p4bin = p4bin
        self.p4base = p4base
        self.p4port = p4port
        self.p4user = p4user
        self.p4passwd = p4passwd
        self.p4extra_views = p4extra_views
        self.p4viewspec = p4viewspec
        self.p4line_end = p4line_end
        self.p4client = p4client

        Source.__init__(self, **kwargs)

        errors = []
        if self.mode not in self.possible_modes:
            errors.append("mode %s is not one of %s" %
                          (self.mode, self.possible_modes))

        if not p4viewspec and p4base is None:
            errors.append("You must provide p4base or p4viewspec")

        if p4viewspec and (p4base or p4branch or p4extra_views):
            errors.append(
                "Either provide p4viewspec or p4base and p4branch (and optionally p4extra_views"
            )

        if p4viewspec and type(p4viewspec) is StringType:
            errors.append(
                "p4viewspec must not be a string, and should be a sequence of 2 element sequences"
            )

        if not interfaces.IRenderable.providedBy(
                p4base) and p4base and p4base.endswith('/'):
            errors.append(
                'p4base should not end with a trailing / [p4base = %s]' %
                p4base)

        if not interfaces.IRenderable.providedBy(
                p4branch) and p4branch and p4branch.endswith('/'):
            errors.append(
                'p4branch should not end with a trailing / [p4branch = %s]' %
                p4branch)

        if (p4branch or p4extra_views) and not p4base:
            errors.append(
                'If you specify either p4branch or p4extra_views you must also specify p4base'
            )

        if errors:
            raise ConfigErrors(errors)
예제 #9
0
파일: configs.py 프로젝트: kou/ursabot
    def load(self):
        # License note:
        #     It is a reimplementation based on the original
        #     buildbot.config.FileLoader and buildbot.config.loadConfigDict
        #     implementation.
        config = self.path.absolute()
        basedir = config.parent

        if not config.exists():
            raise ConfigErrors(
                [f"configuration file '{config}' does not exist"])

        try:
            with config.open('r'):
                pass
        except IOError as e:
            raise ConfigErrors(
                [f'unable to open configuration file {config}: {e}'])

        log.info(f'Loading configuration from {config}')

        # execute the config file
        local_dict = {
            # inject global variables, useful for including configurations
            **self.inject_globals,
            # TODO(kszucs): is it required?
            'basedir':
            basedir.expanduser(),
            '__file__':
            config
        }

        old_sys_path = sys.path[:]
        sys.path.append(str(basedir))
        try:
            try:
                execfile(config, local_dict)
            except ConfigErrors:
                raise
            except SyntaxError:
                exc = traceback.format_exc()
                error(
                    f'encountered a SyntaxError while parsing config file:\n'
                    f'{exc}',
                    always_raise=True)
            except Exception:
                exc = traceback.format_exc()
                error(
                    f'error while parsing config file: {exc} (traceback in '
                    f'logfile)',
                    always_raise=True)
        finally:
            sys.path[:] = old_sys_path

        if self.variable not in local_dict:
            error(
                f"Configuration file {config} does not define variable"
                f"'{self.variable}'",
                always_raise=True)

        return local_dict[self.variable]