Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
res = [res]
for url in res:
log.info("Downloading {} ...".format(url))
# there can be many assets, so we do not "rename" them
# there can be only one source, so we allow passing custom filename for it
download_file(url, args.download if args.format == 'source' else None)
sys.exit(0)
if args.action == 'install':
rpms = [asset for asset in res['assets'] if asset.endswith('.rpm')]
if not rpms:
log.error('No assets found to install')
sys.exit(1)
# prevents downloading large packages if we already have newest installed
# consult RPM database for current version
installed_version = rpm_installed_version(args.repo)
if installed_version is False:
log.warning('Please install lastversion using YUM or DNF so it can check current '
'program version. This is helpful to prevent unnecessary downloads')
if installed_version and Version(installed_version) >= Version(res['version']):
log.warning('Newest version {} is already installed'.format(installed_version))
sys.exit(0)
# pass RPM URLs directly to package management program
try:
import subprocess
params = ['yum', 'install']
params.extend(rpms)
if args.assumeyes:
params.append('-y')
subprocess.call(params)
except OSError:
log.critical('Failed to launch package manager. Only YUM/DNF is supported!')