def execute_patch(patchmodule, method=None, methodargs=None):
 block_user(True)
 frappe.db.begin()
 try:
  log(u'Executing {patch} in {site} ({db})'.format(patch=(patchmodule or str(methodargs)), site=frappe.local.site, db=frappe.db.cur_db_name))
  if patchmodule:
   if patchmodule.startswith(u'finally:'):
    frappe.flags.final_patches.append(patchmodule)
   else:
    if patchmodule.startswith(u'execute:'):
     exec patchmodule.split(u'execute:')[1] in globals()
    else:
     frappe.get_attr((patchmodule.split()[0] + u'.execute'))()
    update_patch_log(patchmodule)
  elif method:
   method(**methodargs)
 except Exception:
  frappe.db.rollback()
  raise
 else:
  frappe.db.commit()
  block_user(False)
  log(u'Success')
 return True

def execute_patch ( patchmodule , method = None , methodargs = None ) : block_user ( True ) frappe . db . begin ( ) try : log ( u'Executing {patch} in {site} ({db})' . format ( patch = ( patchmodule or str ( methodargs ) ) , site = frappe . local . site , db = frappe . db . cur_db_name ) ) if patchmodule : if patchmodule . startswith ( u'finally:' ) : frappe . flags . final_patches . append ( patchmodule ) else : if patchmodule . startswith ( u'execute:' ) : exec patchmodule . split ( u'execute:' ) [ 1 ] in globals ( ) else : frappe . get_attr ( ( patchmodule . split ( ) [ 0 ] + u'.execute' ) ) ( ) update_patch_log ( patchmodule ) elif method : method ( ** methodargs ) except Exception : frappe . db . rollback ( ) raise else : frappe . db . commit ( ) block_user ( False ) log ( u'Success' ) return True
execute the patch .