From 407b030bb7d27b797fb27254710a358c9c69f8be Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 24 Jan 2013 01:57:28 +0900 Subject: catch missing messages on last page of wizard --- src/leap/app.py | 9 ------ src/leap/base/auth.py | 7 ++--- src/leap/baseapp/eip.py | 7 +++-- src/leap/baseapp/mainwindow.py | 2 ++ src/leap/baseapp/network.py | 1 + src/leap/eip/eipconnection.py | 2 +- src/leap/eip/openvpnconnection.py | 1 - src/leap/gui/firstrun/connect.py | 51 +++++++++++++++++++++------------- src/leap/gui/firstrun/last.py | 27 ++++++++++++++---- src/leap/gui/firstrun/providersetup.py | 8 +----- src/leap/gui/firstrun/wizard.py | 1 + 11 files changed, 66 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/leap/app.py b/src/leap/app.py index 912e390d..eb38751c 100644 --- a/src/leap/app.py +++ b/src/leap/app.py @@ -48,14 +48,6 @@ def main(): console.setFormatter(formatter) logger.addHandler(console) - #logger.debug(opts) - import os - ldlib = os.environ.get("LD_LIBRARY_PATH", None) - dyldlib = os.environ.get("DYLD_LIBRARY_PATH", None) - - logger.debug("LD_LIBRARY_PATH %s" % ldlib) - logger.debug("DYLD_LIBRARY_PATH %s" % dyldlib) - logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') logger.info('LEAP client version %s', VERSION) logger.info('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~') @@ -73,7 +65,6 @@ def main(): # To test: # $ LANG=es ./app.py locale = QtCore.QLocale.system().name() - print locale qtTranslator = QtCore.QTranslator() if qtTranslator.load("qt_%s" % locale, ":/translations"): app.installTranslator(qtTranslator) diff --git a/src/leap/base/auth.py b/src/leap/base/auth.py index f629972f..c2d3f424 100644 --- a/src/leap/base/auth.py +++ b/src/leap/base/auth.py @@ -44,7 +44,7 @@ class LeapSRPRegister(object): schema="https", provider=None, verify=True, - register_path="1/users.json", + register_path="1/users", method="POST", fetcher=requests, srp=srp, @@ -113,9 +113,6 @@ class LeapSRPRegister(object): uri, data=user_data, timeout=SIGNUP_TIMEOUT, verify=self.verify) - logger.debug(req) - logger.debug('user_data: %s', user_data) - #logger.debug('response: %s', req.text) # we catch it in the form #req.raise_for_status() return (req.ok, req) @@ -159,7 +156,7 @@ class SRPAuth(requests.auth.AuthBase): def get_init_data(self): try: init_session = self.session.post( - self.server + '/1/sessions.json/', + self.server + '/1/sessions/', data=self.get_auth_data(), verify=self.verify) except requests.exceptions.ConnectionError: diff --git a/src/leap/baseapp/eip.py b/src/leap/baseapp/eip.py index 4c1fb32d..2f215f00 100644 --- a/src/leap/baseapp/eip.py +++ b/src/leap/baseapp/eip.py @@ -193,21 +193,24 @@ class EIPConductorAppMixin(object): # connection information via management interface log = self.conductor.get_log() error_matrix = [(EVENT_CONNECT_REFUSED, (self.start_or_stopVPN, ))] - self.network_checker.checker.parse_log_and_react(log, error_matrix) + if hasattr(self.network_checker, 'checker'): + self.network_checker.checker.parse_log_and_react(log, error_matrix) @QtCore.pyqtSlot() - def start_or_stopVPN(self): + def start_or_stopVPN(self, **kwargs): """ stub for running child process with vpn """ if self.conductor.has_errors(): logger.debug('not starting vpn; conductor has errors') + return if self.eip_service_started is False: try: self.conductor.connect() except eip_exceptions.EIPNoCommandError as exc: + logger.error('tried to run openvpn but no command is set') self.triggerEIPError.emit(exc) except Exception as err: diff --git a/src/leap/baseapp/mainwindow.py b/src/leap/baseapp/mainwindow.py index b1e5bccf..91b0dc61 100644 --- a/src/leap/baseapp/mainwindow.py +++ b/src/leap/baseapp/mainwindow.py @@ -186,4 +186,6 @@ class LeapWindow(QtGui.QMainWindow, called from the end of wizard """ self.show_systray_icon() + # this will setup the command + self.conductor.run_openvpn_checks() self.start_or_stopVPN() diff --git a/src/leap/baseapp/network.py b/src/leap/baseapp/network.py index d5685504..dc5182a4 100644 --- a/src/leap/baseapp/network.py +++ b/src/leap/baseapp/network.py @@ -36,6 +36,7 @@ class NetworkCheckerAppMixin(object): @QtCore.pyqtSlot(object) def runNetworkChecks(self): + logger.debug('running checks (from NetworkChecker Mixin slot)') self.network_checker.run_checks() @QtCore.pyqtSlot(object) diff --git a/src/leap/eip/eipconnection.py b/src/leap/eip/eipconnection.py index 20b45e36..d012c567 100644 --- a/src/leap/eip/eipconnection.py +++ b/src/leap/eip/eipconnection.py @@ -177,7 +177,7 @@ class EIPConnection(OpenVPNConnection, StatusMixIn): super(EIPConnection, self).__init__(*args, **kwargs) - def connect(self): + def connect(self, **kwargs): """ entry point for connection process """ diff --git a/src/leap/eip/openvpnconnection.py b/src/leap/eip/openvpnconnection.py index 05979ff7..4953db11 100644 --- a/src/leap/eip/openvpnconnection.py +++ b/src/leap/eip/openvpnconnection.py @@ -280,7 +280,6 @@ to be triggered for each one of them. # checks - def _check_if_running_instance(self): """ check if openvpn is already running diff --git a/src/leap/gui/firstrun/connect.py b/src/leap/gui/firstrun/connect.py index b7688380..9d89b7ab 100644 --- a/src/leap/gui/firstrun/connect.py +++ b/src/leap/gui/firstrun/connect.py @@ -120,9 +120,11 @@ class ConnectionPage(ValidationPage): called after _do_checks has finished (connected to checker thread finished signal) """ - # this should be called CONNECT PAGE AGAIN. # here we go! :) if self.is_done(): + nextbutton = self.wizard().button(QtGui.QWizard.NextButton) + nextbutton.setFocus() + full_domain = self.field('provider_domain') domain, port = get_https_domain_and_port(full_domain) _domain = u"%s:%s" % ( @@ -138,10 +140,15 @@ class ConnectionPage(ValidationPage): if conductor: conductor.set_provider_domain(domain) - conductor.run_checks() - self.conductor = conductor - errors = self.eip_error_check() - if not errors and start_eip_signal: + # we could run some of the checks to be + # sure everything is in order, but + # I see no point in doing it, we assume + # we've gone thru all checks during the wizard. + #conductor.run_checks() + #self.conductor = conductor + #errors = self.eip_error_check() + #if not errors and start_eip_signal: + if start_eip_signal: start_eip_signal.emit() else: @@ -150,12 +157,6 @@ class ConnectionPage(ValidationPage): "probably the wizard has been launched " "in an stand-alone way.") - # XXX look for a better place to signal - # we are done. - # We could probably have a fake validatePage - # that checks if the domain transfer has been - # done to conductor object, triggers the start_signal - # and does the go_next() self.set_done() def eip_error_check(self): @@ -165,9 +166,13 @@ class ConnectionPage(ValidationPage): consumes the conductor error queue. pops errors, and add those to the wizard page """ - logger.debug('eip error check from connecting page') - errq = self.conductor.error_queue - # XXX missing! + # TODO handle errors. + # We should redirect them to the log viewer + # with a brief message. + # XXX move to LAST PAGE instead. + #logger.debug('eip error check from connecting page') + #errq = self.conductor.error_queue + pass def _do_validation(self): """ @@ -186,17 +191,25 @@ class ConnectionPage(ValidationPage): prevpage, first_error) self.go_back() - else: - logger.debug('should go next, wait for user to click next') - #self.go_next() def nextId(self): wizard = self.wizard() - #if not wizard: - #return return wizard.get_page_index('lastpage') def initializePage(self): super(ConnectionPage, self).initializePage() self.set_undone() + cancelbutton = self.wizard().button(QtGui.QWizard.CancelButton) + cancelbutton.hide() self.completeChanged.emit() + + wizard = self.wizard() + eip_statuschange_signal = wizard.eip_statuschange_signal + if eip_statuschange_signal: + eip_statuschange_signal.connect( + lambda status: self.send_status( + status)) + + def send_status(self, status): + wizard = self.wizard() + wizard.openvpn_status.append(status) diff --git a/src/leap/gui/firstrun/last.py b/src/leap/gui/firstrun/last.py index e097b2ae..32d98acc 100644 --- a/src/leap/gui/firstrun/last.py +++ b/src/leap/gui/firstrun/last.py @@ -15,7 +15,8 @@ class LastPage(QtGui.QWizardPage): def __init__(self, parent=None): super(LastPage, self).__init__(parent) - self.setTitle(self.tr("Connecting to Encrypted Internet Proxy service...")) + self.setTitle(self.tr( + "Connecting to Encrypted Internet Proxy service...")) self.setPixmap( QtGui.QWizard.LogoPixmap, @@ -33,6 +34,7 @@ class LastPage(QtGui.QWizardPage): self.status_line_2 = QtGui.QLabel() self.status_line_3 = QtGui.QLabel() self.status_line_4 = QtGui.QLabel() + self.status_line_5 = QtGui.QLabel() layout = QtGui.QVBoxLayout() layout.addWidget(self.label) @@ -42,6 +44,7 @@ class LastPage(QtGui.QWizardPage): layout.addWidget(self.status_line_2) layout.addWidget(self.status_line_3) layout.addWidget(self.status_line_4) + layout.addWidget(self.status_line_5) self.setLayout(layout) @@ -67,7 +70,7 @@ class LastPage(QtGui.QWizardPage): # signals. See progress.py logger.debug('logging status in last page') self.validation_done = False - status_count = 0 + status_count = 1 try: while True: status = (yield) @@ -84,11 +87,23 @@ class LastPage(QtGui.QWizardPage): pass def initializePage(self): + super(LastPage, self).initializePage() wizard = self.wizard() - if not wizard: - return - eip_status_handler = self.eip_status_handler() + handler = self.eip_status_handler() + + # get statuses done in prev page + for st in wizard.openvpn_status: + self.send_status(handler.send, st) + + # bind signal for events yet to come eip_statuschange_signal = wizard.eip_statuschange_signal if eip_statuschange_signal: eip_statuschange_signal.connect( - lambda status: eip_status_handler.send(status)) + lambda status: self.send_status( + handler.send, status)) + + def send_status(self, cb, status): + try: + cb(status) + except StopIteration: + pass diff --git a/src/leap/gui/firstrun/providersetup.py b/src/leap/gui/firstrun/providersetup.py index 981e3214..6017e4d3 100644 --- a/src/leap/gui/firstrun/providersetup.py +++ b/src/leap/gui/firstrun/providersetup.py @@ -141,18 +141,12 @@ class ProviderSetupValidationPage(ValidationPage): wizard.set_validation_error( prevpage, first_error) - # XXX don't go back, signal error - #self.go_back() - else: - logger.debug('should be going next, wait on user') - #self.go_next() def nextId(self): wizard = self.wizard() from_login = wizard.from_login if from_login: - # XXX bad name. change to connect again. - next_ = 'signupvalidation' + next_ = 'connect' else: next_ = 'signup' return wizard.get_page_index(next_) diff --git a/src/leap/gui/firstrun/wizard.py b/src/leap/gui/firstrun/wizard.py index 427f9df8..f198dca0 100755 --- a/src/leap/gui/firstrun/wizard.py +++ b/src/leap/gui/firstrun/wizard.py @@ -136,6 +136,7 @@ class FirstRunWizard(QtGui.QWizard): self.add_pages_from_dict(pages_dict) self.validation_errors = {} + self.openvpn_status = [] self.setPixmap( QtGui.QWizard.BannerPixmap, -- cgit v1.2.3 From ff59da55ef9a176b36cef19d67e7ec363bf5d739 Mon Sep 17 00:00:00 2001 From: kali Date: Thu, 24 Jan 2013 02:30:00 +0900 Subject: wizard rephrasing & punctuation --- src/leap/gui/firstrun/connect.py | 59 ++++++++++++++++----------------- src/leap/gui/firstrun/intro.py | 6 ++-- src/leap/gui/firstrun/login.py | 2 +- src/leap/gui/firstrun/providerinfo.py | 9 +++-- src/leap/gui/firstrun/providerselect.py | 8 ++--- src/leap/gui/firstrun/providersetup.py | 2 +- src/leap/gui/firstrun/register.py | 4 +-- src/leap/util/translations.py | 2 -- 8 files changed, 46 insertions(+), 46 deletions(-) (limited to 'src') diff --git a/src/leap/gui/firstrun/connect.py b/src/leap/gui/firstrun/connect.py index 9d89b7ab..ad7bb13a 100644 --- a/src/leap/gui/firstrun/connect.py +++ b/src/leap/gui/firstrun/connect.py @@ -24,8 +24,8 @@ class ConnectionPage(ValidationPage): self.current_page = "connect" title = self.tr("Connecting...") - # XXX uh... really? - subtitle = self.tr("Checking connection with provider.") + subtitle = self.tr("Setting up a encrypted " + "connection with the provider") self.setTitle(title) self.setSubTitle(subtitle) @@ -82,7 +82,7 @@ class ConnectionPage(ValidationPage): except Exception as exc: return self.fail(exc.message) - yield((self.tr("Fetching provider config..."), 40), + yield((self.tr("Getting EIP configuration files"), 40), fetcheipconf) ################################################## @@ -94,7 +94,7 @@ class ConnectionPage(ValidationPage): downloaded = pCertChecker.download_new_client_cert( credentials=credentials) if not downloaded: - logger.error('Could not download client cert.') + logger.error('Could not download client cert') return False except auth.SRPAuthenticationError as exc: @@ -106,7 +106,7 @@ class ConnectionPage(ValidationPage): else: return True - yield((self.tr("Fetching eip certificate"), 80), + yield((self.tr("Getting EIP certificate"), 80), fetcheipcert) ################ @@ -159,38 +159,37 @@ class ConnectionPage(ValidationPage): self.set_done() - def eip_error_check(self): - """ - a version of the main app error checker, - but integrated within the connecting page of the wizard. - consumes the conductor error queue. - pops errors, and add those to the wizard page - """ + #def eip_error_check(self): + #""" + #a version of the main app error checker, + #but integrated within the connecting page of the wizard. + #consumes the conductor error queue. + #pops errors, and add those to the wizard page + #""" # TODO handle errors. # We should redirect them to the log viewer # with a brief message. # XXX move to LAST PAGE instead. #logger.debug('eip error check from connecting page') #errq = self.conductor.error_queue - pass - - def _do_validation(self): - """ - called after _do_checks has finished - (connected to checker thread finished signal) - """ - from_login = self.wizard().from_login - prevpage = "login" if from_login else "signup" - wizard = self.wizard() - if self.errors: - logger.debug('going back with errors') - logger.error(self.errors) - name, first_error = self.pop_first_error() - wizard.set_validation_error( - prevpage, - first_error) - self.go_back() + #def _do_validation(self): + #""" + #called after _do_checks has finished + #(connected to checker thread finished signal) + #""" + #from_login = self.wizard().from_login + #prevpage = "login" if from_login else "signup" + + #wizard = self.wizard() + #if self.errors: + #logger.debug('going back with errors') + #logger.error(self.errors) + #name, first_error = self.pop_first_error() + #wizard.set_validation_error( + #prevpage, + #first_error) + #self.go_back() def nextId(self): wizard = self.wizard() diff --git a/src/leap/gui/firstrun/intro.py b/src/leap/gui/firstrun/intro.py index 0425b764..b519362f 100644 --- a/src/leap/gui/firstrun/intro.py +++ b/src/leap/gui/firstrun/intro.py @@ -11,7 +11,7 @@ class IntroPage(QtGui.QWizardPage): def __init__(self, parent=None): super(IntroPage, self).__init__(parent) - self.setTitle(self.tr("First run wizard.")) + self.setTitle(self.tr("First run wizard")) #self.setPixmap( #QtGui.QWizard.WatermarkPixmap, @@ -35,10 +35,10 @@ class IntroPage(QtGui.QWizardPage): radiobuttonGroup = QtGui.QGroupBox() self.sign_up = QtGui.QRadioButton( - self.tr("Sign up for a new account.")) + self.tr("Sign up for a new account")) self.sign_up.setChecked(True) self.log_in = QtGui.QRadioButton( - self.tr("Log In with my credentials.")) + self.tr("Log In with my credentials")) radiobLayout = QtGui.QVBoxLayout() radiobLayout.addWidget(self.sign_up) diff --git a/src/leap/gui/firstrun/login.py b/src/leap/gui/firstrun/login.py index e39eecc0..3707d3ff 100644 --- a/src/leap/gui/firstrun/login.py +++ b/src/leap/gui/firstrun/login.py @@ -22,7 +22,7 @@ class LogInPage(InlineValidationPage, UserFormMixIn): # InlineValidationPage self.current_page = "login" self.setTitle(self.tr("Log In")) - self.setSubTitle(self.tr("Log in with your credentials.")) + self.setSubTitle(self.tr("Log in with your credentials")) self.current_page = "login" self.setPixmap( diff --git a/src/leap/gui/firstrun/providerinfo.py b/src/leap/gui/firstrun/providerinfo.py index 357378df..cff4caca 100644 --- a/src/leap/gui/firstrun/providerinfo.py +++ b/src/leap/gui/firstrun/providerinfo.py @@ -16,9 +16,9 @@ class ProviderInfoPage(QtGui.QWizardPage): def __init__(self, parent=None): super(ProviderInfoPage, self).__init__(parent) - self.setTitle(self.tr("Provider Info")) + self.setTitle(self.tr("Provider Information")) self.setSubTitle(self.tr( - "This is what provider says.")) + "Services offered by this provider")) self.setPixmap( QtGui.QWizard.LogoPixmap, @@ -89,10 +89,13 @@ class ProviderInfoPage(QtGui.QWizardPage): self.description.setText( "%s" % description_text) + # XXX should translate this... enroll = pconfig.get('enrollment_policy') if enroll: self.enrollment_policy.setText( - 'enrollment policy: %s' % enroll) + '%s: %s' % ( + self.tr('enrollment policy'), + enroll)) def nextId(self): wizard = self.wizard() diff --git a/src/leap/gui/firstrun/providerselect.py b/src/leap/gui/firstrun/providerselect.py index ccecd519..917b16fd 100644 --- a/src/leap/gui/firstrun/providerselect.py +++ b/src/leap/gui/firstrun/providerselect.py @@ -32,7 +32,7 @@ class SelectProviderPage(InlineValidationPage): self.setTitle(self.tr("Enter Provider")) self.setSubTitle(self.tr( "Please enter the domain of the provider you want " - "to use for your connection.") + "to use for your connection") ) self.setPixmap( QtGui.QWizard.LogoPixmap, @@ -219,7 +219,7 @@ class SelectProviderPage(InlineValidationPage): return True logger.debug('checking name resolution') - yield((self.tr("checking domain name"), 20), namecheck) + yield((self.tr("Checking if it is a valid provider"), 20), namecheck) ######################### # 2) try https connection @@ -273,7 +273,7 @@ class SelectProviderPage(InlineValidationPage): return True logger.debug('checking https connection') - yield((self.tr("checking https connection"), 40), httpscheck) + yield((self.tr("Checking for a secure connection"), 40), httpscheck) ################################## # 3) try download provider info... @@ -300,7 +300,7 @@ class SelectProviderPage(InlineValidationPage): else: return True - yield((self.tr("fetching provider info"), 80), fetchinfo) + yield((self.tr("Getting info from the provider"), 80), fetchinfo) # done! diff --git a/src/leap/gui/firstrun/providersetup.py b/src/leap/gui/firstrun/providersetup.py index 6017e4d3..47060f6e 100644 --- a/src/leap/gui/firstrun/providersetup.py +++ b/src/leap/gui/firstrun/providersetup.py @@ -27,7 +27,7 @@ class ProviderSetupValidationPage(ValidationPage): self.setTitle(self.tr("Provider setup")) self.setSubTitle( - self.tr("Doing autoconfig.")) + self.tr("Gathering configuration options for this provider")) self.setPixmap( QtGui.QWizard.LogoPixmap, diff --git a/src/leap/gui/firstrun/register.py b/src/leap/gui/firstrun/register.py index 741b9267..15278330 100644 --- a/src/leap/gui/firstrun/register.py +++ b/src/leap/gui/firstrun/register.py @@ -315,7 +315,7 @@ class RegisterUserPage(InlineValidationPage, UserFormMixIn): return True logger.debug('registering user') - yield(("registering with provider", 40), register) + yield(("Registering username", 40), register) self.set_done() yield(("end_sentinel", 100), lambda: None) @@ -376,7 +376,7 @@ class RegisterUserPage(InlineValidationPage, UserFormMixIn): #self.tr("Register a new user with provider %s.") % #provider) self.setSubTitle( - self.tr("Register a new user with provider %s." % + self.tr("Register a new user with provider %s" % provider)) self.validationMsg.setText('') self.userPassword2LineEdit.setText('') diff --git a/src/leap/util/translations.py b/src/leap/util/translations.py index d782cfe4..f55c8fba 100644 --- a/src/leap/util/translations.py +++ b/src/leap/util/translations.py @@ -56,8 +56,6 @@ def translate(*args, **kwargs): return qtTranslate(*nargs) else: - #nargs = ('default', ) + args - #import pdb4qt; pdb4qt.set_trace() return qtTranslate(*args) -- cgit v1.2.3