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