Package buildbot :: Package scripts :: Module tryserver
[frames] | no frames]

Source Code for Module buildbot.scripts.tryserver

 1  # This file is part of Buildbot.  Buildbot is free software: you can 
 2  # redistribute it and/or modify it under the terms of the GNU General Public 
 3  # License as published by the Free Software Foundation, version 2. 
 4  # 
 5  # This program is distributed in the hope that it will be useful, but WITHOUT 
 6  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
 7  # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
 8  # details. 
 9  # 
10  # You should have received a copy of the GNU General Public License along with 
11  # this program; if not, write to the Free Software Foundation, Inc., 51 
12  # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 
13  # 
14  # Copyright Buildbot Team Members 
15   
16  from __future__ import with_statement 
17   
18  import os 
19  import sys 
20  import time 
21  from hashlib import md5 
22   
23 -def tryserver(config):
24 jobdir = os.path.expanduser(config["jobdir"]) 25 job = sys.stdin.read() 26 # now do a 'safecat'-style write to jobdir/tmp, then move atomically to 27 # jobdir/new . Rather than come up with a unique name randomly, I'm just 28 # going to MD5 the contents and prepend a timestamp. 29 timestring = "%d" % time.time() 30 m = md5() 31 m.update(job) 32 jobhash = m.hexdigest() 33 fn = "%s-%s" % (timestring, jobhash) 34 tmpfile = os.path.join(jobdir, "tmp", fn) 35 newfile = os.path.join(jobdir, "new", fn) 36 with open(tmpfile, "w") as f: 37 f.write(job) 38 os.rename(tmpfile, newfile) 39 40 return 0
41