Skip to content Skip to sidebar Skip to footer

Install .rpm Or .msi File Through Python Script

I'm a newbie to python. I have a python script to download a rpm file from S3 bucket. import platform import boto3 import botocore BUCKET_NAME = 'tempdownload' KEY = 'temp.rpm' #

Solution 1:

You can install it directly from Python using rpm bindings. See: https://docs-old.fedoraproject.org/en-US/Fedora_Draft_Documentation/0.1/html/RPM_Guide/ch16s06.html

But rather, you should not call rpm directly, but rather call Yum or DNF or its python bindings.

Solution 2:

You have to call system command - rpm -Ivh yourpackage.rpm

import subprocess
package_path = '/home/mypackage.rpm'command = ['rpm', '-Ivh', package_path]
p = subprocess.Popen(command)
p.wait()
if p.returncode == 0:
    print("OK")
else:
    print("Something went wrong")

Post a Comment for "Install .rpm Or .msi File Through Python Script"