コード例 #1
0
    def launch_process(self, peer, launch_data, restore_config=[]):
        data = launch_data
        wait = 0
        p = os.path.expanduser(data['path'])
        if not os.path.isabs(p):
            path = os.path.join(launcher_tools.obci_root(), p)
            path = os.path.abspath(path)
        else:
            path = os.path.realpath(p)

        dirname = os.path.dirname(path)
        if not launcher_tools.obci_root() in dirname:
            launcher_tools.update_pythonpath(dirname)
            launcher_tools.update_obci_syspath(dirname)
            self.env.update({"PYTHONPATH" : os.environ["PYTHONPATH"]})

            self.logger.info("PYTHONPATH UPDATED  for " + peer +\
                     "!!!!!!!!   " + str(self.env["PYTHONPATH"]))
        args = data['args']
        args = self._attach_base_config_path(path, args)
        args += ['-p', 'experiment_uuid', self.experiment_uuid]
        if peer.startswith('config_server'):
            args += ['-p', 'launcher_socket_addr', self.cs_addr]

            if restore_config:
                args += ['-p', 'restore_peers', ' '.join(restore_config)]
            # wait = 0.5
        if "log_dir" in args:
            idx = args.index("log_dir") + 1
            log_dir = args[idx]
            log_dir = os.path.join(log_dir, self.name)
            args[idx] = log_dir
        else:
            log_dir = os.path.join(CONFIG_DEFAULTS["log_dir"], self.name)
            args += ['-p', 'log_dir', log_dir]
        if not os.path.exists(log_dir):
            os.makedirs(log_dir)

        proc, details = self._launch_process(path, args, data['peer_type'],
                                                    peer, env=self.env, capture_io=NO_STDIO)
        info_obj = {
            "path": path,
            "args": args,
            "peer": peer
        }
        if proc is not None:
            self.processes[peer] = proc
        else:
            self.logger.error("OBCI LAUNCH FAILED")
            send_msg(self._publish_socket, self.mtool.fill_msg("obci_launch_failed",
                                                    machine=self.machine, path=info_obj['path'],
                                                    args=info_obj['args'], details=details))
            self.processes = {}
            self.subprocess_mgr.killall(force=True)

        return proc, details, wait, info_obj
コード例 #2
0
ファイル: obci_script.py プロジェクト: karolaug/openbci
import os
import argparse
import json
import time
import subprocess
import sys
import ConfigParser
import signal
import errno
import socket

import zmq

from obci.control.launcher import launcher_tools
launcher_tools.update_obci_syspath()
launcher_tools.update_pythonpath()

import obci_server
import obci_client
import obci.control.common.obci_control_settings as settings
import obci.control.common.net_tools as net
import view
from obci.control.common.config_helpers import OBCISystemError
from obci.control.peer.peer_cmd import PeerCmd
import obci.control.peer.peer_cmd as peer_cmd

disp = view.OBCIViewText()


def cmd_srv(args):
コード例 #3
0
ファイル: obci_script.py プロジェクト: karolaug/openbci
import os
import argparse
import json
import time
import subprocess
import sys
import ConfigParser
import signal
import errno
import socket

import zmq

from obci.control.launcher import launcher_tools
launcher_tools.update_obci_syspath()
launcher_tools.update_pythonpath()

import obci_server
import obci_client
import obci.control.common.obci_control_settings as settings
import obci.control.common.net_tools as net
import view
from obci.control.common.config_helpers import OBCISystemError
from obci.control.peer.peer_cmd import PeerCmd
import obci.control.peer.peer_cmd as peer_cmd


disp = view.OBCIViewText()

def cmd_srv(args):
コード例 #4
0
    def _launch_processes(self, launch_data, restore_config=[]):
        proc, details = None, None
        success = True
        path, args = None, None

        self.status = launcher_tools.LAUNCHING

        ldata = []
        if 'config_server' in launch_data:
            ldata.append(('config_server', launch_data['config_server']))
        if 'amplifier' in launch_data:
            ldata.append(('amplifier', launch_data['amplifier']))
        for peer, data in launch_data.iteritems():
            if (peer, data) not in ldata:
                ldata.append((peer, data))

        for peer, data in ldata:#self.launch_data.iteritems():
            wait = 0
            if peer.startswith('mx'):
                continue
            p = os.path.expanduser(data['path'])
            if not os.path.isabs(p):
                path = os.path.join(launcher_tools.obci_root(), p)
            else:
                path = os.path.realpath(p)

            dirname = os.path.dirname(path)
            if not launcher_tools.obci_root() in dirname:
                launcher_tools.update_pythonpath(dirname)
                launcher_tools.update_obci_syspath(dirname)
                self.env.update({"PYTHONPATH" : os.environ["PYTHONPATH"]})

                self.logger.info("PYTHONPATH UPDATED  for " + peer +\
                         "!!!!!!!!   " + str(self.env["PYTHONPATH"]))
            args = data['args']
            if peer.startswith('config_server'):
                args += ['-p', 'launcher_socket_addr', self.cs_addr]
                args += ['-p', 'experiment_uuid', self.experiment_uuid]

                if restore_config:
                    args += ['-p', 'restore_peers', ' '.join(restore_config)]
                wait = 0.4
            if "log_dir" in args:
                idx = args.index("log_dir") + 1
                log_dir = args[idx]
                log_dir = os.path.join(log_dir, self.name)
                args[idx] = log_dir
            else:
                log_dir = os.path.join(CONFIG_DEFAULTS["log_dir"], self.name)
                args += ['-p', 'log_dir', log_dir]
            if not os.path.exists(log_dir):
                os.makedirs(log_dir)

            proc, details = self._launch_process(path, args, data['peer_type'],
                                                        peer, env=self.env, capture_io=NO_STDIO)
            if proc is not None:
                self.processes[peer] = proc
            else:
                success = False
                break
            time.sleep(wait)
        if success:
            send_msg(self._publish_socket, self.mtool.fill_msg("all_peers_launched",
                                                    machine=self.machine))
        else:
            self.logger.error("OBCI LAUNCH FAILED")
            send_msg(self._publish_socket, self.mtool.fill_msg("obci_launch_failed",
                                                    machine=self.machine, path=path,
                                                    args=args, details=details))
            self.processes = {}
            self.subprocess_mgr.killall(force=True)