Example #1
0
def _extractActors(group_number, actors):
    """
    Extract actors into group directories.

    :param group_number: The number of the group to extract into.
    :type group_number: ``int``
    :param actors: The set of actors to extract.
    :type actors: ``set(str)``

    """

    experiment_dir = controlcentre.getExperimentPath()

    for actor_name in actors:
        actor = config.getSettings('actors')['defs'][actor_name]
        type=actor['type'].upper()

        extractpath = os.path.join(
            controlcentre.getExperimentPath(),
            "Group_"+str(group_number)
        )

        actorTGZ = tarfile.open(actor['file'],'r:gz')
        extractpath = os.path.join(extractpath, "Vazels", type+"_launcher")

        actorTGZ.extractall(path=extractpath)
Example #2
0
def _extractSueComponents(group_number, sueComps):
    """
    Extract SUE components into the appropriate directories.
    
    :param group_number: The number of the group to extract into.
    :type group_number: ``int``
    :param sueComps: The set of names of Sue Componenets to extract.
    :type sueComps: ``set(str)``
    
    """
    
    experiment_dir = config.getSettings('control_centre')['experiment_dir']
    
    for sueComp_name in sueComps:
        try:
            sueCompFile = config.getSettings('SUE')['defs'][sueComp_name]['file']
        except KeyError:
            print sueComp_name
            print config.getSettings('SUE')['defs']
            raise restlite.Status, "500, Failed to extract Sue component"
    
        extractpath = os.path.join(
            controlcentre.getExperimentPath(),
            "Group_"+str(group_number),
            "SUE"
        )
        
        sueCompTGZ = tarfile.open(sueCompFile,'r:gz')
        sueCompTGZ.extractall(path=extractpath)
Example #3
0
def issueControlCentreCommand(command, args=[], extraargs=[], afterwards=None):
    """
    Send a command to the command client and optionally run a function on finish.

    :param command: The command to run.
    :type command: ``str``
    :param args: List of arguments to the command. (optional)
    :type args: ``list(str)``
    :param extraargs: Arguments to the script, i.e. those beginning with "--". (optional)
    :type extraargs: ``dict``
    :param afterwards: The function to run afterwards (optional).
    :type afterwards: ``func``, takes the output file as a parameter. 
    :returns: ``True`` if the control centre is running, ``False`` otherwise.
    :rtype: ``bool``

    """

    if controlcentre.runningState() is not True:
        return False
  
    experiment_path = controlcentre.getExperimentPath()
    clientargs = __getCommandLineClientArgs()
    for arg in extraargs:
        clientargs.append(arg + "=" + extraargs[arg])
    clientargs.append(command)
    clientargs.extend(args)

    ioFile = open("/dev/null")
    try:
        ioFile = tempfile.SpooledTemporaryFile(256)
    except: pass # Ignore fuckups and use /dev/null instead

    command_process = subprocess.Popen(clientargs, cwd=getCommandLineClientPath(), stdout=ioFile, stderr=subprocess.STDOUT)

    if afterwards is not None:
        def _runWhenDone(process, func, io):
            if process.poll() is None:
                Timer(interval=1, function=_runWhenDone, args=[process, func, io]).start()
            else:
                func(io)
                io.close()

        _runWhenDone(command_process, afterwards, ioFile)

    return True
Example #4
0
    def GET(self, request):
        """
        Grab the experiment output data.

        :returns: JSON representation of the experiment output data.
        :rtype: ``json``
        :raises: :exc:`restlite.Status` 500 if the output could not be parsed.

        """

        authentication.login(request)

        # We want the proper experiment path that vazelsmanager tells us
        exp_dir = controlcentre.getExperimentPath()
        path = os.path.join(exp_dir,"Output_Folder")
        parsed = pbparser.scan_output(path)
        # If the parsing broke in any way we get back None
        if parsed is None:
            raise restlite.Status, "500 Could Not Read Output Data"
        return request.response(parsed)
Example #5
0
    def GET(self, request):
        """
        Get the tgz archive of the probe folder.

        The filename of the resulting file will be taken by the browser
        from the location this handler was attached to.

        .. todo:: Work out why FF cannot open this fil directly (without
                  saving it first)

        .. todo:: Allow this file through the testing proxy.

        :raises: :exc:`restlite.Status` 400 if the experiment is not set up.

                 :exc:`restlite.Status` 500 if the folder could not be served.

        """

        authentication.login(request)
        if commandclient.vazelsPhase() != commandclient.Statuses["STATUS_RUNNING"]:
            raise restlite.Status, "400 Can't get the Probe until the experiment is set up"

        probePath = os.path.join(controlcentre.getExperimentPath(), "Probe_Folder")

        with tempfile.SpooledTemporaryFile(1024) as temp:
            tar = tarfile.open(fileobj=temp, mode="w:gz")
            tar.add(name=probePath, arcname="Probe_Folder")
            tar.close()

            temp.seek(0)

            # Don't have this in the return statement
            # It will break EVERYTHING mysteriously
            content = temp.read()

            return request.response(content, "application/x-gzip")

        raise restlite.Status, "500 Could Not Serve Probe File"