Exemplo n.º 1
0
def install_virtualenv_from_pypi(args, indent=0):
    exit_code = pretty_execute("Downloading setuptools", [
        'wget', '--no-check-certificate',
        'https://bootstrap.pypa.io/ez_setup.py'
    ],
                               args,
                               indent=indent)
    if exit_code:
        return exit_code
    exit_code = pretty_execute(
        "Installing setuptools",
        ['sudo', 'python', 'ez_setup.py', '--version=14.1.1'],
        args,
        indent=indent)
    if exit_code:
        return exit_code
    exit_code = pretty_execute("Installing virtualenv",
                               ['sudo', 'easy_install', 'virtualenv==12.0.7'],
                               args,
                               indent=indent)
    if exit_code:
        return exit_code

    # TODO: fix this ; files are not deleted
    exit_code = pretty_execute(
        "Cleaning", ['rm', '-f', 'easy_setup.py', 'setuptools-14.1.1.zip'],
        args,
        indent=indent)
    return exit_code
Exemplo n.º 2
0
def set_locale_ubuntu(locale, args, indent=0):
    if locale == System.current_locale:
        echo("Locale '%s' is already the active one." % System.current_locale, indent=indent)
        return 0

    # TODO: check asked locale is valid
    language = locale.split('.')[0]

    # Generate locale
    exit_code = pretty_execute("Generating locale '%s'" % locale,
                               ['sudo', 'locale-gen', locale],
                               args, indent=indent)
    if exit_code:
        return exit_code

    # Update locale
    command = [
        'sudo',
        'update-locale',
        'LANG="%s"' % locale,
        'LANGUAGE="%s"' % language,
        'LC_ALL="%s"' % locale,
        'LC_CTYPE="%s"'% locale
    ]
    exit_code = pretty_execute("Updating locale to '%s'" % locale, command,  args, indent=indent)
    if exit_code:
        return exit_code

    # Reconfigure locales
    command = ['sudo', 'dpkg-reconfigure', 'locales']
    exit_code = pretty_execute("Reconfiguring locales", command,  args, indent=indent)
    return exit_code
Exemplo n.º 3
0
def install_wkhtmltopdf_debian(args, indent=0):

    print "%sInstalling wkhtmltopdf 0.12.1 (required by Odoo v8 and above to print QWeb reports)" % (
        '    ' * indent, )
    if System.system_name == 'debian':
        if System.system_major_version == '7':
            package_list = ['fontconfig', 'libfontconfig1', 'libpng12-0']
        else:
            package_list = [
                'fontconfig', 'libfontconfig1', 'libpng12-0', 'xfonts-base',
                'xfonts-75dpi'
            ]

    else:  # Ubuntu
        package_list = ['fontconfig', 'libfontconfig1', 'libjpeg-turbo8']

    exit_code = install_packages_debian(package_list, args, indent=indent + 1)
    if exit_code:
        return exit_code

    if System.system_name == 'debian':
        package_file_name = MAP_DEBIAN_VERSION_TO_PACKAGE_NAME[
            System.system_major_version]
        if System.system_major_version == '7':
            package_url = 'http://downloads.sourceforge.net/project/wkhtmltopdf/archive/0.12.1/'

        else:
            package_url = 'http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.2.1/'
        command = ['wget', package_url + package_file_name]
    else:
        package_file_name = MAP_UBUNTU_VERSION_TO_PACKAGE_NAME[
            System.system_version]
        command = [
            'wget',
            'http://downloads.sourceforge.net/project/wkhtmltopdf/archive/0.12.1/'
            + package_file_name
        ]

    if not os.path.exists(package_file_name):
        exit_code = pretty_execute("Downloading wkhtmltopdf 0.12.1",
                                   command,
                                   args,
                                   indent=indent + 1)
        if exit_code:
            return exit_code

    command = ['sudo', 'dpkg', '-i', package_file_name]
    exit_code = pretty_execute("Installing wkhtmltopdf 0.12.1",
                               command,
                               args,
                               indent=indent + 1)
    return exit_code
Exemplo n.º 4
0
def install_wkhtmltopdf_debian(args, indent=0):

    print "%sInstalling wkhtmltopdf 0.12.1 (required by Odoo v8 and above to print QWeb reports)" % ('    ' * indent,)
    if System.system_name == 'debian':
        if System.system_major_version == '7':
            package_list = ['fontconfig', 'libfontconfig1', 'libpng12-0']
        else:
            package_list = ['fontconfig', 'libfontconfig1', 'libpng12-0', 'xfonts-base', 'xfonts-75dpi']


    else:  # Ubuntu
        package_list = ['fontconfig', 'libfontconfig1', 'libjpeg-turbo8']


    exit_code = install_packages_debian(package_list, args, indent=indent+1)
    if exit_code:
        return exit_code

    if System.system_name == 'debian':
        package_file_name = MAP_DEBIAN_VERSION_TO_PACKAGE_NAME[System.system_major_version]
        if System.system_major_version == '7':
            package_url =  'http://downloads.sourceforge.net/project/wkhtmltopdf/archive/0.12.1/'

        else:
            package_url = 'http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.2.1/'
        command = [
            'wget',
            package_url + package_file_name
        ]
    else:
        package_file_name = MAP_UBUNTU_VERSION_TO_PACKAGE_NAME[System.system_version]
        command = [
            'wget',
            'http://downloads.sourceforge.net/project/wkhtmltopdf/archive/0.12.1/' + package_file_name
        ]


    if not os.path.exists(package_file_name):
        exit_code = pretty_execute("Downloading wkhtmltopdf 0.12.1", command, args, indent=indent+1)
        if exit_code:
            return exit_code

    command = [
        'sudo',
        'dpkg', '-i', package_file_name
    ]
    exit_code = pretty_execute("Installing wkhtmltopdf 0.12.1", command, args, indent=indent+1)
    return exit_code
Exemplo n.º 5
0
def exec_psql_command(msg,
                      sql_command,
                      database='postgres',
                      sudo=False,
                      args=None,
                      indent=0,
                      env=None):

    if System.system_name in (
            'debian',
            'ubuntu',
    ):
        command = [
            'sudo', 'su', 'postgres', '-c',
            'psql %s -tAc \"%s\"' % (database, sql_command)
        ]
    elif System.system_name == 'darwin':
        command = ['psql', database, '-tAc', sql_command]

    # When invoked by root from a root only access directory, postgres user is not allowed
    # to cd in a root owned directory. So we change cwd to tempfile.gettempdir()
    exit_code, output = pretty_execute(msg,
                                       command,
                                       args,
                                       indent=indent,
                                       return_output=True,
                                       env=env,
                                       cwd=tempfile.gettempdir())
    return exit_code, output
Exemplo n.º 6
0
def install_packages_debian(package_list, args=None, indent=0):

    if args.no_packages_check:
        echo("System packages and dependencies update skipped.",
             indent=indent,
             color=Fore.CYAN)
        return 0

    # update apt-get index
    exit_code = refresh_system_packages_index_debian(args, indent=indent)
    if exit_code:
        return exit_code

    # install each package that is not
    failed = 0

    for package in package_list:
        exit_code, output = execute(['sudo', 'dpkg', '-s', package],
                                    capture_output=True)
        if exit_code:  # Not installed
            exit_code = pretty_execute(
                "Installing package: '%s'" % package,
                ['sudo', 'apt-get', 'install', '-y', package],
                args,
                indent=indent)
            if exit_code:
                failed = exit_code

    return failed
Exemplo n.º 7
0
def exec_psql_user_command(msg,
                           username,
                           password,
                           sql_command,
                           host='localhost',
                           database='postgres',
                           args=None,
                           indent=0):
    if System.system_name in ('debian', 'ubuntu', 'darwin'):
        env = os.environ.copy()
        env['PGPASSWORD'] = password
        command = [
            'psql',
            '--host=%s' % host,
            '--username=%s' % username, database, '-c',
            "%s" % sql_command
        ]
    else:
        raise NotImplemented(
            "exec_psql_user_command() is not implemented for %s" %
            System.system_name)

    exit_code, output = pretty_execute(msg,
                                       command,
                                       args,
                                       indent=indent,
                                       return_output=True,
                                       env=env)
    return exit_code, output
Exemplo n.º 8
0
def reset(args):
    echo("Removing all buildout generated items...")
    echo("Note that the ./downloads directory is not removed to avoid re-downloading openerp.",
         indent=1, color=Fore.CYAN)

    exit_code = pretty_execute("Deleting buildout files",
                               ['rm', '-rf', '.installed.cfg', 'bin/', 'develop-eggs/', 'eggs/', 'etc/', 'py27/'],
                               args=args, indent=1)
    return exit_code
Exemplo n.º 9
0
def do_buildout(args, indent=0):
    msg = "Running appserver 'bin/buildout'"
    if args.no_buildout_output:
        msg += " (use --no-buildout-output to hide command output)"

    exit_code = pretty_execute(msg, ['bin/buildout'],
                               args,
                               capture_output=args.no_buildout_output,
                               indent=indent)
    return exit_code
Exemplo n.º 10
0
def refresh_system_packages_index_debian(args, indent=0):

    exit_code = 0
    if System.linux_packages_index_last_update_age > LINUX_PACKAGES_INDEX_MAX_AGE:
        exit_code = pretty_execute("Updating system packages index",
                                   ['sudo', 'apt-get', 'update'], args, indent=indent)
        if not exit_code:
            get_system_index_packages_age(args)

    return exit_code
Exemplo n.º 11
0
def install_xcode(args, indent=0):
    echo("On Darwin, developer tools must be installed from Apple servers.", indent=indent, color=Fore.CYAN)
    echo("On the window that will open, click on \"Get Xcode\", if you want to", indent=indent, color=Fore.CYAN)
    echo("install the full Apple Development Environment (> 1Gb) or click ", indent=indent, color=Fore.CYAN)
    echo("on \"Install\" to only install command line tools required", indent=indent, color=Fore.CYAN)
    echo("by ikez.", indent=indent, color=Fore.CYAN)
    prompt("Press Return when ready and relaunch ikez when it will be done ! ", indent=indent, color=Fore.RED)
    exit_code = pretty_execute("Launching Apple developer tools installer",
                               ['xcode-select', '--install'], args, indent=indent)
    sys.exit(1)
Exemplo n.º 12
0
def do_buildout(args, indent=0):
    msg = "Running appserver 'bin/buildout'"
    if args.no_buildout_output:
        msg += " (use --no-buildout-output to hide command output)"

    exit_code = pretty_execute(msg,
                               ['bin/buildout'],
                               args,
                               capture_output=args.no_buildout_output,
                               indent=indent)
    return exit_code
Exemplo n.º 13
0
def install_brew(args, indent=0):
    echo("ikez use \"Homebrew\" (aka brew) package manager to install some", indent=indent, color=Fore.CYAN)
    echo("required frameworks (eg. libjpeg)", indent=indent, color=Fore.CYAN)
    echo("and programs (eg. git).", indent=indent, color=Fore.CYAN)
    echo("Homebrew home is http://brew.sh", indent=indent, color=Fore.CYAN)
    echo("You must install brew following instructions on the home page that will open.", indent=indent, color=Fore.CYAN)
    prompt("Press Return when ready and relaunch ikez when it will be done ! ", indent=indent, color=Fore.RED)
    exit_code = pretty_execute("Opening brew homepage",
                               ['open', 'http://brew.sh'],
                               args, indent=indent)
    sys.exit(1)
Exemplo n.º 14
0
def refresh_system_packages_index_debian(args, indent=0):

    exit_code = 0
    if System.linux_packages_index_last_update_age > LINUX_PACKAGES_INDEX_MAX_AGE:
        exit_code = pretty_execute("Updating system packages index",
                                   ['sudo', 'apt-get', 'update'],
                                   args,
                                   indent=indent)
        if not exit_code:
            get_system_index_packages_age(args)

    return exit_code
Exemplo n.º 15
0
def install_virtualenv_from_pypi(args, indent=0):
    exit_code = pretty_execute("Downloading setuptools",
                               ['wget', '--no-check-certificate', 'https://bootstrap.pypa.io/ez_setup.py'],
                               args, indent=indent)
    if exit_code:
        return exit_code
    exit_code = pretty_execute("Installing setuptools",
                               ['sudo', 'python', 'ez_setup.py', '--version=14.1.1'],
                               args, indent=indent)
    if exit_code:
        return exit_code
    exit_code = pretty_execute("Installing virtualenv",
                               ['sudo', 'easy_install', 'virtualenv==12.0.7'],
                               args, indent=indent)
    if exit_code:
        return exit_code

    # TODO: fix this ; files are not deleted
    exit_code = pretty_execute("Cleaning",
                               ['rm', '-f', 'easy_setup.py', 'setuptools-14.1.1.zip'],
                               args, indent=indent)
    return exit_code
Exemplo n.º 16
0
def exec_psql_user_command(msg, username, password, sql_command, host='localhost', database='postgres', args=None, indent=0):
    if System.system_name in ('debian', 'ubuntu', 'darwin'):
        env = os.environ.copy()
        env['PGPASSWORD'] = password
        command = [
            'psql', '--host=%s' % host, '--username=%s' % username, database, '-c',
            "%s" % sql_command
        ]
    else:
        raise NotImplemented("exec_psql_user_command() is not implemented for %s" % System.system_name)

    exit_code, output = pretty_execute(msg, command, args, indent=indent, return_output=True, env=env)
    return exit_code, output
Exemplo n.º 17
0
def set_locale_ubuntu(locale, args, indent=0):
    if locale == System.current_locale:
        echo("Locale '%s' is already the active one." % System.current_locale,
             indent=indent)
        return 0

    # TODO: check asked locale is valid
    language = locale.split('.')[0]

    # Generate locale
    exit_code = pretty_execute("Generating locale '%s'" % locale,
                               ['sudo', 'locale-gen', locale],
                               args,
                               indent=indent)
    if exit_code:
        return exit_code

    # Update locale
    command = [
        'sudo', 'update-locale',
        'LANG="%s"' % locale,
        'LANGUAGE="%s"' % language,
        'LC_ALL="%s"' % locale,
        'LC_CTYPE="%s"' % locale
    ]
    exit_code = pretty_execute("Updating locale to '%s'" % locale,
                               command,
                               args,
                               indent=indent)
    if exit_code:
        return exit_code

    # Reconfigure locales
    command = ['sudo', 'dpkg-reconfigure', 'locales']
    exit_code = pretty_execute("Reconfiguring locales",
                               command,
                               args,
                               indent=indent)
    return exit_code
Exemplo n.º 18
0
def install_wkhtmltopdf_darwin(args, indent=0):

    echo(
        "Installing wkhtmltopdf 0.12.1 (required by Odoo v8 and above to print QWeb reports)",
        indent=indent)

    echo(
        "On Darwin, wkhtmltopdf is installed using an interactive installer from wkhtmltopdf",
        indent=indent + 1,
        color=Fore.CYAN)
    echo("official web site: http://wkhtmltopdf.org",
         indent=indent + 1,
         color=Fore.CYAN)

    command = [
        'wget',
        'http://downloads.sourceforge.net/project/wkhtmltopdf/archive/0.12.1/'
        'wkhtmltox-0.12.1_osx-cocoa-x86-64.pkg'
    ]
    if not os.path.exists('wkhtmltox-0.12.1_osx-cocoa-x86-64.pkg'):
        exit_code = pretty_execute("Downloading wkhtmltopdf 0.12.1",
                                   command,
                                   args,
                                   indent=indent + 1)
        if exit_code:
            return exit_code

    prompt(
        "When you're ready, press Enter to launch wkhtmltopdf installer then relaunch"
        " ikez when it will be done ! ",
        indent=indent + 1,
        color=Fore.RED)
    exit_code = pretty_execute(
        "Launching 'wkhtmltox-0.12.1_osx-cocoa-x86-64.pkg' installer",
        ['open', 'wkhtmltox-0.12.1_osx-cocoa-x86-64.pkg'],
        args,
        indent=indent + 1)
    sys.exit(1)
Exemplo n.º 19
0
def install_wkhtmltopdf_darwin(args, indent=0):

    echo("Installing wkhtmltopdf 0.12.1 (required by Odoo v8 and above to print QWeb reports)",
         indent=indent)

    echo("On Darwin, wkhtmltopdf is installed using an interactive installer from wkhtmltopdf", indent=indent+1, color=Fore.CYAN)
    echo("official web site: http://wkhtmltopdf.org", indent=indent+1, color=Fore.CYAN)

    command = [
        'wget',
        'http://downloads.sourceforge.net/project/wkhtmltopdf/archive/0.12.1/'
        'wkhtmltox-0.12.1_osx-cocoa-x86-64.pkg'
    ]
    if not os.path.exists('wkhtmltox-0.12.1_osx-cocoa-x86-64.pkg'):
        exit_code = pretty_execute("Downloading wkhtmltopdf 0.12.1", command, args, indent=indent+1)
        if exit_code:
            return exit_code

    prompt("When you're ready, press Enter to launch wkhtmltopdf installer then relaunch"
           " ikez when it will be done ! ", indent=indent+1, color=Fore.RED)
    exit_code = pretty_execute("Launching 'wkhtmltox-0.12.1_osx-cocoa-x86-64.pkg' installer",
                               ['open', 'wkhtmltox-0.12.1_osx-cocoa-x86-64.pkg'], args, indent=indent+1)
    sys.exit(1)
Exemplo n.º 20
0
def reset(args):
    echo("Removing all buildout generated items...")
    echo(
        "Note that the ./downloads directory is not removed to avoid re-downloading openerp.",
        indent=1,
        color=Fore.CYAN)

    exit_code = pretty_execute("Deleting buildout files", [
        'rm', '-rf', '.installed.cfg', 'bin/', 'develop-eggs/', 'eggs/',
        'etc/', 'py27/'
    ],
                               args=args,
                               indent=1)
    return exit_code
Exemplo n.º 21
0
def exec_psql_command(msg, sql_command, database='postgres', sudo=False, args=None, indent=0, env=None):

    if System.system_name in ( 'debian', 'ubuntu',):
        command = [ 'sudo', 'su', 'postgres', '-c',
            'psql %s -tAc \"%s\"' % (database, sql_command)
        ]
    elif System.system_name == 'darwin':
        command = ['psql', database, '-tAc', sql_command]

    # When invoked by root from a root only access directory, postgres user is not allowed
    # to cd in a root owned directory. So we change cwd to tempfile.gettempdir()
    exit_code, output = pretty_execute(msg, command, args, indent=indent, return_output=True, env=env,
                                       cwd=tempfile.gettempdir())
    return exit_code, output
Exemplo n.º 22
0
def install_packages_darwin(package_list, args=None, indent=0):
    # TODO: On Darwin, we don't bother to refresh since brew index is upto date at install
    # exit_code = refresh_system_packages_index_darwin(args, indent=indent)
    #if exit_code:
    #    return exit_code

    # install each package that is not
    failed = 0

    for package in package_list:
        if package not in System.brew_installed_packages:
            exit_code = pretty_execute("Installing package: '%s'" % package,
                                       ['brew', 'install', package],
                                       args, indent=indent)
            if exit_code:
                failed = exit_code

    return failed
Exemplo n.º 23
0
def install_packages_darwin(package_list, args=None, indent=0):
    # TODO: On Darwin, we don't bother to refresh since brew index is upto date at install
    # exit_code = refresh_system_packages_index_darwin(args, indent=indent)
    #if exit_code:
    #    return exit_code

    # install each package that is not
    failed = 0

    for package in package_list:
        if package not in System.brew_installed_packages:
            exit_code = pretty_execute("Installing package: '%s'" % package,
                                       ['brew', 'install', package],
                                       args,
                                       indent=indent)
            if exit_code:
                failed = exit_code

    return failed
Exemplo n.º 24
0
def install_brew(args, indent=0):
    echo("ikez use \"Homebrew\" (aka brew) package manager to install some",
         indent=indent,
         color=Fore.CYAN)
    echo("required frameworks (eg. libjpeg)", indent=indent, color=Fore.CYAN)
    echo("and programs (eg. git).", indent=indent, color=Fore.CYAN)
    echo("Homebrew home is http://brew.sh", indent=indent, color=Fore.CYAN)
    echo(
        "You must install brew following instructions on the home page that will open.",
        indent=indent,
        color=Fore.CYAN)
    prompt("Press Return when ready and relaunch ikez when it will be done ! ",
           indent=indent,
           color=Fore.RED)
    exit_code = pretty_execute("Opening brew homepage",
                               ['open', 'http://brew.sh'],
                               args,
                               indent=indent)
    sys.exit(1)
Exemplo n.º 25
0
def install_xcode(args, indent=0):
    echo("On Darwin, developer tools must be installed from Apple servers.",
         indent=indent,
         color=Fore.CYAN)
    echo(
        "On the window that will open, click on \"Get Xcode\", if you want to",
        indent=indent,
        color=Fore.CYAN)
    echo("install the full Apple Development Environment (> 1Gb) or click ",
         indent=indent,
         color=Fore.CYAN)
    echo("on \"Install\" to only install command line tools required",
         indent=indent,
         color=Fore.CYAN)
    echo("by ikez.", indent=indent, color=Fore.CYAN)
    prompt("Press Return when ready and relaunch ikez when it will be done ! ",
           indent=indent,
           color=Fore.RED)
    exit_code = pretty_execute("Launching Apple developer tools installer",
                               ['xcode-select', '--install'],
                               args,
                               indent=indent)
    sys.exit(1)
Exemplo n.º 26
0
def install_packages_debian(package_list, args=None, indent=0):

    if args.no_packages_check:
        echo("System packages and dependencies update skipped.", indent=indent, color=Fore.CYAN)
        return 0

    # update apt-get index
    exit_code = refresh_system_packages_index_debian(args, indent=indent)
    if exit_code:
        return exit_code

    # install each package that is not
    failed = 0

    for package in package_list:
        exit_code, output = execute(['sudo', 'dpkg', '-s', package], capture_output=True)
        if exit_code:  # Not installed
            exit_code = pretty_execute("Installing package: '%s'" % package,
                                       ['sudo', 'apt-get', 'install', '-y', package],
                                       args, indent=indent)
            if exit_code:
                failed = exit_code

    return failed
Exemplo n.º 27
0
def install_virtualenv(args, indent=0):

    echo("Installing virtualenv", indent)

    if not System.virtualenv_version:
        echo("virtualenv is not installed !!!!", indent + 1, Fore.CYAN)
        echo("ikez (and buildout) requires a virtualenv version > 1.9.1",
             indent + 1, Fore.CYAN)

        if System.system_name == 'debian':
            if System.system_major_version == '7':
                echo(
                    "On Wheezy (Debian 7.8), default virtualenv version is too old for ikez (and buildout).",
                    indent=indent + 1,
                    color=Fore.CYAN)
                echo(
                    "So we will install recent setuptools (14.1.1) and virtualenv (12.0.7) from pypi.",
                    indent=indent + 1,
                    color=Fore.CYAN)
                echo("Please look there for detail:",
                     indent=indent + 1,
                     color=Fore.CYAN)
                echo("  - https://pypi.python.org/pypi/setuptools",
                     indent=indent + 1,
                     color=Fore.CYAN)
                echo("  - https://pypi.python.org/pypi/virtualenv",
                     indent=indent + 1,
                     color=Fore.CYAN)
                if not args.force:
                    user_permission = (prompt("Are you Ok ? [Y/n] ",
                                              indent=indent + 1,
                                              color=Fore.RED)
                                       or 'Y').lower() in [
                                           'y', 'yes', 'o', 'oui'
                                       ]
                    if not user_permission:
                        return 1

                return install_virtualenv_from_pypi(args, indent=indent + 1)

            elif System.system_major_version == '8':
                echo(
                    "On Jessie (Debian 8), default virtualenv version is too old for ikez (and buildout).",
                    indent=indent + 1,
                    color=Fore.CYAN)
                echo(
                    "So we will install recent setuptools (14.1.1) and virtualenv (12.0.7) from pypi.",
                    indent=indent + 1,
                    color=Fore.CYAN)
                echo("Please look there for detail:",
                     indent=indent + 1,
                     color=Fore.CYAN)
                echo("  - https://pypi.python.org/pypi/setuptools",
                     indent=indent + 1,
                     color=Fore.CYAN)
                echo("  - https://pypi.python.org/pypi/virtualenv",
                     indent=indent + 1,
                     color=Fore.CYAN)
                if not args.force:
                    user_permission = (prompt("Are you Ok ? [Y/n] ",
                                              indent=indent + 1,
                                              color=Fore.RED)
                                       or 'Y').lower() in [
                                           'y', 'yes', 'o', 'oui'
                                       ]
                    if not user_permission:
                        return 1

                return install_virtualenv_from_pypi(args, indent=indent + 1)

            else:
                echo(
                    "You are running ikez on an unsupported Debian version ! ikez supports only"
                    "precise and trusty for now.",
                    color=Fore.RED)
                raise NotImplementedError()

        elif System.system_name == 'ubuntu':

            if System.system_major_version == '12':
                echo(
                    "On Precise (Ubuntu 12), default virtualenv version is too old for ikez (and buildout).",
                    indent=indent + 1,
                    color=Fore.CYAN)
                echo(
                    "So we will install recent setuptools (14.1.1) and virtualenv (12.0.7) from pypi.",
                    indent=indent + 1,
                    color=Fore.CYAN)
                echo("Please look there for detail:",
                     indent=indent + 1,
                     color=Fore.CYAN)
                echo("  - https://pypi.python.org/pypi/setuptools",
                     indent=indent + 1,
                     color=Fore.CYAN)
                echo("  - https://pypi.python.org/pypi/virtualenv",
                     indent=indent + 1,
                     color=Fore.CYAN)
                if not args.force:
                    user_permission = (prompt("Are you Ok ? [Y/n] ",
                                              indent=indent + 1,
                                              color=Fore.RED)
                                       or 'Y').lower() in [
                                           'y', 'yes', 'o', 'oui'
                                       ]
                    if not user_permission:
                        return 1

                return install_virtualenv_from_pypi(args, indent=indent + 1)

            elif System.system_major_version in (
                    '14',
                    '15',
            ):
                echo(
                    "On Ubuntu 14 and 15, default virtualenv version is ok so we just apt-get it.",
                    indent=indent + 1,
                    color=Fore.CYAN)
                exit_code = pretty_execute(
                    "Installing Ubuntu distribution virtualenv",
                    ['sudo', 'apt-get', 'install', '-y', 'python-virtualenv'],
                    args,
                    indent=indent + 1)
                return exit_code
            else:
                echo(
                    "You are running ikez on an unsupported Ubuntu version ! ikez supports only "
                    "Ubuntu 14 and 15 for now.",
                    color=Fore.RED)
                raise NotImplementedError()

        elif System.system_name == 'darwin':
            echo(
                "On Darwin / MacOS, we install recent setuptools (14.1.1) and virtualenv (12.0.7) from pypi.",
                indent=indent + 1,
                color=Fore.CYAN)
            echo("Please look there for detail:",
                 indent=indent + 1,
                 color=Fore.CYAN)
            echo("  - https://pypi.python.org/pypi/setuptools",
                 indent=indent + 1,
                 color=Fore.CYAN)
            echo("  - https://pypi.python.org/pypi/virtualenv",
                 indent=indent + 1,
                 color=Fore.CYAN)
            if not args.force:
                user_permission = (prompt(
                    "Are you Ok ? [Y/n] ", indent=indent + 1, color=Fore.RED)
                                   or 'Y').lower() in ['y', 'yes', 'o', 'oui']
                if not user_permission:
                    return 1

            return install_virtualenv_from_pypi(args, indent=indent + 1)

        else:
            raise NotImplementedError()

    elif semver.compare(System.virtualenv_version, '1.9.1') > 0:
        print "No need to install virtualenv ;  installed version ('%s') is ok (> '1.9.1')." % System.virtualenv_version
        return 126
    else:
        echo("Installed virtualenv version '%s' is too old ! " %
             System.virtualenv_version,
             indent=indent + 1,
             color=Fore.CYAN)
        echo("ikez requires virtualenv version > 1.9.1",
             indent=indent + 1,
             color=Fore.CYAN)
        echo("Look at: ", indent=indent + 1, color=Fore.CYAN)
        echo("  - https://pypi.python.org/pypi/setuptools",
             indent=indent + 1,
             color=Fore.CYAN)
        echo("  - https://pypi.python.org/pypi/virtualenv",
             indent=indent + 1,
             color=Fore.CYAN)

    return 1  #
Exemplo n.º 28
0
def install(args):
    """
    Install Odoo from an ikez Git repository
    :param args:
    :type args:
    :return:
    :rtype:
    """

    if not args.username:
        print "You must specify a PostgreSQL username and password that will be used by Odoo to connect to database."
        print "If this user does not exist, ikez will create it. But if this user exists with a password different "
        print "than the one provided, ikez will exit and you will have to re-launch with a valid password"
        sys.exit(1)

    # Gather answer to all questions
    if not System.postgresql_version:
        if not args.locale and System.system_name in ('debian', 'ubuntu',):  # TODO: Check for Linux, add a system_info to group all Linux distrib
            if not args.unattended:
                locale = raw_input("Enter the locale you want to install or leave blank to use '%s' ? " % System.current_locale)
                if locale:
                    args.locale = locale
            else:
                echo("ERROR: Postgresql is not installed and '--locale' parameter "
                     "is missing. Relaunch with --locale or remove --unattended.",
                     color=Fore.RED)
                sys.exit(1)

    echo("Installing Odoo server")

    # Install required system packages
    exit_code = system.install_system_dependencies(args, indent=1)
    if exit_code:
        return exit_code

    # Install PostgreSQL
    if not System.postgresql_version:
        exit_code = postgresql.install(args, indent=1)
        if exit_code:
            return exit_code

    if args.repository:
        exit_code = pretty_execute("Checking repository URL validity",
                                   ['git', 'ls-remote', args.repository],
                                   args, indent=1)
        if exit_code:
            return exit_code

        # Computing dest directory
        if not args.destination:
            args.destination = args.repository.split('/')[-1]
            # TODO: Remove .git extension

        if args.destination:
            if os.path.exists(args.destination):
                echo("ERROR: folder '%s' exists. Please remove it then relaunch ikez." % args.destination,
                     indent=1, color=Fore.RED)
                return 1
        exit_code = pretty_execute("Cloning repository '%s'" % args.repository,
                                   ['git', 'clone', args.repository, args.destination],
                                   args, indent=1)
        if exit_code:
            return exit_code

        echo("Changing current directory to '%s'" % args.destination, indent=1)
        try:
            os.chdir('./'+args.destination)
        except:
            echo("ERROR: Unable to change current directory to '%s'." % args.destination, indent=1, color=Fore.RED)
            return 1

    if not is_cwd_an_ikez_repo(args):
        print "ERROR: Current directory is not an ikez Odoo repository."
        return 1

    # assert db user exists
    exit_code = enforcing_odoo_server_database_user(args, indent=1)
    if exit_code:
        return exit_code

    if not System.virtualenv_version_ok:
        exit_code = system.install_virtualenv(args, indent=1)
        if exit_code:
            return exit_code

    #integrated in bootstrap_bildout        
    #exit_code = assert_buildout_cfg_files(args, indent=1)
    #if exit_code:
    #    return exit_code

    if not os.path.exists('bin/buildout'):
        exit_code = bootstrap_buildout(args, indent=1)
        if exit_code:
            return exit_code

    exit_code = do_buildout(args, indent=1)

    return exit_code
Exemplo n.º 29
0
def bootstrap_buildout(args, indent=0):
    """
    bootstrap a buildout.
    """
    echo("Bootstrapping buildout", indent=indent)

    if not args.password:
        args.password = args.username

    exit_code = assert_buildout_cfg_files(args, indent=indent+1)
    if exit_code:
        return exit_code

    # To get latest bootstrap.py use:
    #    wget https://raw.github.com/buildout/buildout/master/bootstrap/bootstrap.py
    # We download bootstrap.py as of 14/12/2014 commit = 88ad9f4 using
    # wget https://raw.githubusercontent.com/buildout/buildout/88ad9f41bfbb32330a8fd37326ab93a82a984ba1/bootstrap/bootstrap.py
    exit_code = pretty_execute("Downloading bootstrap.py",
                               ['wget', 'https://raw.githubusercontent.com/buildout/buildout/'
                                '88ad9f41bfbb32330a8fd37326ab93a82a984ba1/bootstrap/bootstrap.py'],
                               args, indent=indent+1)
    if exit_code:
        return exit_code

    exit_code = pretty_execute("Creating virtualenv",
                               ['virtualenv', 'py27', '--no-setuptools', '--no-site-packages'],
                               args, indent=indent+1)
    if exit_code:
        return exit_code

    # we want setuptools==14.1.1 and zc.buildout==2.3.1
    exit_code = pretty_execute("Bootstrapping buildout '%s'" % ('2.3.1',),
                               ['py27/bin/python', 'bootstrap.py', '--version=2.3.1'],
                               args, indent=indent+1)
    if exit_code:
        return exit_code

    exit_code = pretty_execute("Cleaning",
                               ['rm', 'bootstrap.py'],
                               args, indent=indent+1)
    if exit_code:
        return exit_code

    # by default Install pip to have a developer friendly virtualenv
    if not args.no_pip:
        echo("Installing pip in virtualenv (use --no-pip if you want a pure virtualenv)", indent+1)
        exit_code = pretty_execute("Downloading get-pip.py",
                                   ['wget', 'https://bootstrap.pypa.io/get-pip.py'],
                                   args, indent=indent+2)
        if exit_code:
            return exit_code

        # Note that as of 15/03/2015, get-pip.py do not allow to choose pip version to install.
        exit_code = pretty_execute("Running get-pip.py",
                                   ['py27/bin/python', 'get-pip.py'],
                                   args, indent=indent+2)
        if exit_code:
            return exit_code

        exit_code = pretty_execute("Deleting files",
                                   ['rm', 'get-pip.py'],
                                   args, indent=indent+1)
        if not args.no_bzr:
            exit_code = pretty_execute("Installing bzr 2.6 (use --no-bzr to prevent)",
                                       ['py27/bin/pip', 'install', 'bzr==2.6'],
                                       args, indent=indent+1)
            if exit_code:
                return exit_code

    return exit_code
Exemplo n.º 30
0
def install_virtualenv(args, indent=0):

    echo("Installing virtualenv", indent)

    if not System.virtualenv_version:
        echo("virtualenv is not installed !!!!", indent+1, Fore.CYAN)
        echo("ikez (and buildout) requires a virtualenv version > 1.9.1", indent+1, Fore.CYAN)

        if System.system_name == 'debian':
            if System.system_major_version == '7':
                echo("On Wheezy (Debian 7.8), default virtualenv version is too old for ikez (and buildout).", indent=indent+1,
                     color=Fore.CYAN)
                echo("So we will install recent setuptools (14.1.1) and virtualenv (12.0.7) from pypi.", indent=indent+1, color=Fore.CYAN)
                echo("Please look there for detail:", indent=indent+1, color=Fore.CYAN)
                echo("  - https://pypi.python.org/pypi/setuptools", indent=indent+1, color=Fore.CYAN)
                echo("  - https://pypi.python.org/pypi/virtualenv", indent=indent+1, color=Fore.CYAN)
                if not args.force:
                    user_permission = (prompt("Are you Ok ? [Y/n] ", indent=indent+1, color=Fore.RED) or 'Y').lower() in ['y', 'yes', 'o',                                                                                                                          'oui']
                    if not user_permission:
                        return 1

                return install_virtualenv_from_pypi(args, indent=indent+1)

            elif System.system_major_version == '8':
                echo("On Jessie (Debian 8), default virtualenv version is too old for ikez (and buildout).", indent=indent+1,
                     color=Fore.CYAN)
                echo("So we will install recent setuptools (14.1.1) and virtualenv (12.0.7) from pypi.", indent=indent+1, color=Fore.CYAN)
                echo("Please look there for detail:", indent=indent+1, color=Fore.CYAN)
                echo("  - https://pypi.python.org/pypi/setuptools", indent=indent+1, color=Fore.CYAN)
                echo("  - https://pypi.python.org/pypi/virtualenv", indent=indent+1, color=Fore.CYAN)
                if not args.force:
                    user_permission = (prompt("Are you Ok ? [Y/n] ", indent=indent+1, color=Fore.RED) or 'Y').lower() in ['y', 'yes', 'o',                                                                                                                          'oui']
                    if not user_permission:
                        return 1

                return install_virtualenv_from_pypi(args, indent=indent+1)

            else:
                echo("You are running ikez on an unsupported Debian version ! ikez supports only"
                     "precise and trusty for now.", color=Fore.RED)
                raise NotImplementedError()

        elif System.system_name == 'ubuntu':

            if System.system_major_version == '12':
                echo("On Precise (Ubuntu 12), default virtualenv version is too old for ikez (and buildout).", indent=indent+1,
                     color=Fore.CYAN)
                echo("So we will install recent setuptools (14.1.1) and virtualenv (12.0.7) from pypi.", indent=indent+1, color=Fore.CYAN)
                echo("Please look there for detail:", indent=indent+1, color=Fore.CYAN)
                echo("  - https://pypi.python.org/pypi/setuptools", indent=indent+1, color=Fore.CYAN)
                echo("  - https://pypi.python.org/pypi/virtualenv", indent=indent+1, color=Fore.CYAN)
                if not args.force:
                    user_permission = (prompt("Are you Ok ? [Y/n] ", indent=indent+1, color=Fore.RED) or 'Y').lower() in ['y', 'yes', 'o',                                                                                                                          'oui']
                    if not user_permission:
                        return 1

                return install_virtualenv_from_pypi(args, indent=indent+1)

            elif System.system_major_version in ('14', '15',):
                echo("On Ubuntu 14 and 15, default virtualenv version is ok so we just apt-get it.",
                     indent=indent+1, color=Fore.CYAN)
                exit_code = pretty_execute("Installing Ubuntu distribution virtualenv",
                                           ['sudo', 'apt-get', 'install', '-y', 'python-virtualenv'],
                                           args, indent=indent+1)
                return exit_code
            else:
                echo("You are running ikez on an unsupported Ubuntu version ! ikez supports only "
                     "Ubuntu 14 and 15 for now.", color=Fore.RED)
                raise NotImplementedError()

        elif System.system_name == 'darwin':
            echo("On Darwin / MacOS, we install recent setuptools (14.1.1) and virtualenv (12.0.7) from pypi.", indent=indent+1, color=Fore.CYAN)
            echo("Please look there for detail:", indent=indent+1, color=Fore.CYAN)
            echo("  - https://pypi.python.org/pypi/setuptools", indent=indent+1, color=Fore.CYAN)
            echo("  - https://pypi.python.org/pypi/virtualenv", indent=indent+1, color=Fore.CYAN)
            if not args.force:
                user_permission = (prompt("Are you Ok ? [Y/n] ", indent=indent+1, color=Fore.RED) or 'Y').lower() in ['y', 'yes', 'o',                                                                                                                          'oui']
                if not user_permission:
                    return 1

            return install_virtualenv_from_pypi(args, indent=indent+1)

        else:
            raise NotImplementedError()

    elif semver.compare(System.virtualenv_version, '1.9.1') > 0:
        print "No need to install virtualenv ;  installed version ('%s') is ok (> '1.9.1')." % System.virtualenv_version
        return 126
    else:
        echo("Installed virtualenv version '%s' is too old ! " % System.virtualenv_version, indent=indent+1, color=Fore.CYAN)
        echo("ikez requires virtualenv version > 1.9.1", indent=indent+1, color=Fore.CYAN)
        echo("Look at: ", indent=indent+1, color=Fore.CYAN)
        echo("  - https://pypi.python.org/pypi/setuptools", indent=indent+1, color=Fore.CYAN)
        echo("  - https://pypi.python.org/pypi/virtualenv", indent=indent+1, color=Fore.CYAN)

    return 1  #
Exemplo n.º 31
0
def install(args):
    """
    Install Odoo from an ikez Git repository
    :param args:
    :type args:
    :return:
    :rtype:
    """

    if not args.username:
        print "You must specify a PostgreSQL username and password that will be used by Odoo to connect to database."
        print "If this user does not exist, ikez will create it. But if this user exists with a password different "
        print "than the one provided, ikez will exit and you will have to re-launch with a valid password"
        sys.exit(1)

    # Gather answer to all questions
    if not System.postgresql_version:
        if not args.locale and System.system_name in (
                'debian',
                'ubuntu',
        ):  # TODO: Check for Linux, add a system_info to group all Linux distrib
            if not args.unattended:
                locale = raw_input(
                    "Enter the locale you want to install or leave blank to use '%s' ? "
                    % System.current_locale)
                if locale:
                    args.locale = locale
            else:
                echo(
                    "ERROR: Postgresql is not installed and '--locale' parameter "
                    "is missing. Relaunch with --locale or remove --unattended.",
                    color=Fore.RED)
                sys.exit(1)

    echo("Installing Odoo server")

    # Install required system packages
    exit_code = system.install_system_dependencies(args, indent=1)
    if exit_code:
        return exit_code

    # Install PostgreSQL
    if not System.postgresql_version:
        exit_code = postgresql.install(args, indent=1)
        if exit_code:
            return exit_code

    if args.repository:
        exit_code = pretty_execute("Checking repository URL validity",
                                   ['git', 'ls-remote', args.repository],
                                   args,
                                   indent=1)
        if exit_code:
            return exit_code

        # Computing dest directory
        if not args.destination:
            args.destination = args.repository.split('/')[-1]
            # TODO: Remove .git extension

        if args.destination:
            if os.path.exists(args.destination):
                echo(
                    "ERROR: folder '%s' exists. Please remove it then relaunch ikez."
                    % args.destination,
                    indent=1,
                    color=Fore.RED)
                return 1
        exit_code = pretty_execute(
            "Cloning repository '%s'" % args.repository,
            ['git', 'clone', args.repository, args.destination],
            args,
            indent=1)
        if exit_code:
            return exit_code

        echo("Changing current directory to '%s'" % args.destination, indent=1)
        try:
            os.chdir('./' + args.destination)
        except:
            echo("ERROR: Unable to change current directory to '%s'." %
                 args.destination,
                 indent=1,
                 color=Fore.RED)
            return 1

    if not is_cwd_an_ikez_repo(args):
        print "ERROR: Current directory is not an ikez Odoo repository."
        return 1

    # assert db user exists
    exit_code = enforcing_odoo_server_database_user(args, indent=1)
    if exit_code:
        return exit_code

    if not System.virtualenv_version_ok:
        exit_code = system.install_virtualenv(args, indent=1)
        if exit_code:
            return exit_code

    #integrated in bootstrap_bildout
    #exit_code = assert_buildout_cfg_files(args, indent=1)
    #if exit_code:
    #    return exit_code

    if not os.path.exists('bin/buildout'):
        exit_code = bootstrap_buildout(args, indent=1)
        if exit_code:
            return exit_code

    exit_code = do_buildout(args, indent=1)

    return exit_code
Exemplo n.º 32
0
def bootstrap_buildout(args, indent=0):
    """
    bootstrap a buildout.
    """
    echo("Bootstrapping buildout", indent=indent)

    if not args.password:
        args.password = args.username

    exit_code = assert_buildout_cfg_files(args, indent=indent + 1)
    if exit_code:
        return exit_code

    # To get latest bootstrap.py use:
    #    wget https://raw.github.com/buildout/buildout/master/bootstrap/bootstrap.py
    # We download bootstrap.py as of 14/12/2014 commit = 88ad9f4 using
    # wget https://raw.githubusercontent.com/buildout/buildout/88ad9f41bfbb32330a8fd37326ab93a82a984ba1/bootstrap/bootstrap.py
    exit_code = pretty_execute("Downloading bootstrap.py", [
        'wget', 'https://raw.githubusercontent.com/buildout/buildout/'
        '88ad9f41bfbb32330a8fd37326ab93a82a984ba1/bootstrap/bootstrap.py'
    ],
                               args,
                               indent=indent + 1)
    if exit_code:
        return exit_code

    exit_code = pretty_execute(
        "Creating virtualenv",
        ['virtualenv', 'py27', '--no-setuptools', '--no-site-packages'],
        args,
        indent=indent + 1)
    if exit_code:
        return exit_code

    # we want setuptools==14.1.1 and zc.buildout==2.3.1
    exit_code = pretty_execute(
        "Bootstrapping buildout '%s'" % ('2.3.1', ),
        ['py27/bin/python', 'bootstrap.py', '--version=2.3.1'],
        args,
        indent=indent + 1)
    if exit_code:
        return exit_code

    exit_code = pretty_execute("Cleaning", ['rm', 'bootstrap.py'],
                               args,
                               indent=indent + 1)
    if exit_code:
        return exit_code

    # by default Install pip to have a developer friendly virtualenv
    if not args.no_pip:
        echo(
            "Installing pip in virtualenv (use --no-pip if you want a pure virtualenv)",
            indent + 1)
        exit_code = pretty_execute(
            "Downloading get-pip.py",
            ['wget', 'https://bootstrap.pypa.io/get-pip.py'],
            args,
            indent=indent + 2)
        if exit_code:
            return exit_code

        # Note that as of 15/03/2015, get-pip.py do not allow to choose pip version to install.
        exit_code = pretty_execute("Running get-pip.py",
                                   ['py27/bin/python', 'get-pip.py'],
                                   args,
                                   indent=indent + 2)
        if exit_code:
            return exit_code

        exit_code = pretty_execute("Deleting files", ['rm', 'get-pip.py'],
                                   args,
                                   indent=indent + 1)
        if not args.no_bzr:
            exit_code = pretty_execute(
                "Installing bzr 2.6 (use --no-bzr to prevent)",
                ['py27/bin/pip', 'install', 'bzr==2.6'],
                args,
                indent=indent + 1)
            if exit_code:
                return exit_code

    return exit_code