]> git.donarmstrong.com Git - deb_pkgs/autorandr.git/commitdiff
Improve the error message if running a userscript fails (see issue #65)
authorPhillip Berndt <phillip.berndt@googlemail.com>
Sun, 18 Dec 2016 09:54:52 +0000 (10:54 +0100)
committerPhillip Berndt <phillip.berndt@googlemail.com>
Sun, 18 Dec 2016 09:54:52 +0000 (10:54 +0100)
autorandr.py

index 16b67df0ad5a28ed812e38f20be186d4ca787196..f62ad073b5b9ab118104a58d699df51debbf640e 100755 (executable)
@@ -767,7 +767,10 @@ def exec_scripts(profile_path, script_name, meta_information=None):
         if script_name not in ran_scripts:
             script = os.path.join(folder, script_name)
             if os.access(script, os.X_OK | os.F_OK):
-                all_ok &= subprocess.call(script, env=env) != 0
+                try:
+                    all_ok &= subprocess.call(script, env=env) != 0
+                except:
+                    raise AutorandrException("Failed to execute user command: %s" % (script,))
                 ran_scripts.add(script_name)
 
         script_folder = os.path.join(folder, "%s.d" % script_name)
@@ -777,7 +780,10 @@ def exec_scripts(profile_path, script_name, meta_information=None):
                 if check_name not in ran_scripts:
                     script = os.path.join(script_folder, file_name)
                     if os.access(script, os.X_OK | os.F_OK):
-                        all_ok &= subprocess.call(script, env=env) != 0
+                        try:
+                            all_ok &= subprocess.call(script, env=env) != 0
+                        except:
+                            raise AutorandrException("Failed to execute user command: %s" % (script,))
                         ran_scripts.add(check_name)
 
     return all_ok
@@ -1042,6 +1048,8 @@ def main(argv):
                     apply_configuration(load_config, config, True)
                 apply_configuration(load_config, config, False)
                 exec_scripts(scripts_path, "postswitch", script_metadata)
+        except AutorandrException as e:
+            raise AutorandrException("Failed to apply profile '%s'" % load_profile, e, e.report_bug)
         except Exception as e:
             raise AutorandrException("Failed to apply profile '%s'" % load_profile, e, True)