Пример #1
0
 def remove_dirty(self):
     username = Settings.get_username(capitalize=True)
     if username in self.entry.data["is_dirty"]:
         self.entry.data["is_dirty"].remove(username)
         self.entry.update()
         return True
     return False
Пример #2
0
 def set_dirty(self):
     username = Settings.get_username(capitalize=True)
     if username not in self.entry.data["is_dirty"]:
         self.entry.data["is_dirty"].append(username)
         self.entry.update()
         return True
     return False
Пример #3
0
 def remove_lock(self):
     # Lets undo the mutex lock
     # Only unlock if we were the ones to lock it first!
     if self.is_locked() == Settings.get_username(capitalize=True):
         self.entry.data["is_locked"] = None
         self.entry.update()
         return True
     return False
Пример #4
0
 def set_lock(self):
     # Lets mutex lock this beach
     # Only lock if there is no lock currently
     if not self.is_locked():
         self.entry.data["is_locked"] = Settings.get_username(
             capitalize=True)
         self.entry.update()
         return True
     return False
Пример #5
0
def menu_project_options(project):
    options = []

    options.append(["Open", project.open_project])
    # options.append(["Change Name", None])
    # options.append(["Duplicate", None])

    if not project.is_remote() or project.is_dirty():
        options.append(["Upload", project.upload_project])

    if project.is_remote():
        if not project.is_up_to_date():
            options.append(["Download", project.download_and_extract])
        options.append(["Change Category", project.change_category])

    mutex = project.is_locked()
    if mutex and mutex == Settings.get_username(capitalize=True):
        options.append(["Unlock", project.remove_lock])

    if project.is_local():
        options.append(["Duplicate", project.duplicate])

    options.append(["Delete", project.delete_project])

    menu = Menu(title=f'Project "{project.entry.name}"',
                options=[x[0] for x in options])

    result = menu.get_result()

    if result == "back":
        return True
    else:
        if options[result][0] == "Delete":
            return options[result][1]()

        if not options[result][1]():
            return False

        return menu_project_options(project)
Пример #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 get_nice_username():
     return Settings.get_username(capitalize=True)
Пример #8
0
    def open_project(self):
        Log(f'Opening project "{self.entry.name}"..')

        # - Download any new updates / Download new project
        if not self.is_up_to_date():
            Log("Project Update Available!")
            if not self.download_and_extract():
                return False

        # Check for mutex lock
        mutex = self.is_locked()
        if mutex and mutex != Settings.get_username(capitalize=True):
            # Provide dialog to alert user that they can't save
            if not self.dialog_project_locked():
                return True
        else:
            # Lets mutex lock this beach
            self.set_lock()

        # - Open Studio One Project
        if not self.open_studio_one():
            return False

        if not self.is_remote():
            # Lets ask if user wants to upload project
            if self.dialog_upload_new_project():
                if not self.upload_project():
                    Log("An error occurred when trying to upload the project!","warning")
                    Log.press_enter()
                    return False

        elif self.is_dirty():
            # Check for mutex lock
            mutex = self.is_locked()

            if mutex and mutex != Settings.get_username(capitalize=True):
                # Project was locked by someone else
                # Remove any saved changes
                Log("Resetting project.. Undoing changes..")
                self.extract_project()
            else:
                ans = self.dialog_upload_clear_cancel()
                if ans == "y":
                    # Lets upload our changes!
                    if not self.upload_project():
                        Log("An error occurred when trying to upload the project!","warning")
                        Log.press_enter()
                        self.remove_lock()
                        return False
                    # Remove our name from the dirty list if it exists
                    self.remove_dirty()
                elif ans == "clear":
                    self.extract_project()
                    # Remove our name from the dirty list if it exists
                    self.remove_dirty()
                else:
                    # The user is not uploading new changes..
                    # Make sure to set the project to dirty!
                    self.set_dirty()

        # Remove the lock we placed on when opening the project
        self.remove_lock()

        return True