Opened 2 years ago

Closed 4 weeks ago

#5506 closed defect (fixed)

Python 3 compatibility for ./bin/gmg assetlink

Reported by: Vaelatern Owned by:
Priority: trivial Milestone:
Component: programming Keywords: python3
Cc: Parent Tickets:

Description

Without this patch:

$ ./bin/gmg assetlink
/var/www/mediagoblin/mg/mediagoblin/media_types/video/transcoders.py:37: PyGIWarning: GstPbutils was imported without specifying a version first. Use gi.require_version('GstPbutils', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import GstPbutils
WARNING: audiolab is not installed so wav2png will not work
Traceback (most recent call last):
  File "./bin/gmg", line 11, in <module>
    load_entry_point('mediagoblin', 'console_scripts', 'gmg')()
  File "/var/www/mediagoblin/mg/mediagoblin/gmg_commands/__init__.py", line 148, in main_cli
    args.func(args)
  File "/var/www/mediagoblin/mg/mediagoblin/gmg_commands/assetlink.py", line 141, in assetlink
    mgoblin_app = commands_util.setup_app(args)
  File "/var/www/mediagoblin/mg/mediagoblin/gmg_commands/util.py", line 28, in setup_app
    mgoblin_app = app.MediaGoblinApp(args.conf_file)
  File "/var/www/mediagoblin/mg/mediagoblin/app.py", line 121, in __init__
    self.theme_registry, self.current_theme = register_themes(self.app_config)
  File "/var/www/mediagoblin/mg/mediagoblin/tools/theme.py", line 83, in register_themes
    and registry.has_key(current_theme_name):
AttributeError: 'dict' object has no attribute 'has_key'

With this patch:

$ ./bin/gmg assetlink
/var/www/mediagoblin/mg/mediagoblin/media_types/video/transcoders.py:37: PyGIWarning: GstPbutils was imported without specifying a version first. Use gi.require_version('GstPbutils', '1.0') before import to ensure that the right version gets loaded.
  from gi.repository import GstPbutils
WARNING: audiolab is not installed so wav2png will not work
Linked the theme's asset directory:
  /var/www/mediagoblin/mg/mediagoblin/themes/airy/assets
to:
  /var/www/mediagoblin/mg/user_dev/theme_static
Skipping "coreplugin_basic_auth"; already set up.

Patch:

diff --git a/mediagoblin/tools/theme.py b/mediagoblin/tools/theme.py
index 97b041a6..ebb03980 100644
--- a/mediagoblin/tools/theme.py
+++ b/mediagoblin/tools/theme.py
@@ -80,7 +80,7 @@ def register_themes(app_config, builtin_dir=BUILTIN_THEME_DIR):

     current_theme_name = app_config.get('theme')
     if current_theme_name \
-            and registry.has_key(current_theme_name):
+            and current_theme_name in registry.keys():
         current_theme = registry[current_theme_name]
     else:
         current_theme = None

Subtickets

Change History (3)

comment:1 Changed 2 years ago by Vaelatern

Should note that key in dic and key in dic.keys() both work in python 2.7 and 3.x, but one is more clean to those who are not as comfortable in python.

comment:2 Changed 12 months ago by ShawnRisk

Status: newreview

This should be made into a patch.

comment:3 Changed 4 weeks ago by Ben Sturmfels

Resolution: fixed
Status: reviewclosed

Thanks Vaelatern, it looks as though the issue you mentioned above was fixed in commit 06d70c4b968c4d116496d93228f306aea29e5066, so I'll close this ticket now. Please get in touch if you are still seeing issues.

Thanks for taking the time to bring this up and sorry for the delay in responding.

Note: See TracTickets for help on using tickets.