forked from openlp/openlp
use urllib to download file
This commit is contained in:
parent
79f5163113
commit
652b1b86ea
@ -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 '
|
||||
|
Loading…
Reference in New Issue
Block a user