diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-08-02 13:56:08 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-08-02 13:56:08 -0300 |
commit | a3c23acaf45b81a6360cd76180c7329a7369b4c5 (patch) | |
tree | 2a2f500eb81e78a90f5b403fad7a596f2bff0f95 | |
parent | 1b329b507a4ce430ece6629d2b0a8e40526ede3b (diff) | |
parent | f86b56bbb4fa6b713ac393cd5481709478910307 (diff) |
Merge remote-tracking branch 'ivan/bug/3294_improve-add-missing-files' into develop
-rw-r--r-- | changes/bug-3294_improve-add-missing-files | 1 | ||||
-rw-r--r-- | src/leap/platform_init/initializers.py | 35 | ||||
-rw-r--r-- | src/leap/services/eip/vpnlaunchers.py | 2 |
3 files changed, 28 insertions, 10 deletions
diff --git a/changes/bug-3294_improve-add-missing-files b/changes/bug-3294_improve-add-missing-files new file mode 100644 index 00000000..ff1f0723 --- /dev/null +++ b/changes/bug-3294_improve-add-missing-files @@ -0,0 +1 @@ + o Add missing files does not stop if a command fails, also warns the user if there was an error. Closes #3294. diff --git a/src/leap/platform_init/initializers.py b/src/leap/platform_init/initializers.py index 3523c117..cc5f6e87 100644 --- a/src/leap/platform_init/initializers.py +++ b/src/leap/platform_init/initializers.py @@ -122,10 +122,15 @@ def check_missing(): logger.warning( "Installer not found for platform %s." % (_system,)) return - install_missing_fun( - # XXX maybe move constants to fun - UPDOWN_BADEXEC_MSG, - UPDOWN_NOTFOUND_MSG) + + # XXX maybe move constants to fun + ok = install_missing_fun(UPDOWN_BADEXEC_MSG, UPDOWN_NOTFOUND_MSG) + if not ok: + msg = QtGui.QMessageBox() + msg.setWindowTitle(msg.tr("Problem installing files")) + msg.setText(msg.tr('Some of the files could not be copied.')) + msg.setIcon(QtGui.QMessageBox.Warning) + msg.exec_() elif ret == QtGui.QMessageBox.No: logger.debug("Not installing missing scripts, " @@ -235,9 +240,12 @@ def _darwin_install_missing_scripts(badexec, notfound): :type badexec: str :param notfound: error for notifying missing path. :type notfound: str + :returns: True if the files could be copied successfully. + :rtype: bool """ # We expect to execute this from some way of bundle, since # the up/down scripts should be put in place by the installer. + success = False installer_path = os.path.join( os.getcwd(), "..", @@ -261,7 +269,9 @@ def _darwin_install_missing_scripts(badexec, notfound): ret = subprocess.call( cmdline, stdout=subprocess.PIPE, shell=True) - assert([ret]) # happy flakes + success = ret == 0 + if not success: + logger.error("Install missing scripts failed.") except Exception as exc: logger.error(badexec) logger.error("Error was: %r" % (exc,)) @@ -274,6 +284,8 @@ def _darwin_install_missing_scripts(badexec, notfound): logger.error(notfound) logger.debug('path searched: %s' % (installer_path,)) + return success + def DarwinInitializer(): """ @@ -339,10 +351,11 @@ def _linux_install_missing_scripts(badexec, notfound): :type badexec: str :param notfound: error for notifying missing path. :type notfound: str + :returns: True if the files could be copied successfully. + :rtype: bool """ - installer_path = os.path.join( - os.getcwd(), - "apps", "eip", "files") + success = False + installer_path = os.path.join(os.getcwd(), "apps", "eip", "files") launcher = vpnlaunchers.LinuxVPNLauncher # XXX refactor with darwin, same block. @@ -370,7 +383,9 @@ def _linux_install_missing_scripts(badexec, notfound): ret = subprocess.call( cmdline, stdout=subprocess.PIPE, shell=True) - assert([ret]) # happy flakes + success = ret == 0 + if not success: + logger.error("Install missing scripts failed.") except Exception as exc: logger.error(badexec) logger.error("Error was: %r" % (exc,)) @@ -383,6 +398,8 @@ def _linux_install_missing_scripts(badexec, notfound): logger.error(notfound) logger.debug('path searched: %s' % (installer_path,)) + return success + def LinuxInitializer(): """ diff --git a/src/leap/services/eip/vpnlaunchers.py b/src/leap/services/eip/vpnlaunchers.py index b591b3ca..0151c1c6 100644 --- a/src/leap/services/eip/vpnlaunchers.py +++ b/src/leap/services/eip/vpnlaunchers.py @@ -292,7 +292,7 @@ class LinuxVPNLauncher(VPNLauncher): """ to = kls.SYSTEM_CONFIG - cmd = '#!/bin/sh\nset -e\n' + cmd = '#!/bin/sh\n' cmd += 'mkdir -p "%s"\n' % (to, ) cmd += 'cp "%s/%s" "%s"\n' % (frompath, kls.UP_DOWN_FILE, to) cmd += 'cp "%s" "%s"\n' % (pol_file, kls.POLKIT_PATH) |