diff options
author | 2016-12-21 21:24:56 +0200 | |
---|---|---|
committer | 2016-12-21 21:24:56 +0200 | |
commit | 2deaf65dfe9ff2d20f4a6ea9b03be5839cc7b899 (patch) | |
tree | d1c7f054929822850f41162b0122d6d631eb8eaf /scripts | |
parent | 1f405257ba6caed845551b0641de914281ecfeba (diff) |
master_daemon: failure if directory in package is not in format v1.11
Change-Id: Ieb8a0438826148296600a5ab1783376e03df1459
Signed-off-by: Yaroslav Brustinov <ybrustin@cisco.com>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/master_daemon.py | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/scripts/master_daemon.py b/scripts/master_daemon.py index bcafe8eb..b5605e50 100755 --- a/scripts/master_daemon.py +++ b/scripts/master_daemon.py @@ -41,15 +41,20 @@ def update_trex(package_path = 'http://trex-tgn.cisco.com/trex/release/latest'): if ret_code: raise Exception('Could not get requested package. Result: %s' % [ret_code, stdout, stderr]) # clean old unpacked dirs - unpacked_dirs = glob(os.path.join(tmp_dir, 'v[0-9].[0-9][0-9]')) - for unpacked_dir in unpacked_dirs: - shutil.rmtree(unpacked_dir) + tmp_files = glob(os.path.join(tmp_dir, '*')) + for tmp_file in tmp_files: + if os.path.isdir(tmp_file) and not os.path.islink(tmp_file): + shutil.rmtree(tmp_file) # unpacking - ret_code, stdout, stderr = run_command('tar -xzf %s' % os.path.join(tmp_dir, file_name), timeout = 60, cwd = tmp_dir) + ret_code, stdout, stderr = run_command('tar -xzf %s' % os.path.join(tmp_dir, file_name), timeout = 120, cwd = tmp_dir) if ret_code: raise Exception('Could not untar the package. %s' % [ret_code, stdout, stderr]) - unpacked_dirs = glob(os.path.join(tmp_dir, 'v[0-9].[0-9][0-9]')) - if not len(unpacked_dirs) or len(unpacked_dirs) > 1: + tmp_files = glob(os.path.join(tmp_dir, '*')) + unpacked_dirs = [] + for tmp_file in tmp_files: + if os.path.isdir(tmp_file) and not os.path.islink(tmp_file): + unpacked_dirs.append(tmp_file) + if len(unpacked_dirs) != 1: raise Exception('Should be exactly one unpacked directory, got: %s' % unpacked_dirs) cur_dir = args.trex_dir if os.path.islink(cur_dir) or os.path.isfile(cur_dir): |