1

I'm writing a python script that needs to act upon a change in dropbox. I have this:

        UsersFile2 = "/home/pi/Dropbox-Uploader/dropbox_uploader.sh monitor /Lancaster"
       
        call([UsersFile2], shell=True)

which successfully monitors it and then tell me in the command line that a file has changed, but how can I act upon this, the code just keeps checking for updates........... i think its more my understanding of python rather than dropbox

        UsersFile2 = "/home/pi/Dropbox-Uploader/dropbox_uploader.sh monitor /Lancaster"

        
        call([UsersFile2], shell=True)
            
        
        UsersFile = "/home/pi/Dropbox-Uploader/dropbox_uploader.sh download /Lancaster/Updater.txt"
        call([UsersFile], shell=True)

        fileObject = open("Updater.txt", "r")
    
        data = fileObject.read()
        data_into_list = data.split(",")
        ProblemName = data_into_list[0]
        Mirroring = int(data_into_list[1])


        
        if Mirroring == 1:
            MirrorProblem = True
        else:
            MirrorProblem = False
            
        if  ProblemName != OldProblemName:
            OldProblemName = ProblemName
            SearchingByProblemName.Searching_By_Problem_Name(ProblemName,holds_list,original_holds_list,MirrorProblem,MirrorDic)

        elif OldMirror != MirrorProblem:
            
            OldMirror = MirrorProblem
            SearchingByProblemName.Searching_By_Problem_Name(ProblemName,holds_list,original_holds_list,MirrorProblem,MirrorDic)
        else:
            pass

is the rest of the script, so once the Lancaster folder has changed I then want to read Updater.txt and go on

I've read lots of documents, I can keep downloading the document but thats not a great use of time

  • Does you Python code stop executing at line 2? Does the shell script work well on its own? what does the shell script do, does it also halt and until something changes and then print to the console? You may find this helpful although it will not directly answer your issue: https://stackoverflow.com/questions/89228/how-do-i-execute-a-program-or-call-a-system-command – Mark Jan 25 '23 at 12:43
  • yes it stops at line 2 but it is monitoring the folder and when a file changes it prints in concole update.txt which is the file thats changed, the program goes back to monitoring the folder for ever until i kill it. I want it then to run the rest of the code, which all work beautifully – GrifferScott Jan 26 '23 at 09:15

0 Answers0