Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
agkyra
Commits
8702d692
Commit
8702d692
authored
May 14, 2015
by
Giorgos Korfiatis
Browse files
determine instance id
parent
b277f39f
Changes
4
Hide whitespace changes
Inline
Side-by-side
agkyra/protocol.py
View file @
8702d692
...
...
@@ -314,7 +314,6 @@ class WebSocketProtocol(WebSocket):
pass
syncer_settings
=
setup
.
SyncerSettings
(
sync
,
self
.
settings
[
'url'
],
self
.
settings
[
'token'
],
self
.
settings
[
'container'
],
self
.
settings
[
'directory'
],
**
kwargs
)
...
...
agkyra/syncer/setup.py
View file @
8702d692
...
...
@@ -20,6 +20,7 @@ import logging
from
agkyra.syncer.utils
import
join_path
,
ThreadSafeDict
from
agkyra.syncer.database
import
SqliteFileStateDB
from
agkyra.syncer.messaging
import
Messager
from
agkyra.syncer
import
utils
from
kamaki.clients
import
ClientError
...
...
@@ -39,17 +40,22 @@ DEFAULT_DBNAME = "syncer.db"
DEFAULT_ACTION_MAX_WAIT
=
10
DEFAULT_PITHOS_LIST_INTERVAL
=
5
DEFAULT_CONNECTION_RETRY_LIMIT
=
3
INSTANCES_NAME
=
'instances'
thread_local_data
=
threading
.
local
()
def
get_instance
(
elems
):
data
=
""
.
join
(
elems
)
return
utils
.
hash_string
(
data
)
class
SyncerSettings
():
def
__init__
(
self
,
instance
,
auth_url
,
auth_token
,
container
,
local_root_path
,
def
__init__
(
self
,
auth_url
,
auth_token
,
container
,
local_root_path
,
*
args
,
**
kwargs
):
self
.
auth_url
=
auth_url
self
.
auth_url
=
utils
.
normalize_standard_suffix
(
auth_url
)
self
.
auth_token
=
auth_token
self
.
container
=
container
self
.
container
=
utils
.
normalize_standard_suffix
(
container
)
self
.
ignore_ssl
=
kwargs
.
get
(
"ignore_ssl"
,
False
)
if
self
.
ignore_ssl
:
...
...
@@ -65,16 +71,23 @@ class SyncerSettings():
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
.
instances_path
=
join_path
(
self
.
settings_path
,
INSTANCES_NAME
)
self
.
create_dir
(
self
.
instances_path
)
self
.
local_root_path
=
utils
.
normalize_local_suffix
(
local_root_path
)
self
.
create_dir
(
self
.
local_root_path
)
self
.
user_id
=
self
.
endpoint
.
account
self
.
instance
=
get_instance
(
[
self
.
auth_url
,
self
.
user_id
,
self
.
container
,
self
.
local_root_path
])
self
.
instance_path
=
join_path
(
self
.
instances_path
,
self
.
instance
)
self
.
create_dir
(
self
.
instance_path
)
self
.
dbname
=
kwargs
.
get
(
"dbname"
,
DEFAULT_DBNAME
)
self
.
full_dbname
=
join_path
(
self
.
instance_path
,
self
.
dbname
)
self
.
get_db
(
initialize
=
True
)
self
.
local_root_path
=
local_root_path
self
.
create_dir
(
self
.
local_root_path
)
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
)
...
...
agkyra/syncer/syncer.py
View file @
8702d692
...
...
@@ -406,9 +406,8 @@ class FileSyncer(object):
# deleted = master_deleted.intersection(client_deleted)
def
conf
(
instance
,
auth_url
,
auth_token
,
container
,
local_root_path
,
**
kwargs
):
settings
=
SyncerSettings
(
instance
=
instance
,
auth_url
=
auth_url
,
def
conf
(
auth_url
,
auth_token
,
container
,
local_root_path
,
**
kwargs
):
settings
=
SyncerSettings
(
auth_url
=
auth_url
,
auth_token
=
auth_token
,
container
=
container
,
local_root_path
=
local_root_path
,
...
...
agkyra/syncer/utils.py
View file @
8702d692
...
...
@@ -42,6 +42,14 @@ def join_objname(prefix, filename):
return
prefix
+
filename
def
normalize_standard_suffix
(
path
):
return
path
.
rstrip
(
OBJECT_DIRSEP
)
+
OBJECT_DIRSEP
def
normalize_local_suffix
(
path
):
return
path
.
rstrip
(
os
.
path
.
sep
)
+
os
.
path
.
sep
def
hash_string
(
s
):
return
hashlib
.
sha256
(
s
).
hexdigest
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment