Files
spark/tools/replicator/replicate_to_linux_vm.py
T

57 lines
1.7 KiB
Python

from shutil import copyfile
import os, sys, subprocess, time
spark_profile = \
'''\
root = $SOURCE
root = socket://sparkvm:$PORT/$TARGET
ignore = Path build
ignore = Path .git
ignore = Path externals
ignore = Path docker
ignore = Regex .*\.pyc
ignore = Path x64
ignore = Path .vs
ignore = Path src/.vs
ignore = Path src/lib/.vs
ignore = Path src/lib/out
ignore = Path src/sdk/out
ignore = Path src/server/sparkd/out
ignore = Path src/web/out
ignore = Path .vscode
ignore = Path src/client
ignore = Path src/web/api/node_modules
ignore = Path src/web/ui/node_modules
ignore = Path src/web/ui/src/obj
force = $SOURCE
batch = true
confirmbigdel = false
ignorearchives = 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['USERPROFILE']),'.unison')
spark_profile = spark_profile.replace("$SOURCE", repo_root)
spark_profile = spark_profile.replace("$TARGET", "spark")
spark_profile = spark_profile.replace("$PORT", os.getenv("SPARKVM_UNISON_PORT", "8080"))
unison_exe = os.path.join(repo_root,"externals","windows","bin","unison.exe")
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)