Skip to content

Commit 9bf6061

Browse files
committedMar 29, 2024
Switch prints to logging in folder_paths and add some extra debug.
1 parent 5d8898c commit 9bf6061

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed
 

‎folder_paths.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import time
3+
import logging
34

45
supported_pt_extensions = set(['.ckpt', '.pt', '.bin', '.pth', '.safetensors'])
56

@@ -44,7 +45,7 @@
4445
try:
4546
os.makedirs(input_directory)
4647
except:
47-
print("Failed to create input directory")
48+
logging.error("Failed to create input directory")
4849

4950
def set_output_directory(output_dir):
5051
global output_directory
@@ -146,21 +147,23 @@ def recursive_search(directory, excluded_dir_names=None):
146147
try:
147148
dirs[directory] = os.path.getmtime(directory)
148149
except FileNotFoundError:
149-
print(f"Warning: Unable to access {directory}. Skipping this path.")
150-
150+
logging.warning(f"Warning: Unable to access {directory}. Skipping this path.")
151+
152+
logging.debug("recursive file list on directory {}".format(directory))
151153
for dirpath, subdirs, filenames in os.walk(directory, followlinks=True, topdown=True):
152154
subdirs[:] = [d for d in subdirs if d not in excluded_dir_names]
153155
for file_name in filenames:
154156
relative_path = os.path.relpath(os.path.join(dirpath, file_name), directory)
155157
result.append(relative_path)
156-
158+
157159
for d in subdirs:
158160
path = os.path.join(dirpath, d)
159161
try:
160162
dirs[path] = os.path.getmtime(path)
161163
except FileNotFoundError:
162-
print(f"Warning: Unable to access {path}. Skipping this path.")
164+
logging.warning(f"Warning: Unable to access {path}. Skipping this path.")
163165
continue
166+
logging.debug("found {} files".format(len(result)))
164167
return result, dirs
165168

166169
def filter_files_extensions(files, extensions):
@@ -248,8 +251,8 @@ def compute_vars(input, image_width, image_height):
248251
err = "**** ERROR: Saving image outside the output folder is not allowed." + \
249252
"\n full_output_folder: " + os.path.abspath(full_output_folder) + \
250253
"\n output_dir: " + output_dir + \
251-
"\n commonpath: " + os.path.commonpath((output_dir, os.path.abspath(full_output_folder)))
252-
print(err)
254+
"\n commonpath: " + os.path.commonpath((output_dir, os.path.abspath(full_output_folder)))
255+
logging.error(err)
253256
raise Exception(err)
254257

255258
try:

0 commit comments

Comments
 (0)