diff options
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | Makefile | 1 | ||||
| -rw-r--r-- | changes/bug-4116_remember-last-login-domain | 1 | ||||
| -rw-r--r-- | changes/feature-3925_automate-i18n | 2 | ||||
| -rw-r--r-- | data/bitmask.pro | 63 | ||||
| -rw-r--r-- | data/bitmask.pro.template | 9 | ||||
| -rwxr-xr-x | data/make_project_file.py | 74 | ||||
| -rw-r--r-- | docs/dev/internationalization.rst | 13 | ||||
| -rw-r--r-- | src/leap/bitmask/config/leapsettings.py | 19 | ||||
| -rw-r--r-- | src/leap/bitmask/gui/login.py | 1 | ||||
| -rw-r--r-- | src/leap/bitmask/gui/mainwindow.py | 8 | 
11 files changed, 121 insertions, 72 deletions
@@ -29,3 +29,5 @@ MANIFEST  _trial_temp*  config/*  CHANGELOG~ + +data/bitmask.pro @@ -48,6 +48,7 @@ resources : $(COMPILED_RESOURCES)  ui : $(COMPILED_UI)  translations: +	data/make_project_file.py  	$(PYLUP) $(PROJFILE)  	$(LRELE) $(TRANSLAT_DIR)/*.ts diff --git a/changes/bug-4116_remember-last-login-domain b/changes/bug-4116_remember-last-login-domain new file mode 100644 index 00000000..9331052b --- /dev/null +++ b/changes/bug-4116_remember-last-login-domain @@ -0,0 +1 @@ +  o Remember last domain used to login. Closes #4116. diff --git a/changes/feature-3925_automate-i18n b/changes/feature-3925_automate-i18n new file mode 100644 index 00000000..60f31813 --- /dev/null +++ b/changes/feature-3925_automate-i18n @@ -0,0 +1,2 @@ +  o Automate internationalization process, create project file dynamically on +    make. Closes #3925. diff --git a/data/bitmask.pro b/data/bitmask.pro deleted file mode 100644 index b9b5dc84..00000000 --- a/data/bitmask.pro +++ /dev/null @@ -1,63 +0,0 @@ -# qmake file - -# is not there a f*** way of expanding this? other to template with python I mean... - -# to get a list of python files we can use: -# find . -iname "*.py" | grep -Ev "__init__.py|/build/|/docs/|/gui/ui_[a-z]*.py|/gui/[a-z]*_rc.py|./.venv/|/tests/" -# and remove by hand the few files that we do not want. - -SOURCES += ../src/leap/bitmask/app.py \ -           ../src/leap/bitmask/config/leapsettings.py \ -           ../src/leap/bitmask/config/providerconfig.py \ -           ../src/leap/bitmask/crypto/srpauth.py \ -           ../src/leap/bitmask/crypto/srpregister.py \ -           ../src/leap/bitmask/gui/loggerwindow.py \ -           ../src/leap/bitmask/gui/login.py \ -           ../src/leap/bitmask/gui/mainwindow.py \ -           ../src/leap/bitmask/gui/twisted_main.py \ -           ../src/leap/bitmask/gui/wizardpage.py \ -           ../src/leap/bitmask/gui/wizard.py \ -           ../src/leap/bitmask/gui/eip_status.py \ -           ../src/leap/bitmask/gui/mail_status.py \ -           ../src/leap/bitmask/gui/eip_preferenceswindow.py \ -           ../src/leap/bitmask/gui/preferenceswindow.py \ -           ../src/leap/bitmask/platform_init/initializers.py \ -           ../src/leap/bitmask/platform_init/locks.py \ -           ../src/leap/bitmask/provider/supportedapis.py \ -           ../src/leap/bitmask/services/abstractbootstrapper.py \ -           ../src/leap/bitmask/services/eip/eipbootstrapper.py \ -           ../src/leap/bitmask/services/eip/eipconfig.py \ -           ../src/leap/bitmask/provider/providerbootstrapper.py \ -           ../src/leap/bitmask/services/__init__.py \ -           ../src/leap/bitmask/services/connections.py \ -           ../src/leap/bitmask/services/eip/udstelnet.py \ -           ../src/leap/bitmask/services/eip/vpnlauncher.py \ -           ../src/leap/bitmask/services/eip/vpnprocess.py \ -           ../src/leap/bitmask/services/mail/smtpbootstrapper.py \ -           ../src/leap/bitmask/services/mail/smtpconfig.py \ -           ../src/leap/bitmask/services/soledad/soledadbootstrapper.py \ -           ../src/leap/bitmask/services/soledad/soledadconfig.py \ -           ../src/leap/bitmask/services/tx.py \ -           ../src/leap/bitmask/util/constants.py \ -           ../src/leap/bitmask/util/keyring_helpers.py \ -           ../src/leap/bitmask/util/leap_argparse.py \ -           ../src/leap/bitmask/util/leap_log_handler.py \ -           ../src/leap/bitmask/util/privilege_policies.py \ -           ../src/leap/bitmask/util/pyside_tests_helper.py \ -           ../src/leap/bitmask/util/request_helpers.py \ -           ../src/leap/bitmask/util/requirement_checker.py - -FORMS += ../src/leap/bitmask/gui/ui/loggerwindow.ui \ -         ../src/leap/bitmask/gui/ui/login.ui \ -         ../src/leap/bitmask/gui/ui/mainwindow.ui \ -         ../src/leap/bitmask/gui/ui/wizard.ui \ -         ../src/leap/bitmask/gui/ui/eip_status.ui \ -         ../src/leap/bitmask/gui/ui/mail_status.ui \ -         ../src/leap/bitmask/gui/ui/eippreferences.ui \ -         ../src/leap/bitmask/gui/ui/preferences.ui \ - -# where to generate ts files -- tx will pick from here - -# original file, english - -TRANSLATIONS    += ts/en_US.ts diff --git a/data/bitmask.pro.template b/data/bitmask.pro.template new file mode 100644 index 00000000..564103a3 --- /dev/null +++ b/data/bitmask.pro.template @@ -0,0 +1,9 @@ +{header} + +SOURCES += {sources} + +FORMS += {forms} + +# where to generate ts files -- tx will pick from here +# original file, english +TRANSLATIONS    += ts/en_US.ts diff --git a/data/make_project_file.py b/data/make_project_file.py new file mode 100755 index 00000000..d1567837 --- /dev/null +++ b/data/make_project_file.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python +# encoding: utf-8 + +import fnmatch +import os +import os.path +import re + + +# thanks to http://stackoverflow.com/a/5141829/687989 +def list_files(includes, excludes, start='.'): +    """ +    Returns a list of files matching the glob expressions of the included +    parameter and excluding the files and directories matching the parameter +    excludes. + +    :param includes: the files to match, using glob's format. +    :type includes: list of str +    :param excludes: the files and directories to exclude, using glob's format. +    :type excludes: list of str +    """ +    # transform glob patterns to regular expressions +    includes = r'|'.join([fnmatch.translate(x) for x in includes]) +    excludes = r'|'.join([fnmatch.translate(x) for x in excludes]) or r'$.' + +    files_list = [] + +    for root, dirs, files in os.walk(start): +        # exclude dirs +        if excludes: +            dirs[:] = [d for d in dirs if not re.match(excludes, d)] + +        # exclude/include files +        if excludes: +            files = [f for f in files if not re.match(excludes, f)] +        files = [f for f in files if re.match(includes, f)] +        files = [os.path.join(root, f) for f in files] + +        for fname in files: +            files_list.append(fname) + +    return files_list + + +if __name__ == '__main__': +    SOURCE_ROOT = 'src' +    TEMPLATE = 'data/bitmask.pro.template' +    PROJECT = 'data/bitmask.pro' + +    HEADER = ("# DO NOT EDIT MANUALLY.\n" +              "# qmake file generated by script, any changes will be lost.") + +    # Source files +    includes = ["*.py"] +    excludes = ['__init__.py', '_version.py', 'ui_*.py', '*_rc.py'] +    sources = list_files(includes, excludes, SOURCE_ROOT) +    sources = " \\\n".join(["../{0}".format(f) for f in sources]) + +    # Form files +    includes = ["*.ui"] +    excludes = [] +    forms = list_files(includes, excludes, SOURCE_ROOT) +    forms = " \\\n".join(["../{0}".format(f) for f in forms]) + +    # Load template and write project +    template = file(TEMPLATE).read() +    project = template.format(header=HEADER, sources=sources, forms=forms) + +    try: +        with open(PROJECT, 'w') as output: +            output.write(project) +            print "Project file generated successfully" +    except IOError, e: +        print "Error saving project file: {0}".format(e) diff --git a/docs/dev/internationalization.rst b/docs/dev/internationalization.rst index f9f522b9..c0f208de 100644 --- a/docs/dev/internationalization.rst +++ b/docs/dev/internationalization.rst @@ -65,19 +65,20 @@ If you do not already have it, install the ``transifex-client`` from the cheese  You can learn more about the transifex-client `here <http://help.transifex.com/features/client/index.html>`_. -**1.** Add any new source files to the project file, ``data/bitmask.pro``. *We should automate this with some templating, it's tedious.* - -**2.** Update the source .ts file ``data/ts/en_US.ts``.:: +**1.** Update the source .ts file ``data/ts/en_US.ts``.::     $ make translations -**3.** Push source .ts file to transifex:: +It automatically adds any new source files and forms to the project file, ``data/bitmask.pro``. +If there is a file to be ignored in the translations you need to edit the ``data/make_project_file.py`` to set the excludes. + +**2.** Push source .ts file to transifex::     $ tx push -s -**4.** Let the translation fairies do their work... +**3.** Let the translation fairies do their work... -**5.** *Et voila!* Get updated .ts files for each language from ``Transifex``. For instance, to pull updated spanish translations::  +**4.** *Et voila!* Get updated .ts files for each language from ``Transifex``. For instance, to pull updated spanish translations::      $ tx pull -l es     Pulling new translations for resource bitmask.bitmask (source: data/ts/en_US.ts) diff --git a/src/leap/bitmask/config/leapsettings.py b/src/leap/bitmask/config/leapsettings.py index d7b60ba9..c524425e 100644 --- a/src/leap/bitmask/config/leapsettings.py +++ b/src/leap/bitmask/config/leapsettings.py @@ -62,6 +62,7 @@ class LeapSettings(object):      GEOMETRY_KEY = "Geometry"      WINDOWSTATE_KEY = "WindowState"      USER_KEY = "User" +    PROVIDER_KEY = "Provider"      REMEMBER_KEY = "RememberUserAndPass"      DEFAULTPROVIDER_KEY = "DefaultProvider"      AUTOSTARTEIP_KEY = "AutoStartEIP" @@ -241,6 +242,24 @@ class LeapSettings(object):          leap_assert(len(user) > 0, "We cannot save an empty user")          self._settings.setValue(self.USER_KEY, user) +    def get_provider(self): +        """ +        Returns the configured provider to remember, None if there isn't one + +        :rtype: str or None +        """ +        return self._settings.value(self.PROVIDER_KEY, None) + +    def set_provider(self, provider): +        """ +        Saves the provider to remember + +        :param provider: provider name to remember +        :type provider: str +        """ +        leap_assert(len(provider) > 0, "We cannot save an empty provider") +        self._settings.setValue(self.PROVIDER_KEY, provider) +      def get_remember(self):          """          Returns the value of the remember selection. diff --git a/src/leap/bitmask/gui/login.py b/src/leap/bitmask/gui/login.py index c8c5c402..ac34fe23 100644 --- a/src/leap/bitmask/gui/login.py +++ b/src/leap/bitmask/gui/login.py @@ -297,6 +297,7 @@ class LoginWidget(QtGui.QWidget):          self.set_enabled(False)          self.ui.clblErrorMsg.hide() +        self._settings.set_provider(provider)          if self.get_remember() and has_keyring():              # in the keyring and in the settings              # we store the value 'usename@provider' diff --git a/src/leap/bitmask/gui/mainwindow.py b/src/leap/bitmask/gui/mainwindow.py index 5d7f717b..f5631c69 100644 --- a/src/leap/bitmask/gui/mainwindow.py +++ b/src/leap/bitmask/gui/mainwindow.py @@ -583,6 +583,11 @@ class MainWindow(QtGui.QMainWindow):              self._wizard = None          else:              self._try_autostart_eip() + +            domain = self._settings.get_provider() +            if domain is not None: +                self._login_widget.select_provider_by_name(domain) +              if not self._settings.get_remember():                  # nothing to do here                  return @@ -600,9 +605,6 @@ class MainWindow(QtGui.QMainWindow):                  # fill the username                  self._login_widget.set_user(username) -                # select the configured provider in the combo box -                self._login_widget.select_provider_by_name(domain) -                  self._login_widget.set_remember(True)                  saved_password = None  | 
