コード例 #1
0
ファイル: tasks.py プロジェクト: Lantero/personal-portfolio
    def deploy():
        """
        Deploys remotely master branch changes to production server.

        Returns:
            None
        """
        try:
            print()
            info_print(
                "This script will only succeed if you have configured the "
                "production server ssh port to match the one in "
                "config/production.py and have proper ssh access."
            )
            warning_print(
                "This process will update the production server with the "
                "latest master branch changes."
            )
            option = input("Do you want to continue? (y/n)\n")
            if option != "y" and option != "Y":
                sys.exit()
            t0 = time.time()
            remote_production_task("update_project")
            remote_production_task("install_python_requirements")
            remote_production_task("collect_static_files")
            remote_production_task("make_migrations")
            remote_production_task("migrate")
            remote_production_task("restart_server")
            t1 = time.time()
            show_time(t0, t1)
        except KeyboardInterrupt:
            error_print("Process aborted. Bye!")
            sys.exit()
コード例 #2
0
ファイル: tasks.py プロジェクト: Lantero/personal-portfolio
def setup_development_machine():
    """
    Creates remotely a new ubuntu virtual machine ready to work on the project.

    Returns:
        None
    """
    try:
        print()
        info_print("You need to have Vagrant installed in your host machine.")
        warning_print(
            "This process will clean all data on your previous virtual "
            "machine and build it again from scratch."
        )
        option = input("Do you want to continue? (y/n)\n")
        if option != "y" and option != "Y":
            sys.exit()
        t0 = time.time()
        pretty_print("\nCleaning previous installation ...")
        os.chdir("vagrant")
        run("vagrant destroy --force")
        run("vagrant box update")
        run("vagrant up")
        os.chdir("../")
        remote_development_task("update_repositories")
        remote_development_task("create_app_group_and_user")
        remote_development_task("install_postgresql")
        remote_development_task("create_postgresql_user_and_db")
        remote_development_task("install_jpeg_libraries_for_pillow")
        remote_development_task("install_git")
        remote_development_task("download_project")
        remote_development_task("install_virtualenv")
        remote_development_task("create_virtualenv")
        remote_development_task("export_project_keys")
        remote_development_task("install_python_requirements")
        remote_development_task("make_migrations")
        remote_development_task("migrate")
        remote_development_task("install_npm_and_grunt")
        remote_development_task("install_npm_packages")
        remote_development_task("install_ruby_and_sass")
        remote_development_task("install_unity")
        remote_development_task("create_test_data")
        remote_development_task("install_pycharm")
        remote_development_task("configure_pycharm")
        os.chdir("vagrant")
        run("vagrant halt")
        os.chdir("../")
        local_development_task("show_last_tips")
        t1 = time.time()
        show_time(t0, t1)
    except KeyboardInterrupt:
        error_print("Process aborted. Bye!")
        sys.exit()
コード例 #3
0
ファイル: tasks.py プロジェクト: Lantero/personal-portfolio
    def setup_production_server():
        """
        Configures remotely the production server initial setup and deployment.

        Returns:
            None
        """
        try:
            print()
            info_print(
                "This script will only succeed if you have configured the "
                "production server ssh port to match the one in "
                "config/production.py and have proper ssh access."
            )
            info_print(
                "After this setup, you should configure the admin allowed IP "
                "in the nginx configuration file."
            )
            warning_print(
                "This process will clean all data on the production server "
                "and build up everything again from scratch."
            )
            option = input("Do you want to continue? (y/n)\n")
            if option != "y" and option != "Y":
                sys.exit()
            t0 = time.time()
            remote_production_task("clean_production_server")
            remote_production_task("update_repositories")
            remote_production_task("create_app_group_and_user")
            remote_production_task("install_postgresql")
            remote_production_task("create_postgresql_user_and_db")
            remote_production_task("install_jpeg_libraries_for_pillow")
            remote_production_task("install_git")
            remote_production_task("download_project")
            remote_production_task("install_virtualenv")
            remote_production_task("create_virtualenv")
            remote_production_task("export_project_keys")
            remote_production_task("install_python_requirements")
            remote_production_task("create_runtime_files_and_dirs")
            remote_production_task("collect_static_files")
            remote_production_task("make_migrations")
            remote_production_task("migrate")
            remote_production_task("install_supervisor")
            remote_production_task("configure_supervisor")
            remote_production_task("install_nginx")
            remote_production_task("configure_nginx")
            remote_production_task("restart_server")
            t1 = time.time()
            show_time(t0, t1)
        except KeyboardInterrupt:
            error_print("Process aborted. Bye!")
            sys.exit()
コード例 #4
0
def library(library, skipnoalbum=False):

    for track in library:

        title = track["Name"]
        tokens = []
        location = urllib.request.unquote(track["Location"][7:].replace(
            "%20", " "))

        filename, file_extension = os.path.splitext(location)

        utils.notice_print(title)

        if os.path.exists(location):
            if file_extension == ".mp3":

                audio = MP3(location, ID3=EasyID3)

                audio["artistsort"] = ['']
                audio["titlesort"] = ['']
                audio["albumsort"] = ['']

                if "title" in audio.keys():
                    if audio["title"][0] != title:

                        utils.warning_print('different titles\n\tTitle: ' +
                                            str(audio["title"][0]) + "\n" +
                                            '\tName: ' + title)

                        title_selection = utils.prompt(
                            'Which one would you like to keep? ',
                            ["1", "2", "s"], 0)

                        if title_selection == "2":
                            audio["title"] = [title]
                        elif title_selection == "1":
                            title = audio["title"][0]

                else:
                    utils.warning_print("no title")

                    title_duplication = utils.prompt(
                        'Would you like to clone the name? ', ["1", "2"], 0)

                    if title_duplication == "1":
                        audio["title"] = [title]
                    elif title_duplication == "2":
                        audio["title"] = []

                if "artist" in audio.keys():
                    if "albumartist" in audio.keys():

                        if audio["artist"] != audio["albumartist"]:

                            utils.warning_print(
                                'different artists\n\tArtist: ' +
                                str(audio["artist"]) + "\n" +
                                '\tAlbum artist: ' + str(audio["albumartist"]))

                            artist_selection = utils.prompt(
                                'Which one would you like to keep? ',
                                ["1", "2", "s"], 2)

                            if artist_selection == "1":
                                audio["albumartist"] = audio["artist"]
                            elif artist_selection == "2":
                                audio["artist"] = audio["albumartist"]

                    else:
                        utils.warning_print("no album artist")

                        if skipnoalbum is False:

                            artist_duplication = utils.prompt(
                                'Would you like to substitute < no album artist > with < '
                                + audio["artist"][0] + ' >? ', ["1", "2", "s"],
                                1)

                            if artist_duplication == "1":
                                audio["albumartist"] = audio["artist"]
                            elif artist_duplication == "2":
                                audio["albumartist"] = []

                else:
                    utils.warning_print("no artist")

                title_components = title.split("-")
                title_components_dir = {}

                i = 0

                noconflicts = {"title": False, "artist": False}

                if len(title_components) > 1:

                    utils.warning_print("splittable name")

                    for comp in title_components:

                        comp = comp.strip()
                        title_components_dir[i] = comp

                        if "title" in audio.keys() and len(
                                audio["title"]) > 0 and comp.lower(
                                ) == audio["title"][0].lower():
                            noconflicts["title"] = comp
                            del title_components_dir[i]

                        if "artist" in audio.keys() and len(
                                audio["artist"]) > 0 and comp.lower(
                                ) == audio["artist"][0].lower():
                            noconflicts["artist"] = comp
                            del title_components_dir[i]

                        print("\t" + str(i + 1) + " - " + comp)
                        i += 1

                    # print (len(title_components_dir))

                    title_components_keys = list(title_components_dir.keys())

                    if len(title_components_keys) == 1:
                        suggestion = 0
                    else:
                        suggestion = False

                    if noconflicts["title"] is False:

                        newtitle = utils.prompt(
                            'Which term is the title? ',
                            [str(val + 1)
                             for val in title_components_keys] + ["s"],
                            suggestion)

                        if newtitle != "s":
                            audio["title"] = title_components[int(newtitle) -
                                                              1].strip()
                            title_components_keys.remove(int(newtitle) - 1)

                    if len(title_components_keys) == 1:
                        suggestion = 0
                    else:
                        suggestion = False

                    if noconflicts["artist"] is False:

                        newartist = utils.prompt(
                            'Which term is the artist? ',
                            [str(val + 1)
                             for val in title_components_keys] + ["s"],
                            suggestion)

                        if newartist != "s":
                            audio["artist"] = title_components[int(newartist) -
                                                               1].strip()

                audio.save()

            else:
                utils.error_print("Wrong file extension. Extension: " +
                                  file_extension)
        else:
            utils.error_print("File not found. Location: " + location)

        utils.notice_print("All done.\n\n")