mirror of
https://github.com/psy0rz/zfs_autobackup.git
synced 2025-04-11 22:40:01 +03:00
python2 compat
This commit is contained in:
parent
b60dd4c109
commit
f397e7be59
@ -1,8 +1,4 @@
|
||||
from __future__ import print_function
|
||||
import hashlib
|
||||
import sys
|
||||
from builtins import BrokenPipeError
|
||||
from signal import signal, SIGPIPE, SIG_DFL
|
||||
|
||||
from .ZfsNode import ZfsNode
|
||||
from .util import *
|
||||
@ -66,8 +62,8 @@ class ZfsCheck(CliBase):
|
||||
print("{}\t{}\t{}".format(file, block, hash))
|
||||
sys.stdout.flush() #important, to generate SIGPIPES on ssh disconnect
|
||||
|
||||
except BrokenPipeError:
|
||||
output_redir()
|
||||
# except BrokenPipeError:
|
||||
# output_redir()
|
||||
|
||||
finally:
|
||||
snapshot.unmount()
|
||||
|
@ -20,8 +20,6 @@ import platform
|
||||
import sys
|
||||
import time
|
||||
|
||||
import pathlib as pathlib
|
||||
|
||||
|
||||
def block_hash(fname, count=10000, bs=4096):
|
||||
"""This function was created to checksum huge files and blockdevices (TB's)
|
||||
@ -60,12 +58,17 @@ def block_hash_tree(start_path, count=10000, bs=4096):
|
||||
cwd=os.getcwd()
|
||||
os.chdir(start_path)
|
||||
|
||||
try:
|
||||
for f in pathlib.Path('.').glob('**/*'):
|
||||
if f.is_file() and not f.is_symlink():
|
||||
for (chunk_nr, hash) in block_hash(f, count, bs):
|
||||
def walkerror(e):
|
||||
raise e
|
||||
|
||||
yield ( f, chunk_nr, hash )
|
||||
try:
|
||||
for (dirpath, dirnames, filenames) in os.walk(".", onerror=walkerror):
|
||||
for f in filenames:
|
||||
file_path=os.path.join(dirpath, f)
|
||||
|
||||
if (not os.path.islink(file_path)) and os.path.isfile(file_path):
|
||||
for (chunk_nr, hash) in block_hash(file_path, count, bs):
|
||||
yield ( file_path, chunk_nr, hash )
|
||||
finally:
|
||||
os.chdir(cwd)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user