<commit_before>from cubric import DeploymentBase
from cubric import Git, File, Template, NGINX
from path import Path
import plumbum
import datetime


class EmberLocalBuild(DeploymentBase):
    requires = (Git, File)

    _ember_env = "demo"

    @property
    def ember_env(self):
        try:
            return self.config.ember_env
        except AttributeError:
            return self._ember_env

    def sync_repo(self, env):
        self.git.cloneup(self.config.repo, self.config.project,
                         self.config.branch)

    def run(self, env):
        self.file.removed(self.config.project)
        self.sync_repo(env)
        with env.chdir(self.config.project):
            print("Using node:")
            env.command("node", "-v")
            env.command("npm", "install")
            env.command("bower", "install", "--allow-root")
            env.command("ember", "build", "--env={}".format(self.ember_env))


class EmberDeploy(DeploymentBase):
    requires = (Git, File, Template, NGINX)

    def run(self, env):
        """
            - Create remote instance folder
            - Create folder based on commit hash
            - Recursive copy dist/
            - Symlink
            - Setup / update nginx
        """

        with env.sudo():
            env.mkdir(self.config.instancepath, chdir=True,
                      owner=self.config.user)
        # Not usable, works remotely not local!
        # print("Hash", self.git.shorthash(self.config.project))

        tsfolder = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
        tmpfile = Path("/tmp") / tsfolder

        plumbum.path.utils.copy(Path(self.config.project) / 'dist',
                                env.host.path(tmpfile))
        with env.sudo():
            env.chown(tmpfile, owner=self.config.user, recursive=True)
            env.move(tmpfile, self.config.instancepath / tsfolder)
<commit_msg>fix log dir<commit_after>from cubric import DeploymentBase
from cubric import Git, File, Template, NGINX
from path import Path
import plumbum
import datetime


class EmberLocalBuild(DeploymentBase):
    requires = (Git, File)

    _ember_env = "demo"

    @property
    def ember_env(self):
        try:
            return self.config.ember_env
        except AttributeError:
            return self._ember_env

    def sync_repo(self, env):
        self.git.cloneup(self.config.repo, self.config.project,
                         self.config.branch)

    def run(self, env):
        self.file.removed(self.config.project)
        self.sync_repo(env)
        with env.chdir(self.config.project):
            print("Using node:")
            env.command("node", "-v")
            env.command("npm", "install")
            env.command("bower", "install", "--allow-root")
            env.command("ember", "build", "--env={}".format(self.ember_env))


class EmberDeploy(DeploymentBase):
    requires = (Git, File, Template, NGINX)

    def run(self, env):
        """
            - Create remote instance folder
            - Create folder based on commit hash
            - Recursive copy dist/
            - Symlink
            - Setup / update nginx
        """

        logpath = self.config.instancepath / 'logs'
        with env.sudo():
            env.mkdir(logpath, owner=self.config.user)
            env.mkdir(self.config.instancepath, chdir=True,
                      owner=self.config.user)

        # Not usable, works remotely not local!
        # print("Hash", self.git.shorthash(self.config.project))

        tsfolder = datetime.datetime.now().strftime("%Y%m%d%H%M%S")
        tmpfile = Path("/tmp") / tsfolder

        plumbum.path.utils.copy(Path(self.config.project) / 'dist',
                                env.host.path(tmpfile))
        with env.sudo():
            env.chown(tmpfile, owner=self.config.user, recursive=True)
            env.move(tmpfile, self.config.instancepath / tsfolder)

{'fraction_non_alphanumeric': 0.12168367346938776, 'fraction_numerical': 0.0, 'mean_word_length': 2.0371804802478697, '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': '4867271', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1124, 'n_words': 241}