klintkrossa
Posts: 81
Joined: Tue Nov 10, 2015 3:06 pm

More os questions

Fri Feb 24, 2017 5:40 pm

Hello All,
I would like to log some information that os.system returns.

Code: Select all

from os import system

PY_adds = ['python-setuptools', 'python-pip', 'python3-dev',
           'python3-setuptools','python-serial',
           'python3-pip','libjpeg3-dev',
           'python-numpy','python-scipy',
           'python-pandas','python3-pygame',
           'python-pygame','python-pySerial',
           'libusb-1.0-0.dev','build-essential',
           'python-dev','libjpeg-dev']

 
for X in PY_adds:
    print(X)
    print('')
    system("sudo apt-get -y install %s" % X)

if I am just using python3 then it returns:
libjpeg3-dev

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package libjpeg3-dev
25600


Normally os.system returns 0, I would like to grab the "X" if os.system returns 25600 and log what is not loading.

Is that an error code and if I used?
try:
def ....

except 25600:
do somthing
Thanks
This is not like any other bulletin boards that I have been on. Been flamed on other BB's so bad I was afraid to ask.

All my Raspberry Pi's are like the Hessian artilleryman of Sleepy Hollow.

User avatar
paddyg
Posts: 2541
Joined: Sat Jan 28, 2012 11:57 am
Location: UK

Re: More os questions

Fri Feb 24, 2017 5:59 pm

can you not just do something like this?

Code: Select all

...
      res = system("sudo apt-get -y install {}".format(X))
      if res == 25600:
...
      elif res == 32512:
also https://groups.google.com/forum/?hl=en-GB&fromgroups=#!forum/pi3d

klintkrossa
Posts: 81
Joined: Tue Nov 10, 2015 3:06 pm

Re: More os questions

Fri Feb 24, 2017 6:45 pm

paddyg wrote:can you not just do something like this?

Code: Select all

...
      res = system("sudo apt-get -y install {}".format(X))
      if res == 25600:
...
      elif res == 32512:
Thanks yes that will do it
Thanks
This is not like any other bulletin boards that I have been on. Been flamed on other BB's so bad I was afraid to ask.

All my Raspberry Pi's are like the Hessian artilleryman of Sleepy Hollow.

Return to “Python”