Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 
 

38 lignes
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. from webnotes.utils import sendmail
  28. subj = 'Error in running patches in %s' % webnotes.conn.cur_db_name
  29. msg = subj + '<br><br>Login User: ' + webnotes.user.name + '<br><br>' + webnotes.getTraceback()
  30. sendmail(['developer@erpnext.com'], sender='automail@erpnext.com', subject= subj, parts=[['text/plain', msg]])