<commit_before>#!/usr/bin/env python
#
# This is the melissi installer script
#
# Use me you install and upgrade melissi hives

import sys
import os
import commands
from optparse import OptionParser

LOGFILE = "install.log"
PACKAGES = {
    'django':'django',
    'south':'south',
    'django-mptt':'django-mptt',
    'django-extensions':'django_extensions',
    'mysql':'PyMySQL',
    'postgresql':'psycopg2',
    'librsync':'-e git://github.com/melissiproject/librsync.git#egg=librsync',
    'django-piston':'-e git://github.com/django-piston/django-piston.git#egg=django-piston',
    }


def _install(pkg):
    # execute command,
    # silence output export only errors to install.log
    COMMAND = "pip -E env install %s"
    status, output = commands.getstatusoutput(COMMAND % pkg)


    if status != 0:
        sys.exit("Failed while installing %s "
                 "Checking %s for details" % (pkg, LOGFILE)
                 )

def _printer(text, newline=False):
    print text,

    if newline:
        print ""

    with open(LOGFILE, "a+") as f:
        f.write(text)
        if newline:
            f.write('\n')

    sys.stdout.flush()

def upgrade():
    # upgrade git

    # restart script with --install
    os.execv(sys.argv[0], (sys.argv[0], "--install",))

def install(mysql=False, postgresql=False):
    _printer("Installing Packages: ")

    basic_packages = ('django', 'south', 'django-mptt',
                      'django-extensions', 'librsync',
                      'django-piston')

    for pkg in basic_packages:
        _printer("%s, " % pkg)
        _install(PACKAGES[pkg])

    if mysql:
        _printer("mysql, ")
        _install(PACKAGES['mysql'])

    if postgresql:<commit_msg>logfile contains output from pip<commit_after>#!/usr/bin/env python
#
# This is the melissi installer script
#
# Use me you install and upgrade melissi hives

import sys
import os
import commands
from optparse import OptionParser

LOGFILE = "install.log"
PACKAGES = {
    'django':'django',
    'south':'south',
    'django-mptt':'django-mptt',
    'django-extensions':'django_extensions',
    'mysql':'PyMySQL',
    'postgresql':'psycopg2',
    'librsync':'-e git://github.com/melissiproject/librsync.git#egg=librsync',
    'django-piston':'-e git://github.com/django-piston/django-piston.git#egg=django-piston',
    }


def _install(pkg):
    # execute command,
    # silence output export only errors to install.log
    COMMAND = "pip -E env install %s"
    status, output = commands.getstatusoutput(COMMAND % pkg)

    _printer(output, fileonly=True)

    if status != 0:
        sys.exit("Failed while installing %s "
                 "Checking %s for details" % (pkg, LOGFILE)
                 )

def _printer(text, newline=False, fileonly=False):
    if not fileonly:
        print text,

        if newline:
            print ""

    with open(LOGFILE, "a+") as f:
        f.write(text)
        if newline:
            f.write('\n')

    sys.stdout.flush()

def upgrade():
    # upgrade git

    # restart script with --install
    os.execv(sys.argv[0], (sys.argv[0], "--install",))

def install(mysql=False, postgresql=False):
    _printer("Installing Packages: ")

    basic_packages = ('django', 'south', 'django-mptt',
                      'django-extensions', 'librsync',
                      'django-piston')

    for pkg in basic_packages:
        _printer("%s, " % pkg)
        _install(PACKAGES[pkg])

    if mysql:
        _printer("mysql, ")
        _install(PACKAGES['mysql'])

    if postgresql:
{'fraction_non_alphanumeric': 0.13901472253680633, 'fraction_numerical': 0.0022650056625141564, 'mean_word_length': 2.638516992790937, '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': '3923579', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1126, 'n_words': 263}