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')
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 log.info('Downloaded')
45 except subprocess.CalledProcessError as err:
52 parser = argparse.ArgumentParser(description='Download rpm packages from list')
53 parser.add_argument('rpm_list', metavar='rpm-list',
54 help='File with list of npm packages to download.')
55 parser.add_argument('--output-dir', '-o', default=os.getcwd(),
56 help='Download destination')
58 args = parser.parse_args()
60 logging.basicConfig(stream=sys.stdout, level=logging.INFO, format='%(message)s')
62 sys.exit(download(args.rpm_list, args.output_dir))
65 if __name__ == '__main__':