Esempio n. 1
0
    def send_report(self, report):
        self.annotate_report(report)
        self.shorten_task_names(report)

        if self._artifact:
            dirname = fs.path.dirname(self._artifact)
            if dirname:
                fs.makedirs(dirname)
            with open(self._artifact, "w") as f:
                f.write(report.transform(self._stylesheet))

        if report.has_failure():
            if not self._failure:
                return
        else:
            if not self._success:
                return

        msg = EmailMessage()
        msg['Subject'] = self._subject
        msg['From'] = self._from
        msg['To'] = ", ".join(utils.unique_list(self._to.split()))
        msg.set_content(
            "Your e-mail client cannot display HTML formatted e-mails.")
        msg.add_alternative(report.transform(self._stylesheet), subtype='html')

        with smtplib.SMTP(self._server) as server:
            log.info("Sending email report to {}", self._to)
            server.send_message(msg)
Esempio n. 2
0
    def setup(self, deps, tools):
        self.deps = deps
        self.ws = tools.builddir(self._testMethodName)
        with tools.cwd(self.ws):
            tools.setenv("JOLT_CONFIG_PATH", self.ws)
            tools.write_file(
                "default.joltxmanifest", """
<?xml version="1.0" ?>
<jolt-manifest workspace="." />
""")
            tools.write_file(
                "test.jolt", """
from jolt import *
from jolt.error import raise_error_if
from jolt.influence import global_string
global_string("{test}")
""".format(test=self._testMethodName) + self._recipe())
            tools.write_file("test.conf", self._config())
            tools.write_file("net.conf", self._network_config())

            for filename, content in self._files():
                content = "\n".join([l[8:] for l in content.splitlines()])
                dirname = fs.path.dirname(filename)
                if dirname:
                    print(dirname)
                    fs.makedirs(fs.path.join(self.ws, dirname))
                tools.write_file(filename, content)
Esempio n. 3
0
 def __init__(self, location, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self._location = location
     if location is not None:
         dirname = fs.path.dirname(location)
         if dirname:
             fs.makedirs(dirname)
Esempio n. 4
0
 def __init__(self, cache):
     super(DiskVolume, self).__init__()
     self._cache = cache
     self._path = config.get(NAME, "path")
     raise_error_if(not self._path, "volume path not configured")
     fs.makedirs(self._path)
     self._upload = config.getboolean(NAME, "upload", True)
     self._download = config.getboolean(NAME, "download", True)
Esempio n. 5
0
    def task_finished(self, task):
        if not task.has_artifact():
            return

        srcpath = cache.ArtifactCache.get().get_path(task)
        destpath = fs.path.join(loader.get_workspacedir(), self._path,
                                utils.canonical(task.short_qualified_name))

        if fs.path.exists(srcpath):
            fs.unlink(destpath, ignore_errors=True)
            fs.makedirs(fs.path.dirname(destpath))
            fs.symlink(srcpath, destpath)
Esempio n. 6
0
File: amqp.py Progetto: srand/jolt
            def selfdeploy(self):
                """ Installs the correct version of Jolt as specified in execution request. """

                tools = Tools()
                manifest = JoltManifest()
                try:
                    manifest.parse()
                    ident = manifest.get_parameter("jolt_identity")
                    url = manifest.get_parameter("jolt_url")
                    if not ident or not url:
                        return "jolt"

                    requires = manifest.get_parameter("jolt_requires")

                    log.info("Jolt version: {}", ident)

                    src = "build/selfdeploy/{}/src".format(ident)
                    env = "build/selfdeploy/{}/env".format(ident)

                    if not fs.path.exists(env):
                        try:
                            fs.makedirs(src)
                            tools.run("curl {} | tar zx -C {}", url, src)
                            tools.run("virtualenv {}", env)
                            tools.run(". {}/bin/activate && pip install -e {}",
                                      env, src)
                            if requires:
                                tools.run(
                                    ". {}/bin/activate && pip install {}", env,
                                    requires)
                        except Exception as e:
                            tools.rmtree("build/selfdeploy/{}",
                                         ident,
                                         ignore_errors=True)
                            raise e

                    return ". {}/bin/activate && jolt".format(env)
                except Exception as e:
                    log.exception()
                    raise e
Esempio n. 7
0
from jolt import config
from jolt.error import JoltError
from jolt import filesystem as fs
from jolt import colors

default_path = fs.path.join(config.get_logpath(), "jolt.log")
logfile = config.get("jolt", "logfile", default_path)
logsize = config.getsize("jolt", "logsize",
                         os.environ.get("JOLT_LOGSIZE", 10 * 1024**2))  # 10MiB
logcount = config.getint("jolt", "logcount",
                         os.environ.get("JOLT_LOGCOUNT", 1))

dirpath = fs.path.dirname(logfile)
if not fs.path.exists(dirpath):
    fs.makedirs(dirpath)
with open(logfile, "a") as f:
    f.write(
        "--------------------------------------------------------------------------------\n"
    )

################################################################################

ERROR = logging.ERROR
WARNING = logging.WARNING
INFO = logging.INFO
VERBOSE = 15
DEBUG = logging.DEBUG
EXCEPTION = logging.DEBUG + 1
STDOUT = logging.INFO + 1
STDERR = logging.ERROR + 1