<commit_before># -*- coding: utf-8 -*-

from __future__ import absolute_import, division, with_statement

from revolver import contextmanager as ctx
from revolver import core


def command(name, command):
    cmd = "/etc/init.d/%s %s" % (name, command)
    core.sudo(cmd)


def start(name):
    command(name, "start")


def stop(name):
    command(name, "stop")


def restart(name):
    command(name, "restart")


def reload(name):
    command(name, "reload")
<commit_msg>revolver.service now upstart compatible<commit_after># -*- coding: utf-8 -*-

from __future__ import absolute_import, division, with_statement

from revolver import contextmanager as ctx
from revolver import core, file


def add_upstart(name, content):
    if name.endswith(".conf"):
        name = name[:-5]

    upstart_file = "/etc/init/%s.conf" % name

    with ctx.sudo(), ctx.unpatched_state():
        file.write(upstart_file, content)


def command(name, command):
    initd_file = "/etc/init.d/%s" % name
    upstart_file = "/etc/init/%s.conf" % name

    if file.exists(upstart_file):
        cmd = "%s %s" % (command, name)
    elif file.exists(initd_file):
        cmd = "%s %s" % (initd_file, command)
    else:
        cmd = "false"

    core.sudo(cmd)


def start(name):
    command(name, "start")


def stop(name):
    command(name, "stop")


def restart(name):
    command(name, "restart")


def reload(name):
    command(name, "reload")

{'fraction_non_alphanumeric': 0.14435879467414156, 'fraction_numerical': 0.002102312543798178, 'mean_word_length': 3.36697247706422, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6301580', 'n_tokens_mistral': 496, 'n_tokens_neox': 475, 'n_words': 125}