![]() |
Can I make a session on os.system - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Can I make a session on os.system (/thread-18201.html) |
Can I make a session on os.system - Serferi - May-09-2019 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. RE: Can I make a session on os.system - woooee - May-09-2019 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 |