|
|
@@ -19,23 +19,31 @@ import os |
|
|
|
|
|
|
|
class PatchError(Exception): pass |
|
|
|
|
|
|
|
def run_all(): |
|
|
|
def run_all(skip_failing=False): |
|
|
|
"""run all pending patches""" |
|
|
|
executed = [p[0] for p in frappe.db.sql("""select patch from `tabPatch Log`""")] |
|
|
|
|
|
|
|
frappe.flags.final_patches = [] |
|
|
|
for patch in get_all_patches(): |
|
|
|
if patch and (patch not in executed): |
|
|
|
|
|
|
|
def run_patch(patch): |
|
|
|
try: |
|
|
|
if not run_single(patchmodule = patch): |
|
|
|
log(patch + ': failed: STOPPED') |
|
|
|
raise PatchError(patch) |
|
|
|
except Exception: |
|
|
|
if not skip_failing: |
|
|
|
raise |
|
|
|
else: |
|
|
|
log('Failed to execute patch') |
|
|
|
|
|
|
|
for patch in get_all_patches(): |
|
|
|
if patch and (patch not in executed): |
|
|
|
run_patch(patch) |
|
|
|
|
|
|
|
# patches to be run in the end |
|
|
|
for patch in frappe.flags.final_patches: |
|
|
|
patch = patch.replace('finally:', '') |
|
|
|
if not run_single(patchmodule = patch): |
|
|
|
log(patch + ': failed: STOPPED') |
|
|
|
raise PatchError(patch) |
|
|
|
run_patch(patch) |
|
|
|
|
|
|
|
def get_all_patches(): |
|
|
|
patches = [] |
|
|
|