<commit_before>import posixpath

from fabric.api import run, sudo

from .containers import conf
from .task import Task


__all__ = ['install', 'dump', 'execute', 'create_user', 'drop_user',
           'create_db', 'drop_db', 'grant']


class Install(Task):
    def do(self):
        pass

install = Install()


class Dump(Task):
    @conf
    def filename(self):
        return '%(db_name)s%(current_time)s.pgc' % self.conf

    @conf
    def filepath(self):
        return posixpath.join(self.conf.backups_path, self.conf.filename)
<commit_msg>Implement install task for postgres (still some work needed to properly setup password)<commit_after>import posixpath

from fabric.api import run, sudo

from . import system
from .containers import conf
from .task import Task


__all__ = ['install', 'dump', 'execute', 'create_user', 'drop_user',
           'create_db', 'drop_db', 'grant']


class Install(Task):
    def do(self):
        system.aptitude_install.run(packages='postgresql libpq-dev')
        sudo('sudo -u postgres psql --command="\password postgres" postgres')

install = Install()


class Dump(Task):
    @conf
    def filename(self):
        return '%(db_name)s%(current_time)s.pgc' % self.conf

    @conf
    def filepath(self):
        return posixpath.join(self.conf.backups_path, self.conf.filename)

{'fraction_non_alphanumeric': 0.12585291887793784, 'fraction_numerical': 0.0, 'mean_word_length': 3.5993031358885017, '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': '5142076', 'n_tokens_mistral': 437, 'n_tokens_neox': 417, 'n_words': 113}