Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hashlib
- import logging as log
- import errno
- import os
- import re
- import sys
- import glob
- import shutil
- hasher = hashlib.md5()
- def test():
- print("test")
- #target directory
- target = 'OS.js/*'
- test()
- #log
- l = 'null'
- test()
- files = glob.glob(target)
- test()
- for name in files:
- try:
- with open(name,'rb') as f:
- buf = f.read()
- test()
- try:
- with open('hashlog.txt','wb') as l:
- l.write(hasher.hexdigest()+'\n')
- print(hasher.hexdigest())
- test()
- except IOError as exc:
- print("error saving file")
- if exc.errno != errno.EISDIR:
- raise
- except IOError as exc:
- if exc.errno!= errno.EISDIR:
- raise
- ##output
- ##test
- ##d41d8cd98f00b204e9800998ecf8427e
- ##test
- ##Traceback (most recent call last):
- ##File "C:\Users\gnoej\Desktop\python environment\pyHasher.py", line 23, in <module>
- ##with open(name,'rb') as f:
- ##IOError: [Errno 13] Permission denied: 'OS.js\\bin'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement