Example #1
0
    def compress_project(self, set_hash=True):
        Log("Compressing project..", "notice")

        # Clean out temp project if it exists
        Log("Cleaning out temp folder")
        Folder.delete(self.get_temp_dir())

        # Extract cache if it exists
        if self.is_cached():
            Tar.extract(filepath=self.get_cache_file(),
                        destination=self.get_temp_dir().parent)
        else:
            Folder.create(self.get_temp_dir())

        # Create folders if they dont exist
        self.create_required_folders(temp=True, clean=False)

        # Copy from 'extracted_songs' to 'temp'
        if not self.move_extracted_song_to_temp():
            Log("Could not move project from 'extracted_songs' to 'temp'..",
                "warning")
            Log.press_enter()
            return False

        # Compress project to *.lof
        Tar.compress(folderpath=self.get_temp_dir(),
                     destination=self.get_cache_file())

        if set_hash:
            # Set new local hash
            Hash.set_project_hash(self, Hash.create_hash_from_project(self))

        return True
Example #2
0
    def create_required_folders(self, temp=False, clean=True):
        # 'temp=True'  will focus on the temp/<song> directory
        # 'temp=False' will focus on the extracted_songs/<song> directory
        # 'clean=True' will delete the folders first, then recreate them

        # Need to make sure these folders exist
        Log("Creating necessary folders")

        if temp:
            # Clean out temp dir
            if clean:
                Folder.delete(self.get_temp_dir())
            Folder.create(self.get_temp_dir())
        else:
            # Create new extracted dir, remove if exists
            if clean:
                Folder.delete(self.get_root_dir())
            Folder.create(self.get_root_dir())

        for location in ["Media", "Bounces", "Mixdown"]:
            if temp:
                Folder.create(self.get_temp_dir() / location)
            Folder.create(self.get_root_dir() / location)

        return True
Example #3
0
    def delete_project(self):
        options = []
        if self.is_local():
            options.append("local")
        if self.is_remote():
            options.append("remote")
        if self.is_local() and self.is_remote():
            options.append("both")
        options.append("back")

        dialog = Dialog(
            title=f'Deleting Project "{self.entry.name}"',
            body=[
                f'Would you like to delete the local or remote version?',
                f'\n',
                f'\n',
                f'Warning: This is not reversible!',
            ])

        ans = dialog.get_mult_choice(options)

        if ans == "back":
            return True

        if ans == "local" or ans == "both":
            # Remove extracted folder and cached file
            File.delete(self.get_cache_file())
            Folder.delete(self.get_root_dir())

            # Remove hash from local db
            Hash.remove_project_hash(self)

            Menu.notice = f'Project "{self.entry.name}" deleted locally!'

        if ans == "remote" or ans == "both":
            if self.is_remote():
                # Delete compressed file
                project_id = self.entry.data["id"]
                if project_id:
                    Drive.delete(project_id)

                # Delete folder with scratch tracks and mixdowns
                folder_id = Drive.get_id(self.entry.name)
                if folder_id:
                    Drive.delete(folder_id)

                # Remove entry from remote db
                self.entry.destroy()

                Menu.notice = f'Project "{self.entry.name}" deleted remotely!'

        if ans == "both":
            Menu.notice = f'Project "{self.entry.name}" completely deleted!'

        return True
Example #4
0
    def extract_project(self):
        Log("Extracting project..")

        # Create required folders in 'extracted_songs'
        self.create_required_folders()

        # Extract cache to 'temp' folder
        Log("Extracting project")
        Tar.extract(self.get_cache_file(), self.get_temp_dir().parent)

        # Copy and convert from 'temp' to 'extracted_songs'
        if not self.move_temp_to_extracted_songs():
            # If function fails, remove broken extracted project
            # to prevent issues trying again.
            Folder.delete(self.get_root_dir())
            Log("Could not move project from 'temp' to 'extracted_songs'..",
                "warning")
            Log.press_enter()
            return False

        return True
def clear_all_local_projects():
    result = Dialog("Clear Local Projects", [
        f'This will clear all locally cached projects to save',
        f'space on your hard drive.',
        f'\n',
        f'This will NOT:',
        f'\n',
        f'  - Delete any songs on the cloud',
        f'\n',
        f'  - Delete any dirty projects on your computer',
        f'\n',
        f'    that have not been uploaded yet',
        f'\n',
        f'  - Remove any projects that have never been',
        f'\n',
        f'    uploaded to the cloud yet',
        f'\n',
    ]).confirm()

    if result:
        for project in ProjectIndex.get_all_projects():
            if not project.is_dirty() and project.is_remote():
                # Just in case we have it locked
                project.remove_lock()

                # Remove extracted folder and cached file
                File.delete(project.get_cache_file())
                Folder.delete(project.get_root_dir())

                # Remove hash from local db
                Hash.remove_project_hash(project)

            Menu.notice = f'Local projects cleared!'
    else:
        Menu.notice = f'No local projects were cleared..'
    return True