Esempio n. 1
0
 def __init__(self, maildir, prefix=None, category='', repository=''):
     MaildirService.__init__(self, maildir)
     self.prefix = prefix
     self.category = category
     self.repository = repository
     if prefix and not prefix.endswith("/"):
         log.msg("%s: you probably want your prefix=('%s') to end with "
                 "a slash")
Esempio n. 2
0
 def __init__(self, maildir, prefix=None):
     MaildirService.__init__(self, maildir)
     self.prefix = prefix
     if prefix and not prefix.endswith("/"):
         log.msg("%s: you probably want your prefix=('%s') to end with "
                 "a slash")
Esempio n. 3
0
 def __init__(self, name, builderNames, jobdir, properties={}):
     base.BaseScheduler.__init__(self, name, builderNames, properties)
     self.jobdir = jobdir
     self.watcher = MaildirService()
     self.watcher.setServiceParent(self)
Esempio n. 4
0
class Try_Jobdir(TryBase):
    compare_attrs = ('name', 'builderNames', 'jobdir', 'properties')

    def __init__(self, name, builderNames, jobdir, properties={}):
        base.BaseScheduler.__init__(self, name, builderNames, properties)
        self.jobdir = jobdir
        self.watcher = MaildirService()
        self.watcher.setServiceParent(self)

    def setServiceParent(self, parent):
        sm = parent
        m = sm.parent
        self.watcher.setBasedir(os.path.join(m.basedir, self.jobdir))
        TryBase.setServiceParent(self, parent)

    def parseJob(self, f):
        # jobfiles are serialized build requests. Each is a list of
        # serialized netstrings, in the following order:
        #  "1", the version number of this format
        #  buildsetID, arbitrary string, used to find the buildSet later
        #  branch name, "" for default-branch
        #  base revision, "" for HEAD
        #  patchlevel, usually "1"
        #  patch
        #  builderNames...
        p = JobFileScanner()
        p.dataReceived(f.read())
        if p.error:
            raise BadJobfile("unable to parse netstrings")
        s = p.strings
        ver = s.pop(0)
        if ver == "1":
            buildsetID, branch, baserev, patchlevel, diff = s[:5]
            builderNames = s[5:]
            if branch == "":
                branch = None
            if baserev == "":
                baserev = None
            patchlevel = int(patchlevel)
            patch = (patchlevel, diff)
            ss = SourceStamp("Old client", branch, baserev, patch)
        elif ver == "2":  # introduced the repository and project property
            buildsetID, branch, baserev, patchlevel, diff, repository, project = s[:
                                                                                   7]
            builderNames = s[7:]
            if branch == "":
                branch = None
            if baserev == "":
                baserev = None
            patchlevel = int(patchlevel)
            patch = (patchlevel, diff)
            ss = SourceStamp(branch,
                             baserev,
                             patch,
                             repository=repository,
                             project=project)
        else:
            raise BadJobfile("unknown version '%s'" % ver)
        return builderNames, ss, buildsetID

    def messageReceived(self, filename):
        md = os.path.join(self.parent.parent.basedir, self.jobdir)
        if runtime.platformType == "posix":
            # open the file before moving it, because I'm afraid that once
            # it's in cur/, someone might delete it at any moment
            path = os.path.join(md, "new", filename)
            f = open(path, "r")
            os.rename(os.path.join(md, "new", filename),
                      os.path.join(md, "cur", filename))
        else:
            # do this backwards under windows, because you can't move a file
            # that somebody is holding open. This was causing a Permission
            # Denied error on bear's win32-twisted1.3 buildslave.
            os.rename(os.path.join(md, "new", filename),
                      os.path.join(md, "cur", filename))
            path = os.path.join(md, "cur", filename)
            f = open(path, "r")

        try:
            builderNames, ss, jobid = self.parseJob(f)
        except BadJobfile:
            log.msg("%s reports a bad jobfile in %s" % (self, filename))
            log.err()
            return
        # Validate/fixup the builder names.
        builderNames = self.filterBuilderList(builderNames)
        if not builderNames:
            return
        reason = "'try' job"
        d = self.parent.db.runInteraction(self._try, ss, builderNames, reason)

        def _done(ign):
            self.parent.loop_done()  # so it will notify builder loop

        d.addCallback(_done)
        return d

    def _try(self, t, ss, builderNames, reason):
        db = self.parent.db
        ssid = db.get_sourcestampid(ss, t)
        bsid = self.create_buildset(ssid, reason, t, builderNames=builderNames)
        return bsid
Esempio n. 5
0
 def __init__(self, name, builderNames, jobdir,
              properties={}):
     base.BaseScheduler.__init__(self, name, builderNames, properties)
     self.jobdir = jobdir
     self.watcher = MaildirService()
     self.watcher.setServiceParent(self)
Esempio n. 6
0
class Try_Jobdir(TryBase):
    compare_attrs = ( 'name', 'builderNames', 'jobdir', 'properties' )

    def __init__(self, name, builderNames, jobdir,
                 properties={}):
        base.BaseScheduler.__init__(self, name, builderNames, properties)
        self.jobdir = jobdir
        self.watcher = MaildirService()
        self.watcher.setServiceParent(self)

    def setServiceParent(self, parent):
        sm = parent
        m = sm.parent
        self.watcher.setBasedir(os.path.join(m.basedir, self.jobdir))
        TryBase.setServiceParent(self, parent)

    def parseJob(self, f):
        # jobfiles are serialized build requests. Each is a list of
        # serialized netstrings, in the following order:
        #  "1", the version number of this format
        #  buildsetID, arbitrary string, used to find the buildSet later
        #  branch name, "" for default-branch
        #  base revision, "" for HEAD
        #  patchlevel, usually "1"
        #  patch
        #  builderNames...
        p = JobFileScanner()
        p.dataReceived(f.read())
        if p.error:
            raise BadJobfile("unable to parse netstrings")
        s = p.strings
        ver = s.pop(0)
        if ver == "1":
            buildsetID, branch, baserev, patchlevel, diff = s[:5]
            builderNames = s[5:]
            if branch == "":
                branch = None
            if baserev == "":
                baserev = None
            patchlevel = int(patchlevel)
            patch = (patchlevel, diff)
            ss = SourceStamp("Old client", branch, baserev, patch)
        elif ver == "2": # introduced the repository and project property
            buildsetID, branch, baserev, patchlevel, diff, repository, project = s[:7]
            builderNames = s[7:]
            if branch == "":
                branch = None
            if baserev == "":
                baserev = None
            patchlevel = int(patchlevel)
            patch = (patchlevel, diff)
            ss = SourceStamp(branch, baserev, patch, repository=repository,
                             project=project)
        else:
            raise BadJobfile("unknown version '%s'" % ver)
        return builderNames, ss, buildsetID

    def messageReceived(self, filename):
        md = os.path.join(self.parent.parent.basedir, self.jobdir)
        if runtime.platformType == "posix":
            # open the file before moving it, because I'm afraid that once
            # it's in cur/, someone might delete it at any moment
            path = os.path.join(md, "new", filename)
            f = open(path, "r")
            os.rename(os.path.join(md, "new", filename),
                      os.path.join(md, "cur", filename))
        else:
            # do this backwards under windows, because you can't move a file
            # that somebody is holding open. This was causing a Permission
            # Denied error on bear's win32-twisted1.3 buildslave.
            os.rename(os.path.join(md, "new", filename),
                      os.path.join(md, "cur", filename))
            path = os.path.join(md, "cur", filename)
            f = open(path, "r")

        try:
            builderNames, ss, jobid = self.parseJob(f)
        except BadJobfile:
            log.msg("%s reports a bad jobfile in %s" % (self, filename))
            log.err()
            return
        # Validate/fixup the builder names.
        builderNames = self.filterBuilderList(builderNames)
        if not builderNames:
            return
        reason = "'try' job"
        d = self.parent.db.runInteraction(self._try, ss, builderNames, reason)
        def _done(ign):
            self.parent.loop_done() # so it will notify builder loop
        d.addCallback(_done)
        return d

    def _try(self, t, ss, builderNames, reason):
        db = self.parent.db
        ssid = db.get_sourcestampid(ss, t)
        bsid = self.create_buildset(ssid, reason, t, builderNames=builderNames)
        return bsid
Esempio n. 7
0
 def __init__(self, maildir, prefix=None):
     MaildirService.__init__(self, maildir)
     self.prefix = prefix
     if prefix and not prefix.endswith("/"):
         log.msg("%s: you probably want your prefix=('%s') to end with "
                 "a slash")
class Try_Jobdir(TryBase):
    compare_attrs = ( 'name', 'builderNames', 'jobdir', 'properties' )

    def __init__(self, name, builderNames, jobdir, properties={}):
        TryBase.__init__(self, name, builderNames, properties)
        self.jobdir = jobdir
        self.watcher = MaildirService()
        self.watcher.setServiceParent(self)

    def setServiceParent(self, parent):
        self.watcher.setBasedir(os.path.join(parent.basedir, self.jobdir))
        TryBase.setServiceParent(self, parent)

    def parseJob(self, f):
        # jobfiles are serialized build requests. Each is a list of
        # serialized netstrings, in the following order:
        #  "1", the version number of this format
        #  buildsetID, arbitrary string, used to find the buildSet later
        #  branch name, "" for default-branch
        #  base revision, "" for HEAD
        #  patchlevel, usually "1"
        #  patch
        #  builderNames...
        p = JobFileScanner()
        p.dataReceived(f.read())
        if p.error:
            raise BadJobfile("unable to parse netstrings")
        s = p.strings
        ver = s.pop(0)
        if ver != "1":
            raise BadJobfile("unknown version '%s'" % ver)
        buildsetID, branch, baserev, patchlevel, diff = s[:5]
        builderNames = s[5:]
        if branch == "":
            branch = None
        if baserev == "":
            baserev = None
        patchlevel = int(patchlevel)
        patch = (patchlevel, diff)
        ss = SourceStamp(branch, baserev, patch)
        return builderNames, ss, buildsetID

    def messageReceived(self, filename):
        md = os.path.join(self.parent.basedir, self.jobdir)
        if runtime.platformType == "posix":
            # open the file before moving it, because I'm afraid that once
            # it's in cur/, someone might delete it at any moment
            path = os.path.join(md, "new", filename)
            f = open(path, "r")
            os.rename(os.path.join(md, "new", filename),
                      os.path.join(md, "cur", filename))
        else:
            # do this backwards under windows, because you can't move a file
            # that somebody is holding open. This was causing a Permission
            # Denied error on bear's win32-twisted1.3 buildslave.
            os.rename(os.path.join(md, "new", filename),
                      os.path.join(md, "cur", filename))
            path = os.path.join(md, "cur", filename)
            f = open(path, "r")

        try:
            builderNames, ss, bsid = self.parseJob(f)
        except BadJobfile:
            log.msg("%s reports a bad jobfile in %s" % (self, filename))
            log.err()
            return
        # compare builderNames against self.builderNames
        # TODO: think about this some more.. why bother restricting it?
        # perhaps self.builderNames should be used as the default list
        # instead of being used as a restriction?
        for b in builderNames:
            if not b in self.builderNames:
                log.msg("%s got jobfile %s with builder %s" % (self,
                                                               filename, b))
                log.msg(" but that wasn't in our list: %s"
                        % (self.builderNames,))
                return

        reason = "'try' job"
        bs = buildset.BuildSet(builderNames, ss, reason=reason, 
                    bsid=bsid, properties=self.properties)
        self.submitBuildSet(bs)
Esempio n. 9
0
 def __init__(self, name, builderNames, jobdir,
              properties={}, categories=None):
     _Base.__init__(self, name, builderNames, properties, categories)
     self.jobdir = jobdir
     self.watcher = MaildirService()
     self.watcher.setServiceParent(self)
Esempio n. 10
0
 def __init__(self, name, builderNames, jobdir):
     TryBase.__init__(self, name, builderNames)
     self.jobdir = jobdir
     self.watcher = MaildirService()
     self.watcher.setServiceParent(self)
Esempio n. 11
0
 def __init__(self, name, builderNames, jobdir):
     TryBase.__init__(self, name, builderNames)
     self.jobdir = jobdir
     self.watcher = MaildirService()
     self.watcher.setServiceParent(self)