Beispiel #1
0
    def _send_pid(self):
        self._send_socket("start agent", "")
        self._send_socket("pid", os.getpid())
        variables = {}
        try:
            try:
                from robot.variables import GLOBAL_VARIABLES
                variables = GLOBAL_VARIABLES
            except ImportError:  # for robot >2.9
                from robot.conf.settings import RobotSettings
                from robot.variables.scopes import GlobalVariables
                variables = GlobalVariables(RobotSettings()).as_dict()

            data = {}
            for k in variables.keys():
                if not (k.startswith('${') or k.startswith('@{')):
                    key = '${' + k + '}'
                else:
                    key = k
                data[key] = str(variables[k])
            self._send_socket('global_vars', 'global_vars', data)
        except Exception as e:
            self.print_error_message(
                'Global variables sending error: ' + str(e) + ' Global variables: ' + str(variables))
            pass
Beispiel #2
0
    def _send_pid(self):
        self._send_socket("start agent", "")
        self._send_socket("pid", os.getpid())
        variables = {}
        try:
            try:
                from robot.variables import GLOBAL_VARIABLES
                variables = GLOBAL_VARIABLES
            except ImportError:  # for robot >2.9
                from robot.conf.settings import RobotSettings
                from robot.variables.scopes import GlobalVariables
                variables = GlobalVariables(RobotSettings()).as_dict()

            data = {}
            for k in variables.keys():
                if not (k.startswith('${') or k.startswith('@{')):
                    key = '${' + k + '}'
                else:
                    key = k
                data[key] = str(variables[k])
            self._send_socket('global_vars', 'global_vars', data)
        except Exception as e:
            self.print_error_message(
                'Global variables sending error: ' + str(e) + ' Global variables: ' + str(variables))
            pass
    def _send_global_variables(self):
        variables = {}
        try:
            try:
                from robot.variables import GLOBAL_VARIABLES
                variables = GLOBAL_VARIABLES
            except ImportError:  # for robot >2.9
                from robot.conf.settings import RobotSettings
                from robot.variables.scopes import GlobalVariables
                variables = GlobalVariables(RobotSettings()).as_dict()

            data = {}
            for key in variables.keys():
                new_key = '${' + key + '}' if not key.startswith(
                    '${') and not key.startswith('@{') else key
                data[new_key] = str(variables[key])
            self._send_to_server('global_vars', 'global_vars', data)
        except Exception as e:
            self._print_error_message('Global variables sending error: ' +
                                      str(e) + ' Global variables: ' +
                                      str(variables))
Beispiel #4
0
def get_global_variables():
    import robot
    import tempfile
    import os
    # Global variables copied from robot.variables.__init__.py
    global_variables = {
        '${TEMPDIR}': os.path.normpath(tempfile.gettempdir()),
        '${EXECDIR}': '',
        '${/}': os.sep,
        '${:}': os.pathsep,
        '${SPACE}': ' ',
        '${EMPTY}': '',
        '@{EMPTY}': [],
        '${True}': True,
        '${False}': False,
        '${None}': None,
        '${null}': None,
        '${OUTPUT_DIR}': '',
        '${OUTPUT_FILE}': '',
        '${SUMMARY_FILE}': '',
        '${REPORT_FILE}': '',
        '${LOG_FILE}': '',
        '${DEBUG_FILE}': '',
        '${PREV_TEST_NAME}': '',
        '${PREV_TEST_STATUS}': '',
        '${PREV_TEST_MESSAGE}': '',
        '${CURDIR}': '.',
        '${TEST_NAME}': '',
        '${TEST_DOCUMENTATION}': '',
        '@{TEST_TAGS}': [],
        '${TEST_STATUS}': '',
        '${TEST_MESSAGE}': '',
        '${SUITE_NAME}': '',
        '${SUITE_SOURCE}': '',
        '${SUITE_STATUS}': '',
        '${SUITE_MESSAGE}': '',
        '${SUITE_DOCUMENTATION}': '',
        '${KEYWORD_MESSAGE}': '',
        '${KEYWORD_STATUS}': ''
    }

    glob_variables = {}
    try:
        from robot.variables import GLOBAL_VARIABLES

        glob_variables = GLOBAL_VARIABLES
    except ImportError:  # for robot >2.9
        global_variables['&{EMPTY}'] = {}
        global_variables['&{SUITE_METADATA}'] = {}
        from robot.conf.settings import RobotSettings
        from robot.variables.scopes import GlobalVariables

        glob_variables = GlobalVariables(RobotSettings()).as_dict()
        glob_variables['${OUTPUT_DIR}'] = ''
        glob_variables['${EXECDIR}'] = ''
        glob_variables['${OUTPUT_FILE}'] = ''
        glob_variables['${REPORT_FILE}'] = ''
        glob_variables['${LOG_FILE}'] = ''

    data = {
        _wrap_variable_if_needed(key): value
        for key, value in glob_variables.items()
    }

    for k in global_variables:
        if not k in data:
            data[k] = global_variables[k]
    return data
Beispiel #5
0
def get_global_variables():
    import robot
    import tempfile
    import os
    # Global variables copied from robot.variables.__init__.py
    global_variables = {
        '${TEMPDIR}': os.path.normpath(tempfile.gettempdir()),
        '${EXECDIR}': '',
        '${/}': os.sep,
        '${:}': os.pathsep,
        '${SPACE}': ' ',
        '${EMPTY}': '',
        '@{EMPTY}': [],
        '${True}': True,
        '${False}': False,
        '${None}': None,
        '${null}': None,
        '${OUTPUT_DIR}': '',
        '${OUTPUT_FILE}': '',
        '${SUMMARY_FILE}': '',
        '${REPORT_FILE}': '',
        '${LOG_FILE}': '',
        '${DEBUG_FILE}': '',
        '${PREV_TEST_NAME}': '',
        '${PREV_TEST_STATUS}': '',
        '${PREV_TEST_MESSAGE}': '',
        '${CURDIR}': '.',
        '${TEST_NAME}': '',
        '${TEST_DOCUMENTATION}': '',
        '@{TEST_TAGS}': [],
        '${TEST_STATUS}': '',
        '${TEST_MESSAGE}': '',
        '${SUITE_NAME}': '',
        '${SUITE_SOURCE}': '',
        '${SUITE_STATUS}': '',
        '${SUITE_MESSAGE}': '',
        '${SUITE_DOCUMENTATION}': '',
        '${KEYWORD_MESSAGE}': '',
        '${KEYWORD_STATUS}': ''
    }

    glob_variables = {}
    try:
        from robot.variables import GLOBAL_VARIABLES

        glob_variables = GLOBAL_VARIABLES
    except ImportError:  # for robot >2.9
        global_variables['&{EMPTY}'] = {}
        global_variables['&{SUITE_METADATA}'] = {}
        from robot.conf.settings import RobotSettings
        from robot.variables.scopes import GlobalVariables

        glob_variables = GlobalVariables(RobotSettings()).as_dict()
        glob_variables['${OUTPUT_DIR}'] = ''
        glob_variables['${EXECDIR}'] = ''
        glob_variables['${OUTPUT_FILE}'] = ''
        glob_variables['${REPORT_FILE}'] = ''
        glob_variables['${LOG_FILE}'] = ''

    data = {_wrap_variable_if_needed(key) : value for key, value in glob_variables.items()}

    for k in global_variables:
        if not k in data:
            data[k] = global_variables[k]
    return data