#!/usr/bin/python from shutil import copyfile import os, sys, subprocess, time spark_profile = \ '''\ root = $SOURCE root = socket://localhost:8080/$TARGET ignore = Path build ignore = Path .git ignore = Path cmake-build-debug ignore = Path .vscode ignore = Path .cquery_cached_index ignore = Path .idea ignore = Path src/web ignore = Path docker ignore = Regex .*\.pyc ignore = Path x64 ignore = Path .vs prefer = $SOURCE #repeat = watch batch = true ''' this_path = os.path.realpath(__file__) repo_root = os.path.abspath(os.path.dirname(this_path)) repo_root = os.path.join(repo_root,os.pardir) repo_root = os.path.join(repo_root,os.pardir) repo_root = os.path.abspath(repo_root) repo_name = os.path.basename(repo_root) profile_loc = os.path.join(os.path.abspath(os.environ['HOME']),'.unison') spark_profile = spark_profile.replace("$SOURCE", repo_root) spark_profile = spark_profile.replace("$TARGET", repo_name) unison_exe = os.path.join(repo_root,"externals","linux","bin","unison") if not os.path.exists(profile_loc): os.mkdir(profile_loc) with open(os.path.join(profile_loc,repo_name), "w") as text_file: text_file.write(spark_profile) #while True: subprocess.call((unison_exe,repo_name)) #time.sleep(10)