← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands-website/add_DISPLAY_to_update_help into lp:widelands-website

 

kaputtnik has proposed merging lp:~widelands-dev/widelands-website/add_DISPLAY_to_update_help into lp:widelands-website.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands-website/add_DISPLAY_to_update_help/+merge/295756

Use DISPLAY=:1 for update_help.py because wl_map_object_info needs access to the x-server on DISPLAY:1. So

./manage.py update_help

runs without setting the environment variable before by hand.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands-website/add_DISPLAY_to_update_help into lp:widelands-website.
=== modified file 'wlhelp/management/commands/update_help.py'
--- wlhelp/management/commands/update_help.py	2016-05-22 11:35:57 +0000
+++ wlhelp/management/commands/update_help.py	2016-05-25 18:51:24 +0000
@@ -291,6 +291,14 @@
         current_dir = os.path.dirname(os.path.realpath(__file__))
         is_json_valid = False
         os.chdir(WIDELANDS_SVN_DIR)
+        # Because wl_map_object_info needs access to a graphical server, which is running at
+        # DISPLAY :1 on the productive server, we set the environment variable
+        # accordingly.
+        display_set = False
+        if not 'DISPLAY' in os.environ:
+            # No DISPLAY set -> default on the server console
+            display_set = True
+            os.environ['DISPLAY'] = ':1'
         try:
             subprocess.check_call(
                 [os.path.normpath('wl_map_object_info'), json_directory])
@@ -298,6 +306,10 @@
             print(
                 "Error: Unable to execute 'wl_map_object_info' for generating the JSON files.")
 
+        if display_set:
+            # Unset DISPLAY
+            os.environ.pop('DISPLAY')
+
         # Now we validate that they are indeed JSON files (syntax check only)
         validator_script = os.path.normpath(
             WIDELANDS_SVN_DIR + '/utils/validate_json.py')


Follow ups