Blender Kitsu: Fix Gazu Module out of sync #119

Merged
Nick Alberelli merged 11 commits from :fix/restore-gazu-out-of-sync into main 2023-07-13 19:39:30 +02:00
3 changed files with 12 additions and 14 deletions
Showing only changes of commit a0b2786e35 - Show all commits

View File

@ -38,7 +38,7 @@ from blender_kitsu.types import (
User,
)
from blender_kitsu.logger import LoggerFactory
from blender_kitsu.gazu.exception import RouteNotFoundException
import gazu
logger = LoggerFactory.getLogger()
@ -411,7 +411,6 @@ def get_user_all_tasks() -> List[Task]:
def _init_cache_entity(
entity_id: str, entity_type: Any, cache_variable_name: Any, cache_name: str
) -> None:
if entity_id:
try:
globals()[cache_variable_name] = entity_type.by_id(entity_id)
@ -420,7 +419,7 @@ def _init_cache_entity(
cache_name,
globals()[cache_variable_name].name,
)
except RouteNotFoundException:
except gazu.exception.RouteNotFoundException:
logger.error(
"Failed to initialize active %s cache. ID not found on server: %s",
cache_name,

View File

@ -26,8 +26,7 @@ from blender_kitsu.shot_builder.render_settings import RenderSettings
from blender_kitsu.shot_builder.connectors.connector import Connector
import requests
from blender_kitsu import cache
from blender_kitsu.gazu.asset import all_assets_for_shot
from blender_kitsu.gazu.shot import all_shots_for_project, all_sequences_for_project
import gazu
import typing
import logging
@ -168,7 +167,7 @@ class KitsuConnector(Connector):
def get_shots(self) -> typing.List[ShotRef]:
project = cache.project_active_get()
kitsu_sequences = all_sequences_for_project(project.id)
kitsu_sequences = gazu.shot.all_sequences_for_project(project.id)
sequence_lookup = {
sequence_data['id']: KitsuSequenceRef(
@ -179,7 +178,7 @@ class KitsuConnector(Connector):
for sequence_data in kitsu_sequences
}
kitsu_shots = all_shots_for_project(project.id)
kitsu_shots = gazu.shot.all_shots_for_project(project.id)
shots: typing.List[ShotRef] = []
for shot_data in kitsu_shots:
@ -230,7 +229,7 @@ class KitsuConnector(Connector):
return shots
def get_assets_for_shot(self, shot: Shot) -> typing.List[AssetRef]:
kitsu_assets = all_assets_for_shot(shot.kitsu_id)
kitsu_assets = gazu.asset.all_assets_for_shot(shot.kitsu_id)
return [
AssetRef(name=asset_data['name'], code=asset_data['code'])

View File

@ -2407,9 +2407,8 @@ class KITSU_OT_vse_publish_edit_revision(bpy.types.Operator):
sorted_edits = []
active_project = cache.project_active_get()
for edit in gazu.edit.get_all_edits_with_tasks():
if (edit["project_id"] == active_project.id) and not edit['canceled']:
sorted_edits.append(edit)
for edit in gazu.edit.all_edits_for_project(active_project.id):
sorted_edits.append(edit)
return [
(
@ -2423,7 +2422,7 @@ class KITSU_OT_vse_publish_edit_revision(bpy.types.Operator):
def get_edit_task_items(
self: Any, context: bpy.types.Context
) -> List[Tuple[str, str, str]]:
tasks = gazu.tasks.all_tasks_for_edit(self.edit_entry)
tasks = gazu.task.all_tasks_for_edit(self.edit_entry)
return [
(
item.get("id"),
@ -2456,7 +2455,8 @@ class KITSU_OT_vse_publish_edit_revision(bpy.types.Operator):
def invoke(self, context, event):
# Ensure user has permissions to access edit data
try:
edits = gazu.edit.get_all_edits_with_tasks()
active_project = cache.project_active_get()
edits = gazu.edit.all_edits_for_project(active_project.id)
except gazu.exception.NotAllowedException:
self.report(
{"ERROR"}, "Kitsu User doesn't have permissions to access edit data."
@ -2499,7 +2499,7 @@ class KITSU_OT_vse_publish_edit_revision(bpy.types.Operator):
active_project = cache.project_active_get()
existing_previews = gazu.edit.get_all_previews_for_edit(self.edit_entry)
existing_previews = gazu.edit.all_previews_for_edit(self.edit_entry)
len_previews = get_dict_len(existing_previews)
revision = str(set_revision_int(len_previews)).zfill(3)