<commit_before>"""
Module holds all stuff regarding Siege tool usage

Copyright 2015 BlazeMeter Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import logging
import os

from datetime import datetime

from bzt.engine import ScenarioExecutor
from bzt.modules.aggregator import ConsolidatingAggregator, ResultsReader
from bzt.utils import shell_exec, shutdown_process, BetterDict


class SiegeExecutor(ScenarioExecutor):
    def __init__(self):
        super(SiegeExecutor, self).__init__()
        self.log = logging.getLogger('')
        self.process = None
        self.__out = None
        self.__err = None
        self.__rc_name = None
        self.__url_name = None
        self.reader = None

    def prepare(self):
        config_params = ('verbose = true',
                         'csv = true',
                         'timestamp = false',
                         'fullurl = true',
                         'display-id = true',
                         'show-logfile = false',
                         'logging = false')

        self.__rc_name = self.engine.create_artifact("siegerc", "")
        with open(self.__rc_name, 'w') as rc_file:
            rc_file.writelines('\n'.join(config_params))
            rc_file.close()

        self.__url_name = self.engine.create_artifact("siege", "url")

        with open(self.__url_name, 'w') as url_file:
            url_list = self.get_scenario().get("requests", ["http://blazedemo.com"])
            url_file.writelines('\n'.join(url_list))
            url_file.close()

        out_file_name = self.engine.create_artifact("siege", ".out")
        self.reader = DataLogReader(out_file_name, self.log)
        if isinstance(self.engine.aggregator, ConsolidatingAggregator):
            self.engine.aggregator.add_underling(self.reader)

        self.__out = open(out_file_name, 'w')
        self.__err = open(self.engine.create_artifact("siege", ".err"), 'w')
<commit_msg>fix list of urls<commit_after>"""
Module holds all stuff regarding Siege tool usage

Copyright 2015 BlazeMeter Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

import logging
import os

from datetime import datetime

from bzt.engine import ScenarioExecutor
from bzt.modules.aggregator import ConsolidatingAggregator, ResultsReader
from bzt.utils import shell_exec, shutdown_process, BetterDict


class SiegeExecutor(ScenarioExecutor):
    def __init__(self):
        super(SiegeExecutor, self).__init__()
        self.log = logging.getLogger('')
        self.process = None
        self.__out = None
        self.__err = None
        self.__rc_name = None
        self.__url_name = None
        self.reader = None

    def prepare(self):
        config_params = ('verbose = true',
                         'csv = true',
                         'timestamp = false',
                         'fullurl = true',
                         'display-id = true',
                         'show-logfile = false',
                         'logging = false')

        self.__rc_name = self.engine.create_artifact("siegerc", "")
        with open(self.__rc_name, 'w') as rc_file:
            rc_file.writelines('\n'.join(config_params))
            rc_file.close()

        self.__url_name = self.engine.create_artifact("siege", "url")

        with open(self.__url_name, 'w') as url_file:
            url_list = self.get_scenario().get("requests", ["http://blazedemo.com"])
            url_list = [dic['url'] for dic in url_list]     # FIXME: read all info
            url_file.writelines('\n'.join(url_list))
            url_file.close()

        out_file_name = self.engine.create_artifact("siege", ".out")
        self.reader = DataLogReader(out_file_name, self.log)
        if isinstance(self.engine.aggregator, ConsolidatingAggregator):
            self.engine.aggregator.add_underling(self.reader)

        self.__out = open(out_file_name, 'w')
        self.__err = open(self.engine.create_artifact("siege", ".err"), 'w')

{'fraction_non_alphanumeric': 0.0986173241154941, 'fraction_numerical': 0.0032533550223668157, 'mean_word_length': 2.5800582241630274, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7088906', 'n_tokens_mistral': 1397, 'n_tokens_neox': 1333, 'n_words': 393}