Skip to content

Commit

Permalink
Merge branch 'release-1.3.14'
Browse files Browse the repository at this point in the history
  • Loading branch information
Hector Lopez committed May 26, 2022
2 parents deca4cd + 5caff76 commit c17190c
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 9 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
# Changelog #

# 1.3.14
### CHANGES:
* Updated download process to initialize use ready_to_download flag in api response

# 1.3.13
### CHANGES:
* Removed the ability to change the Project Workflow
* Clarified to only download documents when the status is COMPLETE or LATE

# 1.3.12
### CHANGES:
* Clarified set up with git

# 1.3.11
### NEW FEATURES:
* Added the ability to change project and workflow on document update without needing to disassociate
Expand Down
2 changes: 1 addition & 1 deletion python2/ltk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.3.13'
__version__ = '1.3.14'
12 changes: 12 additions & 0 deletions python2/ltk/actions/download_action.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ltk.actions.action import *
from ltk.exceptions import RequestFailedError
import json
import re
import tempfile
Expand All @@ -14,6 +15,7 @@ def __init__(self, path):
self.current_doc = ''
self.DEFAULT_COMMIT_MESSAGE = "Translations updated for "
self.documents_downloaded = False
self.boolean_filter = set(["1", "true", "on", "yes", "True", True])

def download_by_path(self, file_path, locale_codes, locale_ext, no_ext, auto_format, xliff):
docs = self.get_docs_in_path(file_path)
Expand All @@ -40,6 +42,16 @@ def download_locales(self, document_id, locale_codes, auto_format, xliff, locale
def download_action(self, document_id, locale_code, auto_format, xliff=False, locale_ext=True):
try:
latest_document_id = self.get_latest_document_version(document_id) or document_id
try:
response = self.api.document_translation_locale_status(latest_document_id, locale_code)
# 'ready_to_download flag should exist before we check if it's truthy
# "true", and other truthy values, should evaluate to True, so we added a check for that
ready_to_download = response.json()['properties']['ready_to_download'] in self.boolean_filter if 'ready_to_download' in response.json().get('properties') else False
except RequestFailedError as e:
raise_error(response.json(), "Failed to download " + locale_code + ".", True)
return
if not ready_to_download:
return
response = self.api.document_content(latest_document_id, locale_code, auto_format, xliff, self.finalized_file)
entry = None
entry = self.doc_manager.get_doc_by_prop('id', document_id)
Expand Down
5 changes: 3 additions & 2 deletions python2/ltk/actions/status_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class StatusAction(Action):
def __init__(self, path):
Action.__init__(self, path)
self.uploadWaitTime = 300
self.boolean_filter = set(["1", "true", "on", "yes", "True", True])

def get_status(self, **kwargs):
try:
Expand Down Expand Up @@ -146,7 +147,7 @@ def _print_detailed_status(self, doc_id, doc_name):
if 'entities' in response.json():
for entry in response.json()['entities']:
curr_locale = entry['properties']['locale_code']
curr_progress = entry['properties']['percent_complete']
ready_to_download = 'Ready to Download' if 'ready_to_download' in entry.get('properties') and entry['properties']['ready_to_download'] in self.boolean_filter else 'In Progress'
curr_statustext = entry['properties']['status']
# print ('\tlocale: {0} \t percent complete: {1}%'.format(curr_locale, curr_progress))
if 'entities' in entry:
Expand All @@ -162,7 +163,7 @@ def _print_detailed_status(self, doc_id, doc_name):
table.append({"Phase": str(phase_order), "Name": phase_name, "Status": phase_status, "Phase Percent Complete": str(phase_percent_complete) + '%'})
table.sort(key=lambda x: x['Phase'])
print('\n')
print('Locale: {0} \t Total Percent Complete: {1}% ({2})\n'.format(curr_locale, curr_progress, curr_statustext))
print('Locale: {0} \t {1} \n'.format(curr_locale, ready_to_download))
# print('Locale: {0} \n'.format(curr_locale))
print(tabulate(table, headers="keys"))

Expand Down
2 changes: 2 additions & 0 deletions python2/ltk/apicalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ def document_translation_locale_status(self, document_id, locale):
uri = (API_URI['document_translation_locale'] % locals())
r = requests.get(self.host + uri, headers=self.headers)
log_api('GET', uri, r)
if r.status_code != 200:
raise RequestFailedError("Unable to get translation status")
except requests.exceptions.ConnectionError:
self.handleError()
return r
Expand Down
2 changes: 1 addition & 1 deletion python2/ltk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_valid_locales(api, entered_locales, operation_text):
logger.warning('No locales have been assigned to this document. Please add them using \'ltk request\'.')
else:
for locale in entered_locales:
check_locale = locale.replace("-","_")
check_locale = locale.replace("_","-")
if remote_check and check_locale not in valid_locales or not remote_check and not check_locale in locale_list:
logger.warning('The locale code "'+str(locale)+'" failed to be '+operation_text+' since it is invalid (see "ltk list -l" for the list of valid codes).')
else:
Expand Down
2 changes: 1 addition & 1 deletion python3/ltk/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '1.3.13'
__version__ = '1.3.14'
12 changes: 12 additions & 0 deletions python3/ltk/actions/download_action.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from ltk.actions.action import *
from ltk.exceptions import RequestFailedError
import json
import re
import tempfile
Expand All @@ -14,6 +15,7 @@ def __init__(self, path):
self.current_doc = ''
self.DEFAULT_COMMIT_MESSAGE = "Translations updated for "
self.documents_downloaded = False
self.boolean_filter = set(["1", "true", "on", "yes", "True", True])

def download_by_path(self, file_path, locale_codes, locale_ext, no_ext, auto_format, xliff):
docs = self.get_docs_in_path(file_path)
Expand All @@ -40,6 +42,16 @@ def download_locales(self, document_id, locale_codes, auto_format, xliff, locale
def download_action(self, document_id, locale_code, auto_format, xliff=False, locale_ext=True):
try:
latest_document_id = self.get_latest_document_version(document_id) or document_id
try:
response = self.api.document_translation_locale_status(latest_document_id, locale_code)
# 'ready_to_download flag should exist before we check if it's truthy
# "true", and other truthy values, should evaluate to True, so we added a check for that
ready_to_download = response.json()['properties']['ready_to_download'] in self.boolean_filter if 'ready_to_download' in response.json().get('properties') else False
except RequestFailedError as e:
raise_error(response.json(), "Failed to download " + locale_code + ".", True)
return
if not ready_to_download:
return
response = self.api.document_content(latest_document_id, locale_code, auto_format, xliff, self.finalized_file)
entry = None
entry = self.doc_manager.get_doc_by_prop('id', document_id)
Expand Down
5 changes: 3 additions & 2 deletions python3/ltk/actions/status_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class StatusAction(Action):
def __init__(self, path):
Action.__init__(self, path)
self.uploadWaitTime = 300
self.boolean_filter = set(["1", "true", "on", "yes", "True", True])

def get_status(self, **kwargs):
try:
Expand Down Expand Up @@ -146,7 +147,7 @@ def _print_detailed_status(self, doc_id, doc_name):
if 'entities' in response.json():
for entry in response.json()['entities']:
curr_locale = entry['properties']['locale_code']
curr_progress = entry['properties']['percent_complete']
ready_to_download = 'Ready to Download' if 'ready_to_download' in entry.get('properties') and entry['properties']['ready_to_download'] in self.boolean_filter else 'In Progress'
curr_statustext = entry['properties']['status']
# print ('\tlocale: {0} \t percent complete: {1}%'.format(curr_locale, curr_progress))
if 'entities' in entry:
Expand All @@ -162,7 +163,7 @@ def _print_detailed_status(self, doc_id, doc_name):
table.append({"Phase": str(phase_order), "Name": phase_name, "Status": phase_status, "Phase Percent Complete": str(phase_percent_complete) + '%'})
table.sort(key=lambda x: x['Phase'])
print('\n')
print('Locale: {0} \t Total Percent Complete: {1}% ({2})\n'.format(curr_locale, curr_progress, curr_statustext))
print('Locale: {0} \t {1} \n'.format(curr_locale, ready_to_download))
# print('Locale: {0} \n'.format(curr_locale))
print(tabulate(table, headers="keys"))

Expand Down
2 changes: 2 additions & 0 deletions python3/ltk/apicalls.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ def document_translation_locale_status(self, document_id, locale):
uri = (API_URI['document_translation_locale'] % locals())
r = requests.get(self.host + uri, headers=self.headers)
log_api('GET', uri, r)
if r.status_code != 200:
raise RequestFailedError("Unable to get translation status")
except requests.exceptions.ConnectionError:
self.handleError()
return r
Expand Down
2 changes: 1 addition & 1 deletion python3/ltk/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def get_valid_locales(api, entered_locales, operation_text):
logger.warning('No locales have been assigned to this document. Please add them using \'ltk request\'.')
else:
for locale in entered_locales:
check_locale = locale.replace("-","_")
check_locale = locale.replace("_","-")
if remote_check and check_locale not in valid_locales or not remote_check and not check_locale in locale_list:
logger.warning('The locale code "'+str(locale)+'" failed to be '+operation_text+' since it is invalid (see "ltk list -l" for the list of valid codes).')
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

setup(
name='ltk',
version='1.3.13',
version='1.3.14',
url='https://github.com/Lingotek/filesystem-connector',
description='The Lingotek Filesystem Connector (ltk) links your files and folders to the Translation Network™',
long_description=long_description,
Expand Down

0 comments on commit c17190c

Please sign in to comment.