main : adds subcommands, move to Path and improve
Multiple changes to the main file, after this unisync becomes kind of usable. Add subcommands : this uses the 2 previous commits to add the subcommands to unisync it is now possible to sync, add and mount. pathlib : move from PosixPath to Path Remove unused imports Rename base_namespace to cli_args Add some comments and TODOs
This commit is contained in:
@@ -3,24 +3,29 @@
|
||||
|
||||
import os
|
||||
from argparser import create_argparser
|
||||
from config import RootsConfig, ServerConfig, Config, load_config
|
||||
from runners import unisync_sync, unisync_add, unisync_mount
|
||||
from config import load_config
|
||||
from synchroniser import Synchroniser
|
||||
from pathlib import Path, PosixPath
|
||||
from pathlib import Path
|
||||
from paths import *
|
||||
|
||||
def main():
|
||||
parser = create_argparser()
|
||||
base_namespace = parser.parse_args()
|
||||
parser = create_argparser(unisync_sync, unisync_add, unisync_mount)
|
||||
cli_args = parser.parse_args()
|
||||
|
||||
config_path = os.path.expanduser("~/.config/unisync/config.ini")
|
||||
if base_namespace.config != None and os.path.isfile(base_namespace.config):
|
||||
config = load_config(base_namespace.config)
|
||||
# Check if --config is set
|
||||
if cli_args.config != None and os.path.isfile(cli_args.config):
|
||||
config = load_config(cli_args.config)
|
||||
elif os.path.isfile(config_path):
|
||||
config = load_config(config_path)
|
||||
else:
|
||||
# TODO make the command line arguments work and override the config options
|
||||
# TODO replace the next line with something to do if no config file is found
|
||||
config = load_config(config_path)
|
||||
pass
|
||||
|
||||
# TODO make the command line arguments work and override the config options
|
||||
|
||||
synchroniser = Synchroniser(
|
||||
config.roots.remote,
|
||||
config.roots.local,
|
||||
@@ -33,18 +38,7 @@ def main():
|
||||
|
||||
paths_manager = PathsManager(Path(config.roots.local), config.other.cache_dir_path)
|
||||
|
||||
if synchroniser.create_ssh_master_connection() != 0:
|
||||
print("Connection failed quitting")
|
||||
return 1
|
||||
print("Connected to the remote.")
|
||||
|
||||
#synchroniser.sync_files()
|
||||
#synchroniser.update_links(background=False)
|
||||
#synchroniser.mount_remote_dir()
|
||||
|
||||
synchroniser.close_ssh_master_connection()
|
||||
print(paths_manager.get_paths_to_sync())
|
||||
|
||||
cli_args.func(synchroniser, paths_manager)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user