X-Git-Url: https://v.licheni.net/stack/code/dboxswitch.git/blobdiff_plain/bf8352cb84782e000f2b7b831df5a9053d853548..45988c8bde46e2e882825620c2809b7b844f634b:/dboxswitch/profhandler.py diff --git a/dboxswitch/profhandler.py b/dboxswitch/profhandler.py index f2be538..a17b57a 100644 --- a/dboxswitch/profhandler.py +++ b/dboxswitch/profhandler.py @@ -140,9 +140,10 @@ class ProfHandler(): self.stopDropbox() try: if pl in ('Linux','Darwin'): - if os.path.exists(self.getDropboxDirectory()): - os.unlink(self.getDropboxDirectory()) - os.symlink(ppath, self.getDropboxDirectory()) + dbdir = self.getDropboxDirectory() + if os.path.exists(dbdir): + os.unlink(dbdir) + os.symlink(ppath, dbdir) else: raise NotImplementedError, "Not implemented yet." except IOError as e: @@ -159,7 +160,11 @@ class ProfHandler(): def getDropboxDirectory(self): pl = platform.system() if pl in ('Linux', 'Darwin'): - return os.path.join(os.path.expanduser('~'),".dropbox") + basepath = os.path.join(os.path.expanduser("~"), ".dropbox") + for path in [os.path.join(basepath, "instance1"), basepath]: + if os.path.exists(path) and os.path.islink(path): + return path + raise NotImplementedError("Path not found " + basepath + "[instance1]") elif pl == 'Windows': assert os.environ.has_key('APPDATA'), Exception('APPDATA env variable not found') return os.path.join(os.environ['APPDATA'],'Dropbox')