Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for sync.com #1762

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion mackup/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
ENGINE_GDRIVE,
ENGINE_COPY,
ENGINE_ICLOUD,
ENGINE_SYNC,
ENGINE_FS,
)

Expand All @@ -20,6 +21,7 @@
get_copy_folder_location,
get_google_drive_folder_location,
get_icloud_folder_location,
get_sync_folder_location,
)

try:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand All @@ -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")
Expand Down
1 change: 1 addition & 0 deletions mackup/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
16 changes: 16 additions & 0 deletions mackup/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down
21 changes: 21 additions & 0 deletions tests/config_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
ENGINE_GDRIVE,
ENGINE_COPY,
ENGINE_ICLOUD,
ENGINE_SYNC,
ENGINE_FS,
)
from mackup.config import Config, ConfigError
Expand Down Expand Up @@ -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")
Expand Down