Ejemplo n.º 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()
Ejemplo n.º 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()
Ejemplo n.º 3
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
Ejemplo n.º 4
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
Ejemplo n.º 5
0
 def install_pip_packages():
     Run.prg("pip", "install -r requirements.txt")
     if Dev.isDev():
         Run.prg("pip", "freeze > requirements.txt")
Ejemplo n.º 6
0
 def pull_updates_from_git():
     Run.prg("git", "pull --rebase")