You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

39 lines
1.1 KiB

  1. # patch manager
  2. def run(log_exception=1):
  3. import webnotes
  4. from patches import patch
  5. from webnotes.utils import cint
  6. next_patch = cint(webnotes.conn.get_global('next_patch'))
  7. if next_patch <= patch.last_patch:
  8. for i in range(next_patch, patch.last_patch+1):
  9. webnotes.conn.begin()
  10. if log_exception:
  11. try:
  12. patch.execute(i)
  13. except Exception, e:
  14. write_log()
  15. return
  16. else:
  17. patch.execute(i)
  18. webnotes.conn.set_global('next_patch', str(i+1))
  19. webnotes.conn.commit()
  20. def write_log():
  21. import os
  22. import webnotes.defs
  23. import webnotes
  24. patch_log = open(os.path.join(webnotes.defs.modules_path, 'patches', 'patch.log'), 'a')
  25. patch_log.write(('\n\nError in %s:\n' % webnotes.conn.cur_db_name) + webnotes.getTraceback())
  26. patch_log.close()
  27. if getattr(webnotes.defs,'admin_email_notification',0):
  28. from webnotes.utils import sendmail
  29. subj = 'Error in running patches in %s' % webnotes.conn.cur_db_name
  30. msg = subj + '<br><br>Login User: ' + webnotes.user.name + '<br><br>' + webnotes.getTraceback()
  31. sendmail(['developers@erpnext.com'], sender='automail@erpnext.com', subject= subj, parts=[['text/plain', msg]])