From 867d193648723e23ce31974b625116656512b52b Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 16 Apr 2013 14:19:10 +0100 Subject: Give better error message if extension is not executable --- morphlib/plugins/deploy_plugin.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/morphlib/plugins/deploy_plugin.py b/morphlib/plugins/deploy_plugin.py index 94ac8a75..7a6f2b92 100644 --- a/morphlib/plugins/deploy_plugin.py +++ b/morphlib/plugins/deploy_plugin.py @@ -18,6 +18,7 @@ import cliapp import gzip import os import shutil +import stat import tarfile import tempfile import urlparse @@ -206,6 +207,9 @@ class DeployPlugin(cliapp.Plugin): if not os.path.exists(ext_filename): raise morphlib.Error( 'Could not find extension %s%s' % (name, kind)) + if not self._is_executable(ext_filename): + raise morphlib.Error( + 'Extension not executable: %s' % ext_filename) delete_ext = False else: # Found it in the system morphology's repository. @@ -222,6 +226,11 @@ class DeployPlugin(cliapp.Plugin): if delete_ext: os.remove(ext_filename) + + def _is_executable(self, filename): + st = os.stat(filename) + mask = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH + return (stat.S_IMODE(st.st_mode) & mask) != 0 def _cat_file(self, repo_dir, ref, pathname): '''Retrieve contents of a file from a git repository.''' -- cgit v1.2.1