Exemple #1
0
def watchdb(db):
    while 1:
        try:
            buildqueue.get(timeout=60)
        except simplethread.Empty:
            pass
        for job in db.select('jobs', where="builder is null and done='f'"):
            simplethread.spawn(lambda: start_build(db, job))
Exemple #2
0
 def run(self, *args, **kwargs):
     self.lastoutput = StringIO.StringIO()
     self.note(' '.join(args))
     p = subprocess.Popen(args, cwd=self.cwd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
     simplethread.spawn(lambda: self._gobble(p.stderr))
     simplethread.spawn(lambda: self._gobble(p.stdout))
     simplethread.spawn(lambda: self._deathgobble(p.wait))
     
     if kwargs.get('bg'):
         simplethread.spawn(lambda: self._outputdata())
         return
     else:
         self._outputdata()
         return p.returncode
Exemple #3
0
    def run(self, *args, **kwargs):
        self.lastoutput = StringIO.StringIO()
        self.note(' '.join(args))
        p = subprocess.Popen(args,
                             cwd=self.cwd,
                             stdout=subprocess.PIPE,
                             stderr=subprocess.PIPE)
        simplethread.spawn(lambda: self._gobble(p.stderr))
        simplethread.spawn(lambda: self._gobble(p.stdout))
        simplethread.spawn(lambda: self._deathgobble(p.wait))

        if kwargs.get('bg'):
            simplethread.spawn(lambda: self._outputdata())
            return
        else:
            self._outputdata()
            return p.returncode
Exemple #4
0
    
    job_id = db.insert('jobs', commit_hash=d['commit']['id'], message=d['commit']['message'], author=d['commit']['author_name'])
    builder.buildqueue.put(job_id)
    
    announce("Deploying: %s\n%s" % (d['commit']['message'], url_for('show_job', job_id=job_id, _external=True)))
    return "queued\n"

@app.route('/announcements.json')
def announcements():
    last_check = request.args.get('since')
    
    if last_check:
        print last_check
        r = db.select('announcements', where="created_at > $last_check", order='created_at asc', vars=locals())
    else:
        r = db.select('announcements', order='created_at asc', limit=10)
    
    dthandler = lambda obj: obj.isoformat() if isinstance(obj, datetime.datetime) else None
    return json.dumps(r.list(), default=dthandler)

def announce(announcement):
    return db.insert('announcements', content=announcement)

import utils
app.template_filter('timesince')(utils.friendly_time)

if __name__ == "__main__":
    simplethread.spawn(lambda: builder.watchdb(db))
    port = int(os.environ.get("PORT", 5000))
    app.run(host='0.0.0.0', port=port)
Exemple #5
0
def watchdb(db):
    while 1:
        try: buildqueue.get(timeout=60)
        except simplethread.Empty: pass
        for job in db.select('jobs', where="builder is null and done='f'"):
            simplethread.spawn(lambda: start_build(db, job))
Exemple #6
0
@app.route('/announcements.json')
def announcements():
    last_check = request.args.get('since')

    if last_check:
        print last_check
        r = db.select('announcements',
                      where="created_at > $last_check",
                      order='created_at asc',
                      vars=locals())
    else:
        r = db.select('announcements', order='created_at asc', limit=10)

    dthandler = lambda obj: obj.isoformat() if isinstance(
        obj, datetime.datetime) else None
    return json.dumps(r.list(), default=dthandler)


def announce(announcement):
    return db.insert('announcements', content=announcement)


import utils
app.template_filter('timesince')(utils.friendly_time)

if __name__ == "__main__":
    simplethread.spawn(lambda: builder.watchdb(db))
    port = int(os.environ.get("PORT", 5000))
    app.run(host='0.0.0.0', port=port)