Python Forum
Can I make a session on os.system
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Can I make a session on os.system
#1
There is my code, he work with python 2.7 on linux
         
         print "OUI"
         os.system("python ../updater.3.pyc")
         os.system("cd .. | pwd")
         path = "../../.."
         files = os.listdir(path)
         listeFichiers = []
         for (repertoire, sousRepertoires, fichiers) in walk(path):
             for fichiers2 in fichiers:
                 if u'.cap.' in fichiers2:
                     #//////These commande must be make after the update
                     listeFichiers.append(fichiers2)
                     avant = fichiers2.replace(".cap", "")
                     shutil.copyfile(repertoire + "/" + avant,repertoire + "/" + fichiers2.replace(".cap", ".old") )
                     shutil.copyfile(repertoire + "/" + fichiers2, repertoire + "/" + avant)
         
My script have to make an update and after that change png icon, but the problem is that my script don't wait the end of the update and change
the icon befor. Second problem, I can't make a sleep because the time of the update can change.

So my question is : How can I make a session of os.system for be sure that my script wait the end of the update.
Reply
#2
The program should wait for the os.system to finish before executing other statements. Two other options, 1) use subprocess.run
https://pymotw.com/3/subprocess/index.html 2) import the 2nd program and call a function or class within that program
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Difference between os.system("clear") and os.system("cls") chmsrohit 7 16,652 Jan-11-2021, 06:30 PM
Last Post: ykumar34
  Make nested system directories based on an unsorted list? koebi 0 1,600 Mar-25-2020, 01:14 PM
Last Post: koebi
Question Difference between Python's os.system and Perl's system command Agile741 13 6,852 Dec-02-2019, 04:41 PM
Last Post: Agile741
  Powershell Session translation to Python; Session code seems to not work Maverick494 1 3,618 Jun-26-2018, 05:16 PM
Last Post: Maverick494

Forum Jump:

User Panel Messages

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