print(' block %d: Ok' % block_no)
block = b''
else:
- sys.exit(' block %d: Error, digest does not match'
- % block_no)
+ print(' block %d: Error, digest does not match' % block_no)
def check_file_hash(path: bytes) -> None:
global block
full_path = os.path.join(root_dir, path)
if not os.path.exists(full_path):
- sys.exit('Error: file does not exist: "%s"' % full_path.decode())
+ print('Error: file does not exist: "%s"' % full_path.decode(),
+ file=sys.stderr)
+ return
if not os.path.isfile(full_path):
- sys.exit('Error: name is not a regular file: "%s"'
- % full_path.decode())
+ print('Error: name is not a regular file: "%s"' % full_path.decode(),
+ file=sys.stderr)
+ return
block_no = 0
print('File "%s"' % full_path.decode())
with open(full_path, 'rb') as fp:
def check_file_size(path: bytes, size: int) -> None:
full_path = os.path.join(root_dir, path)
if not os.path.exists(full_path):
- sys.exit('Error: file does not exist: "%s"' % full_path.decode())
+ print('Error: file does not exist: "%s"' % full_path.decode(),
+ file=sys.stderr)
+ return
if not os.path.isfile(full_path):
- sys.exit('Error: name is not a regular file: "%s"'
- % full_path.decode())
+ print('Error: name is not a regular file: "%s"' % full_path.decode(),
+ file=sys.stderr)
+ return
file_size = os.path.getsize(full_path)
if file_size == size:
print('File Ok: "%s", size %d' % (full_path.decode(), size))