import os
import glob
import threading
class push:
def start(self):
self.main()
def main(self):
alllist = glob.glob("*")
dirlist = filter(os.path.isdir, alllist)
for path in dirlist:
self.pull(path)
threading.Timer(self.main, 10000)
def pull(self, path):
os.chdir(path)
os.popen("git push")
return
pushInstance = push()
pushInstance.start()
The result of execution is that the loop ends in the first directory and I don"t get the result I want to execute the Push command in each directory. New to python
Update:
has found out the problem. Return to
manually after changing directories.import os
import glob
import threading
class push:
def start(self):
self.main()
def main(self):
alllist = glob.glob("*")
dirlist = filter(os.path.isdir, alllist)
for path in dirlist:
print(path)
self.pull(path)
threading.Timer(self.main, 10000)
def pull(self, path):
os.chdir(path)
os.system("git push")
os.chdir("..")
pushInstance = push()
pushInstance.start()
but I still don"t understand why the change to the working directory will cause the whole loop to break?