From: Garming Sam Date: Tue, 27 Feb 2018 23:38:12 +0000 (+1300) Subject: domain.py: Give some advice if the schema upgrade command fails X-Git-Tag: talloc-2.1.12~347 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ea3a80e66967cab13a664c50ae5f7d23be805e22;p=thirdparty%2Fsamba.git domain.py: Give some advice if the schema upgrade command fails Signed-off-by: Garming Sam Reviewed-by: Andreas Schneider --- diff --git a/python/samba/netcmd/domain.py b/python/samba/netcmd/domain.py index 7b23fa794de..d3b9b0ccf6f 100644 --- a/python/samba/netcmd/domain.py +++ b/python/samba/netcmd/domain.py @@ -4150,9 +4150,14 @@ class cmd_domain_schema_upgrade(Command): # Apply patches if we parsed the Schema-Updates.md file diff = os.path.abspath(os.path.join(diff_dir, update + '.diff')) if temp_folder and os.path.exists(diff): - p = subprocess.Popen(['patch', update, '-i', diff], - stdout=subprocess.PIPE, - stderr=subprocess.PIPE, cwd=temp_folder) + try: + p = subprocess.Popen(['patch', update, '-i', diff], + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, cwd=temp_folder) + except (OSError, IOError): + shutil.rmtree(temp_folder) + raise CommandError("Failed to upgrade schema. Check if 'patch' is installed.") + stdout, stderr = p.communicate() if p.returncode: