Exemplo n.º 1
0
    def handle_password(self):

        web = WebContainer.get_web()
        first = web.get_form_value("database/password")
        second = web.get_form_value("password2")

        if not first or not second:
            return

        if first != second:
            raise CommandException("Passwords do not match")

        if first.find(" ") != -1:
            raise CommandException("Password cannot contain spaces or special characters")

        from pyasm.search import DbPasswordUtil
        DbPasswordUtil.set_password(first)
Exemplo n.º 2
0
    def handle_password(self):

        web = WebContainer.get_web()
        first = web.get_form_value("database/password")
        second = web.get_form_value("password2")

        if not first or not second:
            return

        if first != second:
            raise CommandException("Passwords do not match")

        if first.find(" ") != -1:
            raise CommandException(
                "Password cannot contain spaces or special characters")

        from pyasm.search import DbPasswordUtil
        DbPasswordUtil.set_password(first)
Exemplo n.º 3
0
    def ask_questions(my):

        # set vendor
        default_vendor = Config.get_value("database", "vendor")
        print
        print "Please enter the database vendor (PostgreSQL or Oracle):"
        print
        while 1:
            if not default_vendor:
                default_vendor = "PostgreSQL"
            vendor = raw_input("(%s) -> " % default_vendor)
            if not vendor:
                vendor = default_vendor
            print

            if vendor in ['PostgreSQL', 'Oracle']:
                break
            else:
                print "ERROR: Vendor must one of 'PostgreSQL' or 'Oracle'"
                print


        # set server
        default_server = Config.get_value("database", "server")
        if not default_server:
            default_server = "localhost"
        print
        print "Please enter database server hostname or IP address:"
        print
        server = raw_input("(%s) -> " % default_server)
        if not server:
            server = default_server
        print



        # set the user
        default_user = Config.get_value("database", "user")
        if not default_user:
            default_user = "******"
        print
        print "Please enter user name accessing the database:"
        if vendor == "Oracle":
            print "    (To access Oracle using schema names, type '__EMPTY__')"
        print
        user = raw_input("(%s) -> " % default_user)
        if not user:
            user = default_user
        print



        # set password
        from pyasm.search import DbPasswordUtil
        current_password = DbPasswordUtil.get_password()
        password = 0
        password2 = 1
        print
        print "Please enter database password:"******"  (ENTER to keep password, '__EMPTY__' for empty password)"

        import getpass
        while password != password2:
            print
            password = getpass.getpass("Enter Password -> ")

            if password:
                password2 = getpass.getpass("Confirm Password -> ")
            else:
                password = current_password
                password2 = password
                break

            print

            if password == password2:
                break
            else:
                print "ERROR: Passwords do not match"


        # Summary:
        print
        print "Vendor:   [%s]" % vendor
        print "Server:   [%s]" % server
        print "User:     [%s]" % user
        print

        ok = raw_input("Save to config (N/y) -> ")
        if ok.lower() != "y":
            print "Aborted"
            return


        # save the info
        from pyasm.search import DbPasswordUtil
        DbPasswordUtil.set_password(password)

        Config.set_value("database", "vendor", vendor)
        Config.set_value("database", "server", server)

        if user == "__EMPTY__":
            user = ""
        Config.set_value("database", "user", user)
        Config.save_config()
        path = Config.get_config_path()

        print
        print "Saved new database information to [%s].  Please restart TACTIC for the changes to take effect" % path
        print

        '''
Exemplo n.º 4
0
import os

import tacticenv
from pyasm.common import Config
from pyasm.search import DbPasswordUtil

DbPasswordUtil.set_password('')

Config.set_value("database", "server", os.environ['TACTIC_POSTGRES_PORT_5432_TCP_ADDR'])
Config.save_config()