diff --git a/agkyra/agkyra/config.py b/agkyra/agkyra/config.py index d44e2ea45bccbf2c7b61683063154f83590da019..9c9f95624b8e87ad43aa57a47d6de2eafd80669d 100644 --- a/agkyra/agkyra/config.py +++ b/agkyra/agkyra/config.py @@ -38,8 +38,19 @@ from kamaki.cli.utils import escape_ctrl_chars CLOUD_PREFIX = config.CLOUD_PREFIX config.HEADER = '# Agkyra configuration file version XXX\n' -AGKYRA_DIR = os.environ.get('AGKYRA_DIR', os.path.expanduser('~/.agkyra')) -CONFIG_PATH = '%s%sconfig.rc' % (AGKYRA_DIR, os.path.sep) + +HOME_DIR = os.path.expanduser('~') +DEFAULT_AGKYRA_DIR = os.path.join(HOME_DIR, ".agkyra") +AGKYRA_DIR = os.environ.get('AGKYRA_DIR', DEFAULT_AGKYRA_DIR) +AGKYRA_DIR = os.path.abspath(AGKYRA_DIR) + +if os.path.exists(AGKYRA_DIR): + if not os.path.isdir(AGKYRA_DIR): + raise Exception("Cannot create dir '%s'; file exists" % AGKYRA_DIR) +else: + os.mkdir(AGKYRA_DIR) + +CONFIG_PATH = os.path.join(AGKYRA_DIR, 'config.rc') config.CONFIG_PATH = CONFIG_PATH # neutralize kamaki CONFIG_ENV for this session config.CONFIG_ENV = '' diff --git a/agkyra/agkyra/protocol.py b/agkyra/agkyra/protocol.py index a6a82736e828234c1641d651b9c95e5c22d0aa94..7c579fb18ae5e7e4fa18343ebf3e6184780a4b1d 100644 --- a/agkyra/agkyra/protocol.py +++ b/agkyra/agkyra/protocol.py @@ -19,7 +19,7 @@ import logging from os.path import abspath from agkyra.syncer import ( syncer, setup, pithos_client, localfs_client, messaging) -from agkyra.config import AgkyraConfig +from agkyra.config import AgkyraConfig, AGKYRA_DIR LOG = logging.getLogger(__name__) @@ -209,6 +209,7 @@ class WebSocketProtocol(WebSocket): sync, self.settings['url'], self.settings['token'], self.settings['container'], self.settings['directory'], + agkyra_path=AGKYRA_DIR, ignore_ssl=True) master = pithos_client.PithosFileClient(syncer_settings) slave = localfs_client.LocalfsFileClient(syncer_settings) diff --git a/agkyra/agkyra/syncer/setup.py b/agkyra/agkyra/syncer/setup.py index e5b9300e369564093e1d116cbedec53deb66099b..743c78c44a49d4bb3cc5b35c45155d43e4a91dab 100644 --- a/agkyra/agkyra/syncer/setup.py +++ b/agkyra/agkyra/syncer/setup.py @@ -56,9 +56,11 @@ class SyncerSettings(): self.endpoint = self._get_pithos_client( auth_url, auth_token, container) - self.home_dir = os.path.expanduser('~') - self.settings_path = join_path(self.home_dir, GLOBAL_SETTINGS_NAME) + home_dir = os.path.expanduser('~') + default_settings_path = join_path(home_dir, GLOBAL_SETTINGS_NAME) + self.settings_path = kwargs.get("agkyra_path", default_settings_path) self.create_dir(self.settings_path) + self.instance_path = join_path(self.settings_path, instance) self.create_dir(self.instance_path) @@ -69,7 +71,7 @@ class SyncerSettings(): self.local_root_path = local_root_path self.create_dir(self.local_root_path) - self.cache_name = kwargs.get("cache_path", DEFAULT_CACHE_NAME) + self.cache_name = kwargs.get("cache_name", DEFAULT_CACHE_NAME) self.cache_path = join_path(self.local_root_path, self.cache_name) self.create_dir(self.cache_path) diff --git a/agkyra/launch b/agkyra/launch index f9813a2c32791b7b62990947bd51a723d275f813..a2e3940afe51f84321bd53bfd0f9ca6e37d785a9 100755 --- a/agkyra/launch +++ b/agkyra/launch @@ -16,10 +16,12 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import os -CURPATH = os.path.dirname(os.path.abspath(__file__)) + +from agkyra import config +AGKYRA_DIR = config.AGKYRA_DIR import logging -logfile = os.path.join(CURPATH, 'agkyra.log') +logfile = os.path.join(AGKYRA_DIR, 'agkyra.log') logger = logging.getLogger('agkyra') handler = logging.FileHandler(logfile) formatter = logging.Formatter("%(levelname)s:%(asctime)s:%(message)s")