Beispiel #1
0
    def processFinished(self, exit_code, exit_status):
        if exit_code:
            if exit_code == 101:
                message = _translate('GUIMSG',
                            'script %s failed to start !') % (
                                ray.highlightText(self.getPath()))
            else:
                message = _translate('GUIMSG',
                        'script %s terminated with exit code %i') % (
                            ray.highlightText(self.getPath()), exit_code)

            if self.src_addr:
                self.send(self.src_addr, '/error', self.src_path,
                          - exit_code, message)
        else:
            self.sendGuiMessage(
                _translate('GUIMSG', '...script %s finished. ---')
                    % ray.highlightText(self.getPath()))

            if self.src_addr:
                self.send(self.src_addr, '/reply',
                          self.src_path, 'script finished')
Beispiel #2
0
    def start(self, command, src_addr=None, previous_slot=(None, '')):
        if self.isRunning():
            return False

        command_string = ''
        if command == ray.Command.START:
            command_string = 'start'
        elif command == ray.Command.SAVE:
            command_string = 'save'
        elif command == ray.Command.STOP:
            command_string = 'stop'
        else:
            return False

        scripts_dir = "%s/%s.%s" % \
            (self.client.session.path, ray.SCRIPTS_DIR, self.client.client_id)
        script_path = "%s/%s.sh" % (scripts_dir, command_string)

        if not os.access(script_path, os.X_OK):
            return False

        self._pending_command = command

        if src_addr:
            # Remember the caller of the function calling the script
            # Then, when script is finished
            # We could reply to this (address, path)
            self._initial_caller = previous_slot

        self.src_addr = src_addr

        process_env = QProcessEnvironment.systemEnvironment()
        process_env.insert('RAY_CONTROL_PORT', str(self.getServerPort()))
        process_env.insert('RAY_CLIENT_SCRIPTS_DIR', scripts_dir)
        process_env.insert('RAY_CLIENT_ID', self.client.client_id)
        process_env.insert('RAY_CLIENT_EXECUTABLE',
                           self.client.executable_path)
        process_env.insert('RAY_CLIENT_ARGUMENTS', self.client.arguments)
        self._process.setProcessEnvironment(process_env)

        self.client.sendGuiMessage(
            _translate('GUIMSG', '--- Custom script %s started...%s')
                    % (ray.highlightText(script_path), self.client.client_id))

        self._process.start(script_path, [])
        return True
Beispiel #3
0
    def start(self, step_str, arguments, src_addr=None, src_path=''):
        if self.isRunning():
            return False

        if not self.session.path:
            return False

        scripts_dir, parent_scripts_dir = self.getScriptDirs(
                                                            self.session.path)
        future_scripts_dir, future_parent_scripts_dir = self.getScriptDirs(
                                            self.session.future_session_path)

        script_path = "%s/%s.sh" % (scripts_dir, step_str)
        if not os.access(script_path, os.X_OK):
            return False

        self.src_addr = src_addr
        self.src_path = src_path

        self._stepper_has_call = False
        self._step_str = step_str

        self.sendGuiMessage(_translate('GUIMSG',
                            '--- Custom step script %s started...')
                            % ray.highlightText(script_path))

        process_env = QProcessEnvironment.systemEnvironment()
        process_env.insert('RAY_CONTROL_PORT', str(self.getServerPort()))
        process_env.insert('RAY_SCRIPTS_DIR', scripts_dir)
        process_env.insert('RAY_PARENT_SCRIPTS_DIR', parent_scripts_dir)
        process_env.insert('RAY_FUTURE_SESSION_PATH',
                           self.session.future_session_path)
        process_env.insert('RAY_FUTURE_SCRIPTS_DIR', future_scripts_dir)
        process_env.insert('RAY_SWITCHING_SESSION',
                           str(self.session.switching_session).lower())
        process_env.insert('RAY_SESSION_PATH', self.session.path)

        self._process.setProcessEnvironment(process_env)
        self._process.start(script_path, [str(a) for a in arguments])
        return True