diff --git a/CHANGELOG.md b/CHANGELOG.md index f8c9f11be..6875a4883 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## WIP +- Added support for Sync.com as a new storage (via @JasonMFry) - Added support for KeePassXC (via @harens) - Fixed support for poetry (via @ameyuuno) - Added support for npm package npmrc (via @jdvivar) @@ -471,7 +472,7 @@ - Added support of WebStorm 10 (via @morphinewan) - Added support of Gnome SSH Tunnel Manager (via @skyrocknroll) - Added support for Hammerspoon (via @jkaan) -- Added support for Bitchx (via @troywilson_) +- Added support for Bitchx (via @troywilson\_) - Added support for EditorConfig (via @chadluo) - Add com.agilebits.onepassword4.plist in 1Password (via @amatos) - Added support for Versions (via @amatos) @@ -781,7 +782,7 @@ - Added support for Ack (via @adamlogic) - Added support for Stata and SelfControl (via @kfinlay) - Added support for LaTeXiT (via @twsh) -- Do not link ~/Library/* files on GNU/Linux, should fix #104 +- Do not link ~/Library/\* files on GNU/Linux, should fix #104 ## Mackup 0.5 diff --git a/mackup/config.py b/mackup/config.py index 373bef984..3e0101055 100644 --- a/mackup/config.py +++ b/mackup/config.py @@ -11,6 +11,7 @@ ENGINE_GDRIVE, ENGINE_COPY, ENGINE_ICLOUD, + ENGINE_SYNC, ENGINE_FS, ) @@ -20,6 +21,7 @@ get_copy_folder_location, get_google_drive_folder_location, get_icloud_folder_location, + get_sync_folder_location, ) try: @@ -68,7 +70,7 @@ def engine(self): """ The engine used by the storage. - ENGINE_DROPBOX, ENGINE_GDRIVE, ENGINE_COPY, ENGINE_ICLOUD or ENGINE_FS. + ENGINE_DROPBOX, ENGINE_GDRIVE, ENGINE_COPY, ENGINE_ICLOUD, ENGINE_SYNC, or ENGINE_FS. Returns: str @@ -191,6 +193,7 @@ def _parse_engine(self): ENGINE_GDRIVE, ENGINE_COPY, ENGINE_ICLOUD, + ENGINE_SYNC, ENGINE_FS, ]: raise ConfigError("Unknown storage engine: {}".format(engine)) @@ -212,6 +215,8 @@ def _parse_path(self): path = get_copy_folder_location() elif self.engine == ENGINE_ICLOUD: path = get_icloud_folder_location() + elif self.engine == ENGINE_SYNC: + path = get_sync_folder_location() elif self.engine == ENGINE_FS: if self._parser.has_option("storage", "path"): cfg_path = self._parser.get("storage", "path") diff --git a/mackup/constants.py b/mackup/constants.py index 708cc63fc..6c6a139ac 100644 --- a/mackup/constants.py +++ b/mackup/constants.py @@ -27,6 +27,7 @@ ENGINE_FS = "file_system" ENGINE_GDRIVE = "google_drive" ENGINE_ICLOUD = "icloud" +ENGINE_SYNC = "sync.com" DOCUMENTATION_URL = "https://github.com/lra/mackup/blob/master/doc/README.md" diff --git a/mackup/utils.py b/mackup/utils.py index 29775253d..ab73f04b9 100644 --- a/mackup/utils.py +++ b/mackup/utils.py @@ -297,6 +297,22 @@ def get_icloud_folder_location(): return str(icloud_home) +def get_sync_folder_location(): + """ + Try to locate the Sync.com folder. It defaults to ~/Sync but the user can + change it. + + Returns: + (str) Full path to the Sync.com folder. + """ + default_path = "~/Sync" + + default_home = os.path.expanduser(default_path) + + if not os.path.isdir(default_home): + error(constants.ERROR_UNABLE_TO_FIND_STORAGE.format(provider="Sync.com")) + + return str(default_home) def is_process_running(process_name): """ diff --git a/tests/config_tests.py b/tests/config_tests.py index 6f5bab59d..c0b8632f6 100644 --- a/tests/config_tests.py +++ b/tests/config_tests.py @@ -6,6 +6,7 @@ ENGINE_GDRIVE, ENGINE_COPY, ENGINE_ICLOUD, + ENGINE_SYNC, ENGINE_FS, ) from mackup.config import Config, ConfigError @@ -168,6 +169,26 @@ def test_config_engine_icloud(self): assert cfg.apps_to_ignore == set(["subversion", "sequel-pro", "sabnzbd"]) assert cfg.apps_to_sync == set(["sublime-text-3", "x11", "sabnzbd"]) + def test_config_engine_sync(self): + cfg = Config("mackup-engine-sync.cfg") + + assert isinstance(cfg.engine, str) + assert cfg.engine == ENGINE_SYNC + + assert isinstance(cfg.path, str) + assert cfg.path == os.path.expanduser("~/Sync") + + assert isinstance(cfg.directory, str) + assert cfg.directory == u"Mackup" + + assert isinstance(cfg.fullpath, str) + assert cfg.fullpath == os.path.join( + os.environ[u"HOME"], u"sync", u"Mackup" + ) + + assert cfg.apps_to_ignore == set(["subversion", "sequel-pro", "sabnzbd"]) + assert cfg.apps_to_sync == set(["sublime-text-3", "x11", "sabnzbd"]) + def test_config_engine_filesystem_no_path(self): with self.assertRaises(ConfigError): Config("mackup-engine-file_system-no_path.cfg")