From 652b1b86ea6b4e45356755479b3124fa161d4acf Mon Sep 17 00:00:00 2001 From: Andreas Preikschat Date: Mon, 22 Aug 2011 10:45:03 +0200 Subject: [PATCH] use urllib to download file --- scripts/translation_utils.py | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/scripts/translation_utils.py b/scripts/translation_utils.py index db1788aba..935ef97e8 100755 --- a/scripts/translation_utils.py +++ b/scripts/translation_utils.py @@ -186,25 +186,6 @@ def update_export_at_pootle(source_filename): page = urllib.urlopen(REVIEW_URL) page.close() - -def download_file(source_filename, dest_filename): - """ - Download a file and save it to disk. - - ``source_filename`` - The file to download. - - ``dest_filename`` - The new local file name. - """ - print_verbose(u'Downloading from: %s' % (SERVER_URL + source_filename)) - page = urllib.urlopen(SERVER_URL + source_filename) - content = page.read().decode('utf8') - page.close() - file = open(dest_filename, u'w') - file.write(content.encode('utf8')) - file.close() - def download_translations(): """ This method downloads the translation files from the Pootle server. @@ -219,7 +200,7 @@ def download_translations(): filename = os.path.join(os.path.abspath(u'..'), u'resources', u'i18n', language_file) print_verbose(u'Get Translation File: %s' % filename) - download_file(language_file, filename) + urllib.urlretrieve(SERVER_URL + language_file, filename) print_quiet(u' Done.') def prepare_project(): @@ -304,7 +285,7 @@ def create_translation(language): if not language.endswith(u'.ts'): language += u'.ts' filename = os.path.join(os.path.abspath(u'..'), u'resources', u'i18n', language) - download_file(u'en.ts', filename) + urllib.urlretrieve(SERVER_URL + u'en.ts', filename) print_quiet(u' ** Please Note **') print_quiet(u' In order to get this file into OpenLP and onto the ' u'Pootle translation server you will need to subscribe to the '