38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
#
|
|
# CatNet Python Server
|
|
#
|
|
# Copyright (C) 2023-2024 John Solntsev
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
#
|
|
|
|
import logging
|
|
|
|
|
|
log = logging.getLogger(__name__)
|
|
|
|
def fileiter(filename):
|
|
log.debug("Open file %s to byte-read" % filename)
|
|
|
|
with open(filename, "rb") as f:
|
|
while True:
|
|
file_data = f.read(1024)
|
|
|
|
yield file_data
|
|
|
|
if len(file_data) >= 1024:
|
|
log.debug("File size greeter 1024 bytes, yield data. Continue to read")
|
|
else:
|
|
log.debug("File size lower 1024 bytes, yield data. Break to read")
|
|
break
|