Source code for cgl.plugins.syncthing.setup

from cgl.core.utils.general import cgl_execute
import os


[docs] def install_syncthing(): """ Installs syncthing on the current machine with choco Returns: """ command = r"choco install syncthing -y" return command
[docs] def start_syncthing(): """ Launches syncthing at Returns: """ command = r"syncthing" cgl_execute(command, new_console=True)
[docs] def stop_syncthing(): """ Launches syncthing at Returns: """ command = r"syncthing -no-browser -no-restart" cgl_execute(command, new_console=True)
[docs] def launch_syncthing_gui(url="http://localhost:8384"): """ Launches syncthing on the current machine Returns: """ command = f"start {url}" cgl_execute(command, new_console=True)
[docs] def edit_syncthing_folder_path(): """ Edits the syncthing folder path Returns: """ LOCALAPPDATA = os.environ["LOCALAPPDATA"] syncthing_config_file = os.path.join(LOCALAPPDATA, "syncthing", "config.xml") syncthing_new_config_file = os.path.join( LOCALAPPDATA, "syncthing", "config_new.xml" ) # load the xml file from cgl.core.utils.read_write import load_xml, save_xml from cgl.core.config.query import get_last_company tree = load_xml(syncthing_config_file) # find the "folder" element in the tree dict folder_element = tree["configuration"]["folder"] new_path = os.path.join(CFG.get_prod_root(), CFG.company) folder_element["@path"] = new_path print(new_path) print(folder_element["@path"]) # write the xml file save_xml(syncthing_new_config_file, tree) print(syncthing_new_config_file)
if __name__ == "__main__": edit_syncthing_folder_path() # launch_syncthing() # install_syncthing() # print("hello