1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
'''
Created on Dec 25, 2012
__author__ = "Elizabeth 'pidge' Flanagan"
__copyright__ = "Copyright 2013, Intel Corp."
__credits__ = ["Elizabeth Flanagan"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "Elizabeth Flanagan"
__email__ = "elizabeth.flanagan@intel.com"
'''
from buildbot.process.buildstep import BuildStep
from buildbot.status import progress
from buildbot.status.results import SUCCESS, WARNINGS, FAILURE, SKIPPED, \
EXCEPTION, RETRY, worst_status
import os, datetime
import cPickle as pickle
from autobuilder.config import *
from twisted.python import log
class SetDest(BuildStep):
name = "SetDest"
def __init__(self, factory, argdict=None, **kwargs):
self.target=""
for k, v in argdict.iteritems():
setattr(self, k, v)
self.slaveworkdir=os.path.join(os.path.join(YOCTO_ABBASE, "yocto-slave"))
self.description = ["Setting", "Destination"]
for p in self.__class__.parms:
if kwargs.has_key(p):
setattr(self, p, kwargs[p])
del kwargs[p]
self._pendingLogObservers = []
self._acquiringLock = None
self.stopped = False
def start(self):
DEST = self.getProperty("DEST")
if DEST is not None:
self.finished(SUCCESS)
else:
buildername=self.getProperty("buildername")
self.workdir=os.path.join(self.slaveworkdir, buildername)
DEST = os.path.join(os.environ.get("BUILD_PUBLISH_DIR").strip('"').strip("'"), self.target)
DEST_DATE=datetime.datetime.now().strftime("%Y%m%d")
DATA_FILE = os.path.join(YOCTO_ABBASE, self.target + "_dest.dat")
try:
pfile = open(DATA_FILE, 'rb')
data = pickle.load(pfile)
except:
pfile = open(DATA_FILE, 'wb')
data = {}
pickle.dump(data, pfile)
pfile.close()
# we can't os.path.exists here as we don't neccessarily have
# access to the slave dest from master. So we keep a cpickle of
# the dests.
try:
# if the dictionary entry exists, we increment value by one, then repickle
REV=data[os.path.join(DEST, DEST_DATE)]
REV=int(REV) + 1
except:
REV=1
data[os.path.join(DEST, DEST_DATE)] = REV
pfile = open(DATA_FILE, 'wb')
pickle.dump(data, pfile)
pfile.close()
DEST = os.path.join(DEST, DEST_DATE + "-" + str(REV))
self.setProperty("DEST", DEST)
self.finished(SUCCESS)
|