<commit_before>'''
Created on Dec 25, 2012

__author__ = "Elizabeth 'pidge' Flanagan"
__copyright__ = "Copyright 2013, Intel Corp."
__credits__ = ["<NAME>"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "<NAME>"
__email__ = "<EMAIL>"
'''

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
from buildbot.steps.shell import ShellCommand

class SetDest(ShellCommand):
    name = "SetDest" 
    haltOnFailure = True 
    flunkOnFailure = True
    name = "Destination"
    description = ["Setting %s" % name]
    descriptionDone = [name]

    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 k, v in argdict.iteritems():
            setattr(self, k, v)
        self.description = "Setting Destination"
        # Timeout needs to be passed to LoggingBuildStep as a kwarg
        self.timeout = 100
        kwargs['timeout']=self.timeout
        ShellCommand.__init__(self, **kwargs)

    def start(self):
        DEST = self.getProperty("DEST")
        log.msg(os.environ.get("BUILD_PUBLISH_DIR"))
        if DEST is not None:
            self.finished(SUCCESS)
        else:
            buildername=self.getProperty("buildername")
            self.workdir=os.path.join(self.slaveworkdir, buildername)
            if str(self.getProperty("custom_release_me_" + buildername)) == "True":             
                rel_name = self.getProperty("custom_release_name_"  + buildername)
                if not rel_name or rel_name == "":
                    rel_name == self.getProperty(commit-description)
                DEST=os.path.normpath(os.path.join(
                                      os.environ.get("RELEASE_PUBLISH_DIR"),rel_name))
                if os.environ.get("RELEASE_PUBLISH_DIR") not in DEST:
                    self.step_status.setText(["Failed Setting Destination:", "Bad Release Name."])
                    self.finished(FAILURE)
            else:
                DEST = os.path.normpath(os.path.join(
                                        os.environ.get("BUILD_PUBLISH_DIR"), buildername))
                if os.environ.get("BUILD_PUBLISH_DIR") not in DEST:
                    self.step_status.setText(["Failed Setting Destination:", "Bad Release Name."])
                    self.finished(FAILURE)
                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.setProperty("DESTDIR", os.path.basename(os.path.normpath(DEST)))          
            self.finished(SUCCESS)
<commit_msg>SetDest.py: Use new properties from nightly<commit_after>'''
Created on Dec 25, 2012

__author__ = "Elizabeth 'pidge' Flanagan"
__copyright__ = "Copyright 2013, Intel Corp."
__credits__ = ["<NAME>"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = "<NAME>"
__email__ = "<EMAIL>"
'''

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
from buildbot.steps.shell import ShellCommand

class SetDest(ShellCommand):
    name = "SetDest" 
    haltOnFailure = True 
    flunkOnFailure = True
    name = "Destination"
    description = ["Setting %s" % name]
    descriptionDone = [name]

    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 k, v in argdict.iteritems():
            setattr(self, k, v)
        self.description = "Setting Destination"
        # Timeout needs to be passed to LoggingBuildStep as a kwarg
        self.timeout = 100
        kwargs['timeout']=self.timeout
        ShellCommand.__init__(self, **kwargs)

    def start(self):
        DEST = self.getProperty("DEST")
        log.msg(os.environ.get("BUILD_PUBLISH_DIR"))
        if DEST is not None:
            self.finished(SUCCESS)
        else:
            buildername=self.getProperty("buildername")
            self.workdir=os.path.join(self.slaveworkdir, buildername)
            if str(self.getProperty("custom_release_me_" + buildername)) == "True":             
                rel_name = self.getProperty("custom_release_name_"  + buildername)
                if not rel_name or rel_name == "":
                    rel_name == self.getProperty(commit-description)
                DEST=os.path.normpath(os.path.join(
                                      os.environ.get("RELEASE_PUBLISH_DIR"),rel_name))
                if os.environ.get("RELEASE_PUBLISH_DIR") not in DEST:
                    self.step_status.setText(["Failed Setting Destination:", "Bad Release Name."])
                    self.finished(FAILURE)
            else:
                DEST = os.path.normpath(os.path.join(
                                        os.environ.get("BUILD_PUBLISH_DIR"), buildername))
                if os.environ.get("BUILD_PUBLISH_DIR") not in DEST:
                    self.step_status.setText(["Failed Setting Destination:", "Bad Release Name."])
                    self.finished(FAILURE)
                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)

{'fraction_non_alphanumeric': 0.10844892812105927, 'fraction_numerical': 0.004287515762925599, 'mean_word_length': 1.8325, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5010687', 'n_tokens_mistral': 2384, 'n_tokens_neox': 2245, 'n_words': 511}