install rpm or msi file through python script

0 votes

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' # packaged using golang

platformName = platform.system()
s3 = boto3.resource('s3')

print(platformName)

if platformName == 'Linux':
    try:
        bucket = s3.Bucket(BUCKET_NAME)
        bucket.download_file(KEY, 'temp.rpm')
    except botocore.exceptions.ClientError as e:
        if e.response['Error']['Code'] == "404":
            print("The object does not exist.")
        else:
            raise
else:
    print("not valid operating system")

I want to add a script in the same file to install the downloaded rpm file or msi package for windows. I tried searching online but didn't get any information. Would appreciate if anyone provide some pointers.

Thanks!

Sep 18, 2018 in AWS by bug_seeker
• 15,510 points
2,759 views

1 answer to this question.

0 votes

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")
answered Sep 18, 2018 by Priyaj
• 58,020 points

Related Questions In AWS

0 votes
1 answer

How can I install curl 7.34 or later on Amazon linux old instance

add a new text file called /etc/yum.repos.d/city-fan.repo ...READ MORE

answered Aug 9, 2018 in AWS by Priyaj
• 58,020 points
7,537 views
0 votes
1 answer

Boto3 - python script to view all directories and files

There are no folders, only S3 object ...READ MORE

answered Sep 14, 2018 in AWS by Priyaj
• 58,020 points
41,446 views
0 votes
1 answer

Boto3 - python script to view all directories and files

There are no folders, only S3 object ...READ MORE

answered Sep 17, 2018 in AWS by Priyaj
• 58,020 points
3,132 views
0 votes
1 answer

Import my AWS credentials using python script

Using AWS Cli  Configure your IAM user then ...READ MORE

answered Nov 16, 2018 in AWS by Jino
• 5,820 points
2,869 views
0 votes
1 answer
0 votes
1 answer
+1 vote
2 answers

How do I run python script on aws EC2 instance(ubuntu)?

I believe that you are using the ...READ MORE

answered Apr 17, 2018 in AWS by Cloud gunner
• 4,670 points
10,330 views
+1 vote
2 answers

How to install Python MySQLdb module using pip?

It's easy to do, but hard to ...READ MORE

answered Aug 1, 2018 in AWS by Priyaj
• 58,020 points
5,738 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP