示例#1
0
    def create_database(cls):
        """ Allows user to create database with a specified name """

        name = raw_input(
            "Specify database name (default: music.db) - type 'exit' to abort): "
        ) or "music.db"

        if name == 'exit':
            return DatabaseMenu

        State.ApplicationState.album_manager = Manager.AlbumManager(
            os.path.dirname(sys.argv[0]) + "/" + name)
        return MainMenu
示例#2
0
    def load_database(cls):
        """ Allows user to load database with a specified name """

        files = []

        for f in os.listdir(os.path.dirname(sys.argv[0])):
            if f.endswith(".db"):
                files.append(f)

        if not files:
            print "No database files found."
            raw_input("\nPress ENTER to go back to the previous menu... ")
            return DatabaseMenu

        else:
            print "Databases found: "

            for f in files:
                print(f)

            print

            name = raw_input(
                "Specify database name (default: music.db - type 'exit' to abort): "
            ) or "music.db"

            if name == 'exit':
                return DatabaseMenu

            elif not os.path.exists(os.path.dirname(sys.argv[0]) + "/" + name):
                print "The specified file does not exist.\n"
                return None

            State.ApplicationState.album_manager = Manager.AlbumManager(
                os.path.dirname(sys.argv[0]) + "/" + name)
            return MainMenu