diff options
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 1 | ||||
-rw-r--r-- | changes/bug_improve-bootstrap-script | 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 | ||||
-rwxr-xr-x | pkg/scripts/bitmask_bootstrap.sh | 51 |
9 files changed, 135 insertions, 81 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_improve-bootstrap-script b/changes/bug_improve-bootstrap-script new file mode 100644 index 00000000..855efcb7 --- /dev/null +++ b/changes/bug_improve-bootstrap-script @@ -0,0 +1 @@ + o Add call to `make` to bootstrap script. 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/pkg/scripts/bitmask_bootstrap.sh b/pkg/scripts/bitmask_bootstrap.sh index bd568ebd..70f9867e 100755 --- a/pkg/scripts/bitmask_bootstrap.sh +++ b/pkg/scripts/bitmask_bootstrap.sh @@ -1,10 +1,34 @@ #!/bin/bash - +###################################################################### +# bitmask_boostrap.sh +# Copyright (C) 2013 LEAP +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +###################################################################### # Installs requirements, and # clones the latest leap-client # depends on: -# openvpn git-core libgnutls-dev python-dev python-qt4 python-setuptools python-virtualenv +# (authoritative list under docs/dev/quickstart.rst) + +# git python-dev python-setuptools python-virtualenv python-pip python-openssl libsqlite3-dev g++ openvpn +# pyside-tools python-pyside python-qt4 + +# Clone latest git (develop branch) +# change "develop" for any other branch you want. +BRANCH="develop" +BITMASK_DIR="bitmask-develop" # Escape code esc=`echo -en "\033"` @@ -23,27 +47,30 @@ echo "~~~~~~~~~~~~~~~~~~~~~~~" echo "" echo "${cc_green}Creating virtualenv...${cc_normal}" -mkdir bitmask-testbuild -virtualenv bitmask-testbuild -source bitmask-testbuild/bin/activate +mkdir ${BITMASK_DIR} +virtualenv "${BITMASK_DIR}" +source ./${BITMASK_DIR}/bin/activate echo "${cc_green}Installing bitmask...${cc_normal}" -# Clone latest git (develop branch) -# change "develop" for any other branch you want. - +pip install -e 'git+https://leap.se/git/bitmask_client@'${BRANCH}'#egg=leap.bitmask' -pip install -e 'git+https://leap.se/git/bitmask_client@develop#egg=leap.bitmask' - -cd bitmask-testbuild +cd ${BITMASK_DIR} # symlink the pyside libraries to the system libs ./src/leap.bitmask/pkg/postmkvenv.sh +cd ./src/leap.bitmask +make +cd ../../ +source ./bin/activate + echo "${cc_green}bitmask installed! =)" echo "${cc_yellow}" echo "Launch it with: " echo "~~~~~~~~~~~~~~~~~~~~~~" -echo "bin/bitmask" +echo "bin/bitmask --debug" echo "~~~~~~~~~~~~~~~~~~~~~~" +echo "If you are not inside the virtualenv, source it first with " +echo "source "${BITMASK_DIR}"/bin/activate" echo "${cc_normal}" |