logging_5.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. def check_dir():
  2. try:
  3. if not os.path.exists(settings.MEDIA_ROOT):
  4. try:
  5. os.mkdir(settings.MEDIA_ROOT)
  6. except OSError:
  7. logging.error(traceback.format_exc())
  8. return
  9. if not os.path.exists(settings.MEDIA_ROOT+"/att"):
  10. try:
  11. os.mkdir(settings.MEDIA_ROOT+"/att")
  12. except OSError:
  13. logging.error(traceback.format_exc())
  14. return
  15. if not os.path.exists(settings.MEDIA_ROOT+"/att/biophoto"):
  16. try:
  17. os.mkdir(settings.MEDIA_ROOT+"/att/biophoto")
  18. except OSError:
  19. logging.error(traceback.format_exc())
  20. return
  21. if not os.path.exists(settings.ATT_ROOT):
  22. try:
  23. os.mkdir(settings.ATT_ROOT)
  24. except OSError:
  25. logging.error(traceback.format_exc())
  26. return
  27. if not os.path.exists(settings.ATT_ROOT+"/USERPIC"):
  28. try:
  29. os.mkdir(settings.ATT_ROOT+"/USERPIC")
  30. except OSError:
  31. logging.error(traceback.format_exc())
  32. return
  33. except Exception as err:
  34. logging.error('%s\n%s' % (traceback.format_exc(), str(err)))