def _translate_untranslated(context, lang): for site in context.sites: try: frappe.init(site=site) frappe.connect() translate_untranslated_from_google(lang) frappe.db.commit() finally: frappe.destroy()
def _translate_untranslated_all(context): for site in context.sites: try: frappe.init(site=site) frappe.connect() for lang in frappe.db.sql_list("select name from tabLanguage"): translate_untranslated_from_google(lang) frappe.db.commit() finally: frappe.destroy()
def _translate_untranslated_all(context): for site in context.sites: try: frappe.init(site=site) frappe.connect() for lang in frappe.db.sql_list("select name from tabLanguage"): try: translate_untranslated_from_google(lang) except requests.exceptions.HTTPError: print("skipping {0}".format(lang)) continue finally: frappe.db.commit() finally: frappe.destroy()