Advertisement
Guest User

Untitled

a guest
Aug 30th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.09 KB | None | 0 0
  1. import hashlib
  2. import logging as log
  3. import errno
  4. import os
  5. import re
  6. import sys
  7. import glob
  8. import shutil
  9.  
  10. hasher = hashlib.md5()
  11. def test():
  12.     print("test")
  13. #target directory
  14. target = 'OS.js/*'
  15.  
  16. test()
  17. #log
  18. l = 'null'
  19. test()
  20. files = glob.glob(target)
  21. test()
  22. for name in files:
  23.     try:
  24.         with open(name,'rb') as f:
  25.             buf = f.read()
  26.             test()
  27.             try:
  28.                 with open('hashlog.txt','wb') as l:
  29.                     l.write(hasher.hexdigest()+'\n')
  30.                     print(hasher.hexdigest())
  31.                     test()
  32.             except IOError as exc:
  33.                 print("error saving file")
  34.                 if exc.errno != errno.EISDIR:
  35.                     raise
  36.     except IOError as exc:
  37.         if exc.errno!= errno.EISDIR:
  38.             raise
  39. ##output
  40. ##test
  41. ##d41d8cd98f00b204e9800998ecf8427e
  42. ##test
  43.  
  44. ##Traceback (most recent call last):
  45.   ##File "C:\Users\gnoej\Desktop\python environment\pyHasher.py", line 23, in <module>
  46.     ##with open(name,'rb') as f:
  47. ##IOError: [Errno 13] Permission denied: 'OS.js\\bin'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement