Python Forum
reading data from command line
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
reading data from command line
#1
I want to automate updating python packages through pip. I think I have most of it. I just don't know how to evaluate the output from results = os.system('pip list --outdated'). I thought putting 0 for none would be sufficient but it doesn't work. It gives me a list of outdated packages but says they are all up to date. It never runs lines 12-21. Wall
def pkg_update():
    options = ['Check for updates?', '1 Yes', '2 Exit']
    for option in options:
        print(option)
    choice = input('> ')
    if choice == '1':
        print('Checking for updates.')
        results = os.system('pip list --outdated')
        if results == 0: # What do I put here?
            print('All packages are up to date.\n')
            pkg_update()
        else:
            print(results)
            while True:
                update_list = list(results)
                current = update_list.pop(0)
                print(f'Updating {current}.')
                os.system(f'''pip install --upgrade
				             {current}''')
                print('Done')
            pkg_update()

    elif choice == '2':
        raise SystemExit

    else:
        pkg_update()


if __name__ == "__main__":
    pkg_update(
Reply


Messages In This Thread
reading data from command line - by mcmxl22 - Feb-17-2019, 08:15 PM
RE: reading data from command line - by snippsat - Feb-17-2019, 08:55 PM
RE: reading data from command line - by Axel_Erfurt - Feb-17-2019, 09:01 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading and storing a line of output from pexpect child eagerissac 1 4,354 Feb-20-2024, 05:51 AM
Last Post: ayoshittu
  Reading in of line not working? garynewport 2 905 Sep-19-2023, 02:22 PM
Last Post: snippsat
  Reading All The RAW Data Inside a PDF NBAComputerMan 4 1,430 Nov-30-2022, 10:54 PM
Last Post: Larz60+
  Command line argument issue space issue mg24 5 1,398 Oct-26-2022, 11:05 PM
Last Post: Yoriz
  Reading Data from JSON tpolim008 2 1,143 Sep-27-2022, 06:34 PM
Last Post: Larz60+
  accept command line argument mg24 5 1,397 Sep-27-2022, 05:58 PM
Last Post: snippsat
  Help reading data from serial RS485 korenron 8 14,312 Nov-14-2021, 06:49 AM
Last Post: korenron
  Help with WebSocket reading data from anoter function korenron 0 1,366 Sep-19-2021, 11:08 AM
Last Post: korenron
  Presenting multiline data into single line aaronbuhu 1 1,841 Aug-05-2021, 10:57 AM
Last Post: jamesaarr
  Accessing varying command line arguements Rakshan 3 2,105 Jul-28-2021, 03:18 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020