Пример #1
0
    def run():
        if Dev.get("DO_NOT_UPDATE"):
            Run.prg("pip", "freeze > requirements.txt")
            return True

        Update.pull_updates_from_git()
        return Update.run_migrations()
Пример #2
0
def start_main_program():
    main = Path(".main.py")

    if main.exists():
        ans = Run.prg("python", f'"{main.absolute()}"', useSubprocess=True)

        if ans == 0:
            # There was an error
            Slack.upload_log()
            raise Exception(
                "\n\nThere was an error.. Contact your administrator.\n\n")

    else:
        Log(".main.py Does not exist!!", "warning")
        Dialog(title="Fatal Error!",
               body=[
                   f'"{main.absolute()}" doesnt exist!',
                   f'\n',
                   f'\n',
                   f'Something went terribly wrong.. Contact your',
                   f'administrator.',
                   f'\n',
                   f'\n',
               ],
               clear=False).press_enter()
        Slack.upload_log()
Пример #3
0
    def to_wav(self, folderpath):
        folderpath = Path(folderpath)
        Folder.create(folderpath)

        mp3 = self.filepath
        wav = Path(f'{folderpath.absolute()}/{mp3.stem}.wav')
        stem, num, ext = File.split_name(wav.name)

        if wav.is_file():
            # File already exists locally, do not do anything
            Log(f'File "{wav.name}" already exists, keeping local file.')
            return True

        Run.ffmpeg(args="-i",
                   source=mp3.absolute(),
                   destination=wav.absolute(),
                   codec="-c:a pcm_s24le")
        return True
Пример #4
0
    def run_migrations():
        migrations = glob("migrations/*")
        migrations.sort()
        migrations = [Path(x) for x in migrations]
        current_version = Settings.get_version()
        result = True

        for migration in migrations:
            migration_version = Decimal(migration.stem.replace("_", "."))

            if migration_version > current_version:
                Update.install_pip_packages()

                ans = Run.prg("python",
                              migration.absolute(),
                              useSubprocess=True)

                if ans == 0:
                    Slack.upload_log()
                    Log(
                        f'There was a problem loading this migration file!\n "{migration.absolute()}"',
                        "warning")
                    Log.press_enter()
                    # If there was an issue upgrading the migration, we don't want to set the new version
                    return False
                elif ans != 1:
                    Log("You must restart the program to finish the update!",
                        "notice")
                    Log.press_enter()
                    result = False

                Settings.set_version(migration_version)

                # Push a notification to Slack
                Slack(
                    f'{Settings.get_username(capitalize=True)} has upgraded to V{migration_version}!'
                )

        return result
Пример #5
0
    def open_studio_one(self):
        Log("OPENING STUDIO ONE","notice")

        # First create a temp version of the project
        File.recursive_overwrite( self.get_song_file(), self.get_song_file(version="temp") )

        Dialog(
            title = "Wait for Studio One to close!",
            body  = "DO NOT CLOSE THIS WINDOW!!"
        )

        if Dev.get("NO_OPEN_STUDIO_ONE"):
            # Do not open studio one
            return True

        # Build the dummy files
        self.set_dummy_files()

        # Open Studio One
        ans = Run.prg(
            alias   = "open",
            command = f'{ self.get_song_file(version="temp") }',
            wait    = True
        )

        # Remove dummy files
        self.remove_dummy_files()

        if ans != 0:
            return False

        # Copy over any saved data to the original song file
        File.recursive_overwrite( self.get_song_file(version="temp"), self.get_song_file() )
        File.delete( self.get_song_file(version="temp") )

        return True
Пример #6
0
    def to_mp3(self, folderpath, username_ignore=False):
        folderpath = Path(folderpath)

        wav = self.filepath
        mp3 = Path(f'{folderpath.absolute()}/{wav.stem}.mp3')
        username = Settings.get_username()

        if "_old" in wav.name:
            Dialog(
                title="Warning! Can't Upload *_old* Audio File!",
                body=[
                    f'It appears that you have not yet resolved the audio file',
                    f'conflict for "{wav.name}"!  You must either delete this file,',
                    f'or re-name it and re-link it in Studio One!',
                    f'\n',
                    f'\n',
                ],
                clear=False).press_enter()
            return False

        if not mp3.is_file():
            if not username in wav.name.lower() and not username_ignore:
                dialog = Dialog(
                    title="Warning! Where Is Your Name?!",
                    body=[
                        f'It appears that the file',
                        f'\n',
                        f'\n',
                        f' - {wav.parent.absolute().name}/{wav.name}',
                        f'\n',
                        f'\n',
                        f'does not contain your name.. Are you sure you recorded',
                        f'on the correct track?!  Doing this can cause serious',
                        f'version control issues!!',
                        f'\n',
                        f'\n',
                        f'Since you have already removed unused audio files from',
                        f'the pool, AND selected the checkbox to delete those',
                        f'audio files..  You should go back into your Studio One',
                        f'project, remove this clip from the timeline, OR rename',
                        f'this clip to include your name, and then re-run the',
                        f'upload!',
                        f'\n',
                        f'\n',
                        f'If you are ABSOLUTELY SURE that this is in error, aka',
                        f'uploading a project from band practice, then type "yes"',
                        f'at the prompt, or "yesall" to ignore all other warnings',
                        f'for this.',
                        f'\n',
                        f'\n',
                        f'If you want to exit now, type "no" at the prompt.',
                        f'\n',
                        f'\n',
                    ],
                    clear=False)
                ans = dialog.get_mult_choice(["yes", "yesall", "no"])

                if ans == "no":
                    return False
                elif ans == "yesall":
                    username_ignore = True

        else:
            Log(f'Keeping cached file "{mp3.name}"')
            return True

        Run.ffmpeg(args="-i",
                   source=wav.absolute(),
                   destination=mp3.absolute(),
                   codec="")

        if username_ignore:
            return {"username_ignore": True}
        return True
Пример #7
0
 def install_pip_packages():
     Run.prg("pip", "install -r requirements.txt")
     if Dev.isDev():
         Run.prg("pip", "freeze > requirements.txt")
Пример #8
0
 def pull_updates_from_git():
     Run.prg("git", "pull --rebase")