Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Gracefully handle exceptions during direct i18n loading #628

Merged
merged 1 commit into from
Aug 24, 2024

Conversation

StandingPadAnimations
Copy link
Collaborator

If translations.py doesn't exist, MCprep moves to direct i18n, which directly uses MO files for translations (at the cost of some UI updating issues). However, if these MO files do not exist, then MCprep will throw an exception. Since this exception occurs in the creation of MCprepEnv, MCprep is rendered unusable.

This patch adds a basic try-except statement to allow MCprepEnv to handle these exceptions gracefully.

If translations.py doesn't exist, MCprep moves to direct i18n, which
directly uses MO files for translations (at the cost of some UI updating
issues). However, if these MO files do not exist, then MCprep will throw
an exception. Since this exception occurs in the creation of
`MCprepEnv`, MCprep is rendered unusable.

This patch adds a basic try-except statement to allow `MCprepEnv` to
handle these exceptions gracefully.

Signed-off-by: Mahid Sheikh <[email protected]>
@StandingPadAnimations StandingPadAnimations linked an issue Aug 23, 2024 that may be closed by this pull request
2 tasks
@TheDuckCow
Copy link
Member

Can you share the code to auto run the translations again? ie the bash command so I can insert them into the push_latest.sh script. There I can do a check that makes it auto-quit if there are untracked changes (or, should we always just auto-commit machine translation updates?). In that PR I'll also fix the usage of bab instead of the old builder, rather confused how we didn't run into this in the last release. I was probably lucky and did a single non-dev build with bab locally before running the main script

@StandingPadAnimations
Copy link
Collaborator Author

Sure

bab -b translate

@TheDuckCow
Copy link
Member

Hm that command was already there, but I guess it comes back down to it being the old pre-bab command.

@TheDuckCow TheDuckCow changed the base branch from master to dev August 24, 2024 02:48
Copy link
Member

@TheDuckCow TheDuckCow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving, changed base to dev as I'm going to make another commit change for the releaser script there.

@TheDuckCow TheDuckCow merged commit 09418d4 into dev Aug 24, 2024
1 check passed
@TheDuckCow TheDuckCow deleted the 627-graceful-translations-fix branch August 24, 2024 02:49
@TheDuckCow
Copy link
Member

TheDuckCow commented Aug 24, 2024

Looks like it wasn't all the way graceful, had to pull the v3.6.1.1 release after publishign as testing the build locally now ran into this issue, which now seems to always trigger even with translations. Now I'm not even sure why the automated tests aren't catching this, since there are enable/disable tests that should be occurring. I'm less familiar with this module

Addon.APIRC, ERROR, ThreadPoolExecutor-0_0, 11:15:20, api_remote_control_params.py/_get_user_info_from_api:266: Not authorized
Addon.APIRC, ERROR, ThreadPoolExecutor-0_0, 11:15:20, api_remote_control_params.py/thread_execute:282: get_user_info failed: Not authorized
Addon, WARNING, API RC Collect, 11:15:20, toolbox.py/callback_get_user_data_done:593: callback_get_user_data_done NOK
Traceback (most recent call last):
  File "/Applications/Blender 4.3/blender.app/Contents/Resources/4.3/scripts/modules/addon_utils.py", line 407, in enable
    mod = importlib.import_module(module_name)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Applications/Blender 4.3/blender.app/Contents/Resources/4.3/python/lib/python3.11/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 940, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/patrickcrawford/Library/Application Support/Blender/4.3/scripts/addons/MCprep_addon/__init__.py", line 59, in <module>
    from . import load_modules
  File "/Users/patrickcrawford/Library/Application Support/Blender/4.3/scripts/addons/MCprep_addon/load_modules.py", line 118, in <module>
    from . import mcprep_ui
  File "/Users/patrickcrawford/Library/Application Support/Blender/4.3/scripts/addons/MCprep_addon/mcprep_ui.py", line 106, in <module>
    class MCPREP_MT_mob_spawner(bpy.types.Menu):
  File "/Users/patrickcrawford/Library/Application Support/Blender/4.3/scripts/addons/MCprep_addon/mcprep_ui.py", line 108, in MCPREP_MT_mob_spawner
    bl_label = env._("Mob Spawner")
               ^^^^^^^^^^^^^^^^^^^^
  File "/Users/patrickcrawford/Library/Application Support/Blender/4.3/scripts/addons/MCprep_addon/conf.py", line 166, in _
    if bpy.context.preferences.view.language in self.languages:
                                                ^^^^^^^^^^^^^^
AttributeError: 'MCprepEnv' object has no attribute 'languages'

Working on another patch for you to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MCprep 3.6.1 Update is Missing Compiled Translations
2 participants