<commit_before>"""Example Plugin for EasyEngine."""

from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
from ee.core.variables import EEVariables
from ee.core.aptget import EEAptGet
from ee.core.donwload import EEDownload
import random
import string


def ee_stack_hook(app):
    # do something with the ``app`` object here.
    pass


class EEStackController(CementBaseController):
    class Meta:
        label = 'stack'
        stacked_on = 'base'
        stacked_type = 'nested'
        description = 'stack command manages stack operations'
        arguments = [
            (['--web'],
                dict(help='Install web stack', action='store_true')),
            (['--admin'],
                dict(help='Install admin tools stack', action='store_true')),
            (['--mail'],
                dict(help='Install mail server stack', action='store_true')),
            (['--nginx'],
                dict(help='Install Nginx stack', action='store_true')),
            (['--php'],
                dict(help='Install PHP stack', action='store_true')),
            (['--mysql'],
                dict(help='Install MySQL stack', action='store_true')),
            (['--postfix'],
                dict(help='Install Postfix stack', action='store_true')),
            ]

    @expose(hide=True)
    def default(self):
        # TODO Default action for ee stack command
        print("Inside EEStackController.default().")

    @expose(hide=True)
    def preseed_pref(self, packages):
        if "postfix" in packages:
            EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type"
                                 "string \'Internet Site\'\" | "
                                 "debconf-set-selections")
            EEShellExec.cmd_exec("echo \"postfix postfix/mailname string"
                                 "$(hostname -f)\" | debconf-set-selections")
        if "mysql" in packages:
            chars = ''.join(random.sample(string.letters, 8))
            EEShellExec.cmd_exec("echo \"percona-server-server-5.6"
                                 "percona-server-server/root_password"
                                 "password {<PASSWORD>}\""
                                 "| debconf-set-selections".format(pass=chars))
            EEShellExec.cmd_exec("echo \"percona-server-server-5.6"
                                 "percona-server-server/root_password_again"
                                 "password {pass}\""
                                 "| debconf-set-selections".format(pass=chars))

    @expose()
    def install(self):
        pkg = EEAptGet()
        packages = []
        if self.app.pargs.web:
            packages = (packages + EEVariables.ee_nginx + EEVariables.ee_php +
                        EEVariables.ee_mysql)
        if self.app.pargs.admin:
            pass
            #packages = packages + EEVariables.ee_nginx
        if self.app.pargs.mail:
            pass
            #packages = packages + EEVariables.ee_nginx<commit_msg>Fixed various typos<commit_after>"""Example Plugin for EasyEngine."""

from cement.core.controller import CementBaseController, expose
from cement.core import handler, hook
from ee.core.variables import EEVariables
from ee.core.aptget import EEAptGet
from ee.core.download import EEDownload
import random
import string


def ee_stack_hook(app):
    # do something with the ``app`` object here.
    pass


class EEStackController(CementBaseController):
    class Meta:
        label = 'stack'
        stacked_on = 'base'
        stacked_type = 'nested'
        description = 'stack command manages stack operations'
        arguments = [
            (['--web'],
                dict(help='Install web stack', action='store_true')),
            (['--admin'],
                dict(help='Install admin tools stack', action='store_true')),
            (['--mail'],
                dict(help='Install mail server stack', action='store_true')),
            (['--nginx'],
                dict(help='Install Nginx stack', action='store_true')),
            (['--php'],
                dict(help='Install PHP stack', action='store_true')),
            (['--mysql'],
                dict(help='Install MySQL stack', action='store_true')),
            (['--postfix'],
                dict(help='Install Postfix stack', action='store_true')),
            ]

    @expose(hide=True)
    def default(self):
        # TODO Default action for ee stack command
        print("Inside EEStackController.default().")

    @expose(hide=True)
    def preseed_pref(self, packages):
        if "postfix" in packages:
            EEShellExec.cmd_exec("echo \"postfix postfix/main_mailer_type"
                                 "string \'Internet Site\'\" | "
                                 "debconf-set-selections")
            EEShellExec.cmd_exec("echo \"postfix postfix/mailname string"
                                 "$(hostname -f)\" | debconf-set-selections")
        if "mysql" in packages:
            chars = ''.join(random.sample(string.letters, 8))
            EEShellExec.cmd_exec("echo \"percona-server-server-5.6"
                                 "percona-server-server/root_password"
                                 "password {chars}\" |"
                                 "debconf-set-selections".format(chars=chars))
            EEShellExec.cmd_exec("echo \"percona-server-server-5.6"
                                 "percona-server-server/root_password_again"
                                 "password {chars}\" |"
                                 "debconf-set-selections".format(chars=chars))

    @expose()
    def install(self):
        pkg = EEAptGet()
        packages = []
        if self.app.pargs.web:
            packages = (packages + EEVariables.ee_nginx + EEVariables.ee_php +
                        EEVariables.ee_mysql)
        if self.app.pargs.admin:
            pass
            #packages = packages + EEVariables.ee_nginx
        if self.app.pargs.mail:
            pass
            #packages = packages + EEVariables.ee_nginx
{'fraction_non_alphanumeric': 0.12076340901612373, 'fraction_numerical': 0.0016452780519907865, 'mean_word_length': 1.7923748277446028, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 21, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '625532', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1626, 'n_words': 345}