diff --git a/agkyra/cli.py b/agkyra/cli.py index 07cec6a84a7d603280cce445c7bda337ca38cfc4..80b1f06a8fbd1e47520f6759cd2474c8c796ad18 100644 --- a/agkyra/cli.py +++ b/agkyra/cli.py @@ -21,20 +21,7 @@ from agkyra import config, protocol, protocol_client LOG = logging.getLogger(__name__) STATUS = protocol.STATUS -NOTIFICATION = { - 0: 'Not initialized', - 1: 'Initializing ...', - 2: 'Shutting down', - 100: 'Syncing', - 101: 'Pausing', - 102: 'Paused', - 200: 'Settings are incomplete', - 201: 'Cloud URL error', - 202: 'Authentication error', - 203: 'Local directory error', - 204: 'Remote container error', - 1000: 'Critical error' -} +NOTIFICATION = protocol.COMMON['NOTIFICATION'] remaining = lambda st: st['unsynced'] - (st['synced'] + st['failed']) diff --git a/agkyra/nwgui/notify.js b/agkyra/nwgui/notify.js index 2a54fd88b958f3cb7c41e26ca4b1837500f8bc09..97b08d9cbd2423ec40789db97abf792592f6c8d3 100644 --- a/agkyra/nwgui/notify.js +++ b/agkyra/nwgui/notify.js @@ -1,20 +1,5 @@ var gui = require('nw.gui'); -var NOTIFICATION = { - 0: 'Not initialized', - 1: 'Initializing ...', - 2: 'Shutting down', - 100: 'Syncing', - 101: 'Pausing', - 102: 'Paused', - 200: 'Settings are incomplete', - 201: 'Cloud URL error', - 202: 'Authentication error', - 203: 'Local directory error', - 204: 'Remote container error', - 1000: 'error error' -} - function is_up(code) { return (code / 100 >> 0) === 1; } function has_settings_error(code) { return (code / 200 >> 0) === 2; } function remaining(status) { diff --git a/agkyra/nwgui/protocol.js b/agkyra/nwgui/protocol.js index 2e8d4fcdccb7a6fc5a3dc120bf7dd710b560fd0e..b3257b2f8c04a034410dfc99f6be0e6074b59fcf 100644 --- a/agkyra/nwgui/protocol.js +++ b/agkyra/nwgui/protocol.js @@ -21,7 +21,10 @@ var fs = require('fs'); // Read config file var cnf = JSON.parse(fs.readFileSync(gui.App.argv[0], encoding='utf-8')); -var UI_COMMON = JSON.parse(fs.readFileSync(path.join('..', 'ui_common.json'))); +var COMMON = JSON.parse(fs.readFileSync(path.join('..', 'ui_data/common.json'))); + +var STATUS = COMMON['STATUS']; +var NOTIFICATION = COMMON['NOTIFICATION']; function log_debug(msg) { if (DEBUG) console.log(msg); } @@ -29,8 +32,6 @@ function send_json(socket, msg) { socket.send(JSON.stringify(msg)); } -var STATUS = UI_COMMON['STATUS']; - var globals = { settings: { token: null, diff --git a/agkyra/protocol.py b/agkyra/protocol.py index 66dae8a06a2e67856b9596340b39354d9f4e4dc0..e9c6ee970d78a468b8ef291f95f233c7bb67ea80 100644 --- a/agkyra/protocol.py +++ b/agkyra/protocol.py @@ -34,9 +34,9 @@ CURPATH = os.path.dirname(os.path.abspath(__file__)) LOG = logging.getLogger(__name__) SYNCERS = utils.ThreadSafeDict() -with open(os.path.join(CURPATH, 'ui_common.json')) as f: - UI_COMMON = json.load(f) -STATUS = UI_COMMON['STATUS'] +with open(os.path.join(CURPATH, 'ui_data/common.json')) as f: + COMMON = json.load(f) +STATUS = COMMON['STATUS'] def retry_on_locked_db(method, *args, **kwargs): @@ -446,13 +446,13 @@ class WebSocketProtocol(WebSocket): # d.update(unsynced=0, synced=0, failed=0) while msg: if isinstance(msg, messaging.SyncMessage): - LOG.error('UNSYNCED +1') + LOG.error('UNSYNCED +1 %s' % getattr(msg, 'objname', '')) self.set_status(unsynced=self.get_status('unsynced') + 1) elif isinstance(msg, messaging.AckSyncMessage): - LOG.error('SYNCED +1') + LOG.error('SYNCED +1 %s' % getattr(msg, 'objname', '')) self.set_status(synced=self.get_status('synced') + 1) elif isinstance(msg, messaging.SyncErrorMessage): - LOG.error('FAILED +1') + LOG.error('FAILED +1 %s' % getattr(msg, 'objname', '')) self.set_status(failed=self.get_status('failed') + 1) elif isinstance(msg, messaging.LocalfsSyncDisabled): self.set_status(code=STATUS['DIRECTORY ERROR']) diff --git a/agkyra/ui_common.json b/agkyra/ui_common.json deleted file mode 100644 index a17fa392d5a33e1b8ad707493982603b8dcba1c2..0000000000000000000000000000000000000000 --- a/agkyra/ui_common.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "STATUS": { - "UNINITIALIZED": 0, - "INITIALIZING": 1, - "SHUTTING DOWN": 2, - "SYNCING": 100, - "PAUSING": 101, - "PAUSED": 102, - "SETTINGS MISSING": 200, - "AUTH URL ERROR": 201, - "TOKEN ERROR": 202, - "DIRECTORY ERROR": 203, - "CONTAINER ERROR": 204, - "CRITICAL ERROR": 1000 - } -} \ No newline at end of file diff --git a/agkyra/ui_data/common.json b/agkyra/ui_data/common.json new file mode 100644 index 0000000000000000000000000000000000000000..61dc95cb301b3c1808ba1aae61e1b694651b9bb6 --- /dev/null +++ b/agkyra/ui_data/common.json @@ -0,0 +1,30 @@ +{ + "STATUS": { + "UNINITIALIZED": 0, + "INITIALIZING": 1, + "SHUTTING DOWN": 2, + "SYNCING": 100, + "PAUSING": 101, + "PAUSED": 102, + "SETTINGS MISSING": 200, + "AUTH URL ERROR": 201, + "TOKEN ERROR": 202, + "DIRECTORY ERROR": 203, + "CONTAINER ERROR": 204, + "CRITICAL ERROR": 1000 + }, + "NOTIFICATION": { + "0": "Not initialized", + "1": "Initializing ...", + "2": "Shutting down", + "100": "Syncing", + "101": "Pausing", + "102": "Paused", + "200": "Settings are incomplete", + "201": "Cloud URL error", + "202": "Authentication error", + "203": "Local directory error", + "204": "Remote container error", + "1000": "Critical error" +} +} \ No newline at end of file