DEBUG is now a boolean to fix occasionaly debug when I did not want it
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
|
||||
|
||||
# global debug setting
|
||||
DEBUG=0
|
||||
DEBUG=False
|
||||
|
||||
### SQLALCHEMY IMPORTS ###
|
||||
from sqlalchemy.ext.declarative import declarative_base
|
||||
@@ -660,7 +660,7 @@ def FinishJob(job, last_log, state="Completed", pa_job_state="Completed"):
|
||||
if job.state=="Failed":
|
||||
CancelJob(job,job.id)
|
||||
session.commit()
|
||||
if DEBUG==1:
|
||||
if DEBUG:
|
||||
print( f"DEBUG: {last_log}" )
|
||||
return
|
||||
|
||||
@@ -669,7 +669,7 @@ def FinishJob(job, last_log, state="Completed", pa_job_state="Completed"):
|
||||
# TODO: why not only retrieve New jobs from DB?
|
||||
##############################################################################
|
||||
def HandleJobs():
|
||||
if DEBUG==1:
|
||||
if DEBUG:
|
||||
print("INFO: PA job manager is scanning for new jobs to process")
|
||||
for job in session.query(Job).all():
|
||||
if job.pa_job_state == 'New':
|
||||
@@ -684,7 +684,7 @@ def HandleJobs():
|
||||
continue
|
||||
|
||||
# use this to remove threads for easier debugging, and errors will stacktrace to the console
|
||||
if DEBUG==1:
|
||||
if DEBUG:
|
||||
print("*************************************")
|
||||
print("RUNNING job: id={} name={} wait_for={}".format(job.id, job.name, job.wait_for ))
|
||||
RunJob(job)
|
||||
@@ -810,7 +810,7 @@ def AddDir(job, dirname, in_dir, rel_path, in_path ):
|
||||
# no in_dir occurs when we Add the actual Dir for the Path (top of the tree)
|
||||
if in_dir:
|
||||
e.in_dir=in_dir
|
||||
if DEBUG==1:
|
||||
if DEBUG:
|
||||
AddLogForJob(job, f"DEBUG: Process new dir: {dirname}, rel_path={rel_path}")
|
||||
session.add(e)
|
||||
return dir
|
||||
@@ -1113,7 +1113,7 @@ def JobImportDir(job):
|
||||
path=[jex.value for jex in job.extra if jex.name == "path"][0]
|
||||
path_type=[jex.value for jex in job.extra if jex.name == "path_type"][0]
|
||||
AddLogForJob(job, f"Checking {path_type} Directory: {path}" )
|
||||
if DEBUG==1:
|
||||
if DEBUG:
|
||||
print( f"DEBUG: Checking Directory: {path}" )
|
||||
if not os.path.exists( path ):
|
||||
FinishJob( job, f"Finished Importing: {path} -- Path does not exist", "Failed" )
|
||||
@@ -1167,7 +1167,7 @@ def JobImportDir(job):
|
||||
|
||||
stat = os.stat(fname)
|
||||
if stat.st_ctime > dir.last_import_date:
|
||||
if DEBUG==1:
|
||||
if DEBUG:
|
||||
print("DEBUG: {} - {} is newer than {}".format( basename, stat.st_ctime, dir.last_import_date ) )
|
||||
if isImage(fname):
|
||||
type_str = 'Image'
|
||||
@@ -1180,7 +1180,7 @@ def JobImportDir(job):
|
||||
year, month, day, woy = GetDateFromFile(fname, stat)
|
||||
e=AddFile( job, basename, type_str, fsize, dir, year, month, day, woy )
|
||||
else:
|
||||
if DEBUG==1:
|
||||
if DEBUG:
|
||||
print( f"DEBUG: { basename} - {stat.st_ctime} is OLDER than {dir.last_import_date}" )
|
||||
e=session.query(Entry).join(EntryDirLink).join(Dir).filter(Entry.name==basename,Dir.eid==dir.eid).first()
|
||||
e.exists_on_fs=True
|
||||
@@ -1305,7 +1305,7 @@ def GenHashAndThumb(job, e):
|
||||
session.commit()
|
||||
stat = os.stat( e.FullPathOnFS() )
|
||||
if stat.st_ctime < e.file_details.last_hash_date:
|
||||
if DEBUG==1:
|
||||
if DEBUG:
|
||||
print(f"OPTIM: GenHashAndThumb {e.name} file is older than last hash, skip this")
|
||||
job.current_file_num+=1
|
||||
return
|
||||
@@ -1325,7 +1325,7 @@ def GenHashAndThumb(job, e):
|
||||
# File, call file_func on it
|
||||
####################################################################################################################################
|
||||
def ProcessFilesInDir(job, e, file_func, count_dirs):
|
||||
if DEBUG==1:
|
||||
if DEBUG:
|
||||
print( f"DEBUG: ProcessFilesInDir: {e.FullPathOnFS()}")
|
||||
if e.type.name != 'Directory':
|
||||
file_func(job, e)
|
||||
@@ -1345,7 +1345,7 @@ def JobGetFileDetails(job):
|
||||
JobProgressState( job, "In Progress" )
|
||||
path=[jex.value for jex in job.extra if jex.name == "path"][0]
|
||||
path_prefix=[jex.value for jex in job.extra if jex.name == "path_prefix"][0]
|
||||
if DEBUG==1:
|
||||
if DEBUG:
|
||||
print("DEBUG: JobGetFileDetails for path={path_prefix}" )
|
||||
p=session.query(Path).filter(Path.path_prefix==path_prefix).first()
|
||||
job.current_file_num = 0
|
||||
|
||||
Reference in New Issue
Block a user