old style exception, raise --> new style for Python 3 (#10082)
* old style raise --> raise() for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style exception --> new style for Python 3 * old style raise --> raise() for Python 3 * old style raise --> raise() for Python 3 * old style exception, raise --> new style for Python 3
This commit is contained in:
parent
c67bf5026e
commit
6848708377
@ -84,7 +84,7 @@ def get_csv_contents(files_path):
|
||||
try:
|
||||
csv_content.setdefault(file_type, [])\
|
||||
.append(read_csv_content(csvfile.read()))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
continue
|
||||
return csv_content
|
||||
|
||||
|
@ -469,7 +469,7 @@ def submit_invoice(si_doc, name, doc):
|
||||
si_doc.insert()
|
||||
si_doc.submit()
|
||||
frappe.db.commit()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if frappe.message_log: frappe.message_log.pop()
|
||||
frappe.db.rollback()
|
||||
save_invoice(e, si_doc, name)
|
||||
|
@ -72,7 +72,7 @@ def get_fiscal_years(transaction_date=None, fiscal_year=None, label="Date", verb
|
||||
|
||||
error_msg = _("""{0} {1} not in any active Fiscal Year.""").format(label, formatdate(transaction_date))
|
||||
if verbose==1: frappe.msgprint(error_msg)
|
||||
raise FiscalYearError, error_msg
|
||||
raise FiscalYearError(error_msg)
|
||||
|
||||
def validate_fiscal_year(date, fiscal_year, company, label="Date", doc=None):
|
||||
years = [f[0] for f in get_fiscal_years(date, label=_(label), company=company)]
|
||||
@ -738,4 +738,4 @@ def create_payment_gateway_account(gateway):
|
||||
|
||||
except frappe.DuplicateEntryError:
|
||||
# already exists, due to a reinstall?
|
||||
pass
|
||||
pass
|
||||
|
@ -311,7 +311,7 @@ class ProcessPayroll(Document):
|
||||
journal_entry.submit()
|
||||
jv_name = journal_entry.name
|
||||
self.update_salary_slip_status(jv_name = jv_name)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
frappe.msgprint(e)
|
||||
return jv_name
|
||||
|
||||
|
@ -121,7 +121,7 @@ def upload():
|
||||
try:
|
||||
check_record(d)
|
||||
ret.append(import_doc(d, "Attendance", 1, row_idx, submit=True))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
error = True
|
||||
ret.append('Error for row (#%d) %s : %s' % (row_idx,
|
||||
len(row)>1 and row[1] or "", cstr(e)))
|
||||
|
@ -12,6 +12,6 @@ def execute():
|
||||
frappe.model.rename_field("Item", "parent_website_sitemap", "parent_website_route")
|
||||
frappe.model.rename_field("Sales Partner", "parent_website_sitemap",
|
||||
"parent_website_route")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if e.args[0]!=1054:
|
||||
raise
|
||||
raise
|
||||
|
@ -78,7 +78,7 @@ def execute():
|
||||
def insert_or_update(account):
|
||||
try:
|
||||
account.insert()
|
||||
except frappe.NameError, e:
|
||||
except frappe.NameError as e:
|
||||
if e.args[0]=="Email Account":
|
||||
existing_account = frappe.get_doc("Email Account", e.args[1])
|
||||
for key, value in account.as_dict().items():
|
||||
|
@ -34,7 +34,7 @@ def execute():
|
||||
voucher = frappe.get_doc(voucher_type, voucher_no)
|
||||
voucher.make_gl_entries()
|
||||
frappe.db.commit()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print frappe.get_traceback()
|
||||
rejected.append([voucher_type, voucher_no])
|
||||
frappe.db.rollback()
|
||||
|
@ -19,6 +19,6 @@ def execute():
|
||||
def rename_field_if_exists(doctype, old_fieldname, new_fieldname):
|
||||
try:
|
||||
rename_field(doctype, old_fieldname, new_fieldname)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if e.args[0] != 1054:
|
||||
raise
|
||||
|
@ -233,10 +233,10 @@ def install(country=None):
|
||||
|
||||
try:
|
||||
doc.insert(ignore_permissions=True)
|
||||
except frappe.DuplicateEntryError, e:
|
||||
except frappe.DuplicateEntryError as e:
|
||||
# pass DuplicateEntryError and continue
|
||||
if e.args and e.args[0]==doc.doctype and e.args[1]==doc.name:
|
||||
# make sure DuplicateEntryError is for the exact same doc and not a related doc
|
||||
pass
|
||||
else:
|
||||
raise
|
||||
raise
|
||||
|
@ -696,7 +696,7 @@ def _msgprint(msg, verbose):
|
||||
if verbose:
|
||||
msgprint(msg, raise_exception=True)
|
||||
else:
|
||||
raise frappe.ValidationError, msg
|
||||
raise frappe.ValidationError(msg)
|
||||
|
||||
|
||||
def get_last_purchase_details(item_code, doc_name=None, conversion_rate=1.0):
|
||||
|
@ -143,16 +143,16 @@ class StockReconciliation(StockController):
|
||||
|
||||
# item should not be serialized
|
||||
if item.has_serial_no == 1:
|
||||
raise frappe.ValidationError, _("Serialized Item {0} cannot be updated using Stock Reconciliation, please use Stock Entry").format(item_code)
|
||||
raise frappe.ValidationError(_("Serialized Item {0} cannot be updated using Stock Reconciliation, please use Stock Entry").format(item_code))
|
||||
|
||||
# item managed batch-wise not allowed
|
||||
if item.has_batch_no == 1:
|
||||
raise frappe.ValidationError, _("Batched Item {0} cannot be updated using Stock Reconciliation, instead use Stock Entry").format(item_code)
|
||||
raise frappe.ValidationError(_("Batched Item {0} cannot be updated using Stock Reconciliation, instead use Stock Entry").format(item_code))
|
||||
|
||||
# docstatus should be < 2
|
||||
validate_cancelled_item(item_code, item.docstatus, verbose=0)
|
||||
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.validation_messages.append(_("Row # ") + ("%d: " % (row_num)) + cstr(e))
|
||||
|
||||
def update_stock_ledger(self):
|
||||
|
@ -378,7 +378,7 @@ class update_entries_after(object):
|
||||
if self.verbose:
|
||||
frappe.throw(msg, NegativeStockError, title='Insufficent Stock')
|
||||
else:
|
||||
raise NegativeStockError, msg
|
||||
raise NegativeStockError(msg)
|
||||
|
||||
def get_previous_sle(args, for_update=False):
|
||||
"""
|
||||
|
Loading…
x
Reference in New Issue
Block a user