2 # -*- coding: utf-8 -*-
4 # COPYRIGHT NOTICE STARTS HERE
6 # Copyright 2019 © Samsung Electronics Co., Ltd.
8 # Licensed under the Apache License, Version 2.0 (the "License");
9 # you may not use this file except in compliance with the License.
10 # You may obtain a copy of the License at
12 # http://www.apache.org/licenses/LICENSE-2.0
14 # Unless required by applicable law or agreed to in writing, software
15 # distributed under the License is distributed on an "AS IS" BASIS,
16 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 # See the License for the specific language governing permissions and
18 # limitations under the License.
20 # COPYRIGHT NOTICE ENDS HERE
30 log = logging.getLogger(name=__name__)
33 def download(rpm_list, dst_dir):
34 if not base.check_tool('yumdownloader'):
35 log.error('ERROR: yumdownloader is not installed')
36 raise RuntimeError('yumdownloader missing')
38 rpm_set = base.load_list(rpm_list)
40 command = 'yumdownloader --destdir={} {}'.format(dst_dir, ' '.join(rpm_set))
41 log.info('Running command: {}'.format(command))
43 subprocess.check_call(command.split())
44 except subprocess.CalledProcessError as err:
45 log.exception(err.output)
47 log.info('Downloaded')
51 parser = argparse.ArgumentParser(description='Download rpm packages from list')
52 parser.add_argument('rpm_list', metavar='rpm-list',
53 help='File with list of npm packages to download.')
54 parser.add_argument('--output-dir', '-o', default=os.getcwd(),
55 help='Download destination')
57 args = parser.parse_args()
59 logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(message)s')
62 download(args.rpm_list, args.output_dir)
63 except (subprocess.CalledProcessError, RuntimeError):
68 if __name__ == '__main__':