Python Forum

Full Version: Avoid FreeFileSync from being launch while it has previous popups openned
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For those familiered with FreeFileSync, know that there is another feature called RealTimeSync(RTS), who simply doesnt work at least in my MacOS, so I start making my own "RealTimeSync" but seems like I am not able to control FreeFileSync launchs when a popup is launched, after the sleep time it continues popuping up and doesnt wait for a click on this first popup. I have also tried to use my own warnings instead of FreeFileSync(FFS) popups but I cannot rely on that.

For default those batchs from FFS and RTS, I can only launch those directly with 'open' command, since both have extended attributes.

So do you have a way to show it one at a time? Huh

This is the code that I am using right now, for testing:

import os
import sys
import subprocess
import time

####EDIT HERE####
ffs_batch_folder_path = '/Users/admin/Desktop/AOI-A/RTS_Config/'
ffs_batch_file = 'BatchRun_aoi2.ffs_batch'
nas_folder_path = 'Download'
#################

sleep_period = 60 #in seconds
first_launch_sleep_period = 30 #in seconds

def run_ffs_batch():
    #give some time to connect remote folder where it will sync
    time.sleep(first_launch_sleep_period)
    #starts periodic function
    while(1):
        print ('%s' %output)
        if os.path.exists('/Volumes/%s' %nas_folder_path):
            if os.path.exists('%s' %ffs_batch_folder_path):
                if len(output)>400:
                    print ('Connected from remote folder')
                    try:
                        #run batch file
                        subprocess.check_output(['open', "%s" %ffs_batch_file], cwd=ffs_batch_folder_path)
                    except subprocess.CalledProcessError as e:
                        print ('Unable to sync, check batch file name and location: \n%s' %e)
                else:
                    break
                    ap = """ display dialog "Remote folder not accessible, please contact your system administrator!" with title "Warning from Remote Folder!" with icon caution buttons {"OK"} """
                    subprocess.call("osascript -e '{}'".format(ap),shell=True)
                    print ('Remote folder not accessible!')
            else:
                ap = """ display dialog "Localhost folder not accessible, please contact your system administrator!" with title "Warning from Localhost Folder!" with icon caution buttons {"OK"} """
                subprocess.call("osascript -e '{}'".format(ap),shell=True)
                print ('Localhost folder not accessible!')
        else:
            ap = """ display dialog "Remote folder not mounted, please contact your system administrator!" with title "Warning from Remote Folder!" with icon caution buttons {"OK"} """
            subprocess.call("osascript -e '{}'".format(ap),shell=True)
            print ('Remote folder not mounted!')
        #sync period of time
        time.sleep(sleep_period)
 
if __name__=="__main__":
    run_ffs_batch()
I avoid those popups by removing those through FreeFileSync GUI, and also I made a search to see if FreeFileSync was still being used through PID to avoid this app to be openned again,while the other one was running, and creating a stack of FreeFileSync processes.