<commit_before>#!/usr/bin/env python
#
# 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 argparse
import extras
import signal
import sys

import daemon

from nodepool import builder
import nodepool.cmd


# as of python-daemon 1.6 it doesn't bundle pidlockfile anymore
# instead it depends on lockfile-0.9.1 which uses pidfile.
pid_file_module = extras.try_imports(['daemon.pidlockfile', 'daemon.pidfile'])

class NodePoolBuilder(nodepool.cmd.NodepoolApp):

    def sigint_handler(self, signal, frame):
        self.nb.stop()

    def parse_arguments(self):
        parser = argparse.ArgumentParser(description='NodePool Image Builder.')
        parser.add_argument('-c', dest='config',
                            default='/etc/nodepool/nodepool.yaml',
                            help='path to config file')
        parser.add_argument('-l', dest='logconfig',
                            help='path to log config file')
        parser.add_argument('-p', dest='pidfile',
                            help='path to pid file',
                            default='/var/run/nodepool/nodepool.pid')
        parser.add_argument('-d', dest='nodaemon', action='store_true',
                            help='do not run as a daemon')
        self.args = parser.parse_args()

    def main(self):
        self.setup_logging()
        self.nb = builder.NodePoolBuilder(self.args.config)

        signal.signal(signal.SIGINT, self.sigint_handler)

        self.nb.runForever()<commit_msg>Use different pidfile for builder daemon<commit_after>#!/usr/bin/env python
#
# 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 argparse
import extras
import signal
import sys

import daemon

from nodepool import builder
import nodepool.cmd


# as of python-daemon 1.6 it doesn't bundle pidlockfile anymore
# instead it depends on lockfile-0.9.1 which uses pidfile.
pid_file_module = extras.try_imports(['daemon.pidlockfile', 'daemon.pidfile'])

class NodePoolBuilder(nodepool.cmd.NodepoolApp):

    def sigint_handler(self, signal, frame):
        self.nb.stop()

    def parse_arguments(self):
        parser = argparse.ArgumentParser(description='NodePool Image Builder.')
        parser.add_argument('-c', dest='config',
                            default='/etc/nodepool/nodepool.yaml',
                            help='path to config file')
        parser.add_argument('-l', dest='logconfig',
                            help='path to log config file')
        parser.add_argument('-p', dest='pidfile',
                            help='path to pid file',
                            default='/var/run/nodepool-builder/'
                                    'nodepool-builder.pid')
        parser.add_argument('-d', dest='nodaemon', action='store_true',
                            help='do not run as a daemon')
        self.args = parser.parse_args()

    def main(self):
        self.setup_logging()
        self.nb = builder.NodePoolBuilder(self.args.config)

        signal.signal(signal.SIGINT, self.sigint_handler)

        self.nb.runForever()
{'fraction_non_alphanumeric': 0.09856364536899455, 'fraction_numerical': 0.004457652303120356, 'mean_word_length': 2.655203619909502, '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': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6238817', 'n_tokens_mistral': 1105, 'n_tokens_neox': 1097, 'n_words': 343}