Commit 4ac700bb authored by Stavros Sachtouris's avatar Stavros Sachtouris Committed by Giorgos Korfiatis
Browse files

Allow raising popups more than once per session

parent 75d17806
......@@ -71,24 +71,27 @@ class GUI(WebSocketBaseClient):
def _dump_session_file(self, session):
"""Create (overwrite) the session file for GUI use"""
LOG.info('Create session file with connection info for GUI')
flags = os.O_CREAT | os.O_WRONLY
mode = stat.S_IREAD | stat.S_IWRITE
f = os.open(self.session_file, flags, mode)
os.write(f, json.dumps(session))
os.close(f)
LOG.debug('Session file %s created' % self.session_file)
def clean_exit(self):
"""Clean up tracks of GUI"""
LOG.info('Remove session file')
try:
os.remove(self.session_file)
LOG.debug('Removed GUI session file')
LOG.debug('Removed session file %s' % self.session_file)
except Exception as e:
LOG.warning('While cleaning GUI: %s' % e)
self.close()
def handshake_ok(self):
"""If handshake OK is, SessionHelper UP goes, so GUI launched can be"""
LOG.debug('Protocol server is UP, running GUI')
LOG.info('Protocol server is UP, start html/js GUI')
try:
subprocess.call([self.nw, self.gui_code, self.session_file])
finally:
......
......@@ -212,6 +212,9 @@ class SessionHelper(object):
pass
class WebSocketProtocol(WebSocket):
"""Helper-side WebSocket protocol for communication with GUI:
......@@ -293,16 +296,21 @@ class WebSocketProtocol(WebSocket):
if self.syncer and self.can_sync():
self._consume_messages()
with self.status.lock() as d:
if self.syncer.paused:
d['code'] = STATUS['PAUSED']
elif d['code'] != STATUS['PAUSING'] or (
d['unsynced'] == d['synced'] + d['failed']):
d['code'] = STATUS['SYNCING']
LOG.debug('Status was %s' % d['code'])
if d['code'] in (
STATUS['UNINITIALIZED'], STATUS['INITIALIZING']):
if self.syncer.paused:
d['code'] = STATUS['PAUSED']
elif d['code'] != STATUS['PAUSING'] or (
d['unsynced'] == d['synced'] + d['failed']):
d['code'] = STATUS['SYNCING']
with self.status.lock() as d:
LOG.debug('Status is now %s' % d['code'])
return d.get(key, None) if key else dict(d)
def set_status(self, **kwargs):
with self.status.lock() as d:
LOG.debug('CHANGING STATUS TO %s' % kwargs)
d.update(kwargs)
@property
......@@ -482,12 +490,15 @@ class WebSocketProtocol(WebSocket):
LOG.debug('FAILED +1 %s' % getattr(msg, 'objname', ''))
self.set_status(failed=self.get_status('failed') + 1)
elif isinstance(msg, messaging.LocalfsSyncDisabled):
LOG.debug('STOP BACKEND, %s'% getattr(msg, 'objname', ''))
LOG.debug('CHANGE STATUS TO: %s' % STATUS['DIRECTORY ERROR'])
self.set_status(code=STATUS['DIRECTORY ERROR'])
self.syncer.stop_all_daemons()
elif isinstance(msg, messaging.PithosSyncDisabled):
LOG.debug('STOP BACKEND, %s'% getattr(msg, 'objname', ''))
self.set_status(code=STATUS['CONTAINER ERROR'])
self.syncer.stop_all_daemons()
LOG.debug('Backend message: %s' % msg.name)
LOG.debug('Backend message: %s %s' % (msg.name, type(msg)))
# Limit the amount of messages consumed each time
max_consumption -= 1
if max_consumption:
......
......@@ -217,12 +217,14 @@ function check_menu_lang() {
}
// Update progress
var old_status = -1;
window.setInterval(function() {
check_menu_lang();
var new_progress = COMMON.NOTIFICATION[globals.status.code];
var new_pause = '';
var tray_icon_off = false;
var dialogue_msg = null;
var status_unchanged = (old_status == globals.status.code);
switch(globals.status.code) {
case STATUS['UNINITIALIZED']:
case STATUS['INITIALIZING']:
......@@ -255,9 +257,11 @@ window.setInterval(function() {
'%s', remaining(globals.status));
break;
case STATUS['DIRECTORY ERROR']:
if (status_unchanged) break;
dialogue_msg = COMMON.DIALOGUE[globals.status.code].replace(
'%s', globals.settings.directory);
case STATUS['CONTAINER ERROR']:
if (status_unchanged) break;
if (!dialogue_msg)
dialogue_msg = COMMON.DIALOGUE[globals.status.code].replace(
'%s', globals.settings.container);
......@@ -265,16 +269,17 @@ window.setInterval(function() {
if (windows.dialogue === null) {
windows['dialogue'] = gui.Window.open(
'dialogue.html', {
toolbar: false, focus: true,
width: 550, height: 220});
toolbar: false, focus: true, width: 550, height: 220});
windows['dialogue'].on('closed', function() {
var d = get_dialogue();
if (d.response) post_force(socket);
windows['dialogue'] = null;
});
}
case STATUS['AUTH URL ERROR']:
case STATUS['TOKEN ERROR']:
case STATUS['SETTINGS MISSING']:
if (status_unchanged) break;
deactivate_menu();
new_pause = COMMON.MENU.INACTIVE;
settings_menu.enabled = true;
......@@ -301,6 +306,7 @@ window.setInterval(function() {
else if (!(tray_icon_off || tray.icon === tray_icon.on))
tray.icon = tray_icon.on;
old_status = globals.status.code
get_status(socket);
}, 1500);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment