How to update the system using python script?

I’m at the beginning of my journey but I believe (it’s probably hope not a faith) that something like system update should be quite easy.

After a little research I’ve found that I can to it this way:

#!/usr/bin/python

from subprocess import call
call(['sudo','pacman','-Syyu'])

Is this the proper way in terms of Manjaro maintenance?
Is there better/another way?
I know that I could create an alias but I want to learn how to integrate python with the system

I’ve found something about os.system but in python docs there is an information about subprocess:

This module intends to replace several older modules and functions:

os.system
os.spawn*

p.s.
system update is just an example.
Is subprocess and call the way to have an interaction between system and python?

This is probably a good overview:

But yours looks about right for a simply single action.

1 Like

not for interaction :wink: for real interaction (for update) is possible to use python lib as pyalpm or the Pamac python bindings
here, is really interactive: we can pass callback functions to update

sometimes, we can also use dbus …

1 Like

There are tons of similar tools out there… pacui (although not python) might provide you with a decent guide. See: GitHub - excalibur1234/pacui: Bash script providing advanced Pacman and Yay/Pikaur/Aurman/Pakku/Trizen/Pacaur/Pamac-cli functionality in a simple UI

1 Like

Currently I know how to define variables and create simple functions but I’ll check in the furure :slight_smile:

I’m aware
I just wanted to do something else. Not only print World welcome messages :smiley:
Maybe in the future I’ll be able to develop for linux community. Especially for Manjaro of course :slight_smile:

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.