moved InitValidation checks to log to a Job to show errors in front-end, and moved the creation of the symlinks to the InitValidation so we can restart paweb docker container and it will recreate the symlinks in static without needing an import. Also added token highlighting of a failed job
This commit is contained in:
@@ -776,7 +776,7 @@ def JobImportDir(job):
|
|||||||
if not os.path.exists( path ):
|
if not os.path.exists( path ):
|
||||||
FinishJob( job, f"Finished Importing: {path} -- Path does not exist", "Failed" )
|
FinishJob( job, f"Finished Importing: {path} -- Path does not exist", "Failed" )
|
||||||
return
|
return
|
||||||
symlink=CreateSymlink(job,path_type,path)
|
symlink=SymlinkName(path_type.name, path, path)
|
||||||
|
|
||||||
# create/find the Path
|
# create/find the Path
|
||||||
path_obj=AddPath( job, symlink, path_type )
|
path_obj=AddPath( job, symlink, path_type )
|
||||||
@@ -1232,39 +1232,48 @@ def JobRestoreFiles(job):
|
|||||||
return
|
return
|
||||||
|
|
||||||
def InitialValidationChecks():
|
def InitialValidationChecks():
|
||||||
|
now=datetime.now(pytz.utc)
|
||||||
|
job=Job(start_time=now, last_update=now, name="init", state="New", wait_for=None, pa_job_state="New", current_file_num=0 )
|
||||||
|
session.add(job)
|
||||||
settings = session.query(Settings).first()
|
settings = session.query(Settings).first()
|
||||||
rbp_exists=0
|
rbp_exists=0
|
||||||
paths = settings.recycle_bin_path.split("#")
|
paths = settings.recycle_bin_path.split("#")
|
||||||
|
AddLogForJob(job, f"INFO: Starting Initial Validation checks...")
|
||||||
for path in paths:
|
for path in paths:
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
rbp_exists=1
|
rbp_exists=1
|
||||||
|
ptype = session.query(PathType).filter(PathType.name=='Bin').first().id
|
||||||
|
symlink=CreateSymlink(job,ptype,path)
|
||||||
path, dirs, files = next(os.walk(path))
|
path, dirs, files = next(os.walk(path))
|
||||||
if len(dirs) + len(files) > 0:
|
if len(dirs) + len(files) > 0:
|
||||||
print("INFO: the bin path contains content, cannot process to know where original deletes were form - skipping content!" )
|
AddLogForJob(job, "NFO: the bin path contains content, cannot process to know where original deletes were form - skipping content!" )
|
||||||
print("TODO: could be smart about what is known in the DB vs on the FS, and change below to an ERROR if it is one")
|
AddLogForJob(job, "ODO: could be smart about what is known in the DB vs on the FS, and change below to an ERROR if it is one")
|
||||||
print("WARNING: IF the files in the bin are in the DB (succeeded from GUI deletes) then this is okay, otherwise you should delete contents form the recycle bin and restart the job manager)" )
|
AddLogForJob(job, "ARNING: IF the files in the bin are in the DB (succeeded from GUI deletes) then this is okay, otherwise you should delete contents form the recycle bin and restart the job manager)" )
|
||||||
break
|
break
|
||||||
if not rbp_exists:
|
if not rbp_exists:
|
||||||
print("ERROR: The bin path in settings does not exist - Please fix now");
|
AddLogForJob(job, "ERROR: The bin path in settings does not exist - Please fix now");
|
||||||
sp_exists=0
|
sp_exists=0
|
||||||
paths = settings.storage_path.split("#")
|
paths = settings.storage_path.split("#")
|
||||||
for path in paths:
|
for path in paths:
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
sp_exists=1
|
sp_exists=1
|
||||||
break
|
ptype = session.query(PathType).filter(PathType.name=='Storage').first().id
|
||||||
|
symlink=CreateSymlink(job,ptype,path)
|
||||||
if not sp_exists:
|
if not sp_exists:
|
||||||
print("ERROR: None of the storage paths in the settings exist - Please fix now");
|
AddLogForJob(job, "ERROR: None of the storage paths in the settings exist - Please fix now");
|
||||||
ip_exists=0
|
ip_exists=0
|
||||||
|
paths = settings.import_path.split("#")
|
||||||
for path in paths:
|
for path in paths:
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
ip_exists=1
|
ip_exists=1
|
||||||
break
|
ptype = session.query(PathType).filter(PathType.name=='Import').first().id
|
||||||
|
symlink=CreateSymlink(job,ptype,path)
|
||||||
if not ip_exists:
|
if not ip_exists:
|
||||||
print("ERROR: None of the import paths in the settings exist - Please fix now");
|
AddLogForJob(job, "ERROR: None of the import paths in the settings exist - Please fix now");
|
||||||
paths = settings.import_path.split("#")
|
|
||||||
if not rbp_exists or not sp_exists or not ip_exists:
|
if not rbp_exists or not sp_exists or not ip_exists:
|
||||||
print("ERROR: Exiting until above errors are fixed by paths being created or settings being updated to valid paths" )
|
FinishJob(job,"ERROR: Job manager EXITing until above errors are fixed by paths being created or settings being updated to valid paths", "Failed" )
|
||||||
exit(-1)
|
exit(-1)
|
||||||
|
FinishJob(job,"Finished Initial Validation Checks")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,11 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="row col-lg-12">
|
<div class="row col-lg-12">
|
||||||
<label class="form-control-plaintext col-lg-2">Current state:</label>
|
<label class="form-control-plaintext col-lg-2">Current state:</label>
|
||||||
<label class="form-control-plaintext col-lg-10">{{job.state}}</label>
|
{% if job.state != "Complete" %}
|
||||||
|
<label class="form-control-plaintext col-lg-10" style="background-color:red">{{job.state}}</label>
|
||||||
|
{% else %}
|
||||||
|
<label class="form-control-plaintext col-lg-10">{{job.state}}</label>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
{% if job.wait_for != None %}
|
{% if job.wait_for != None %}
|
||||||
<div class="row col-lg-12">
|
<div class="row col-lg-12">
|
||||||
|
|||||||
@@ -7,7 +7,11 @@
|
|||||||
var completed_rows=Array()
|
var completed_rows=Array()
|
||||||
|
|
||||||
{% for job in jobs %}
|
{% for job in jobs %}
|
||||||
row='<tr><td><a href="{{url_for('joblog', id=job.id)}}">Job #{{job.id}} - {{job.name}}</a>'
|
{% if job.state == "Failed" %}
|
||||||
|
row='<tr><td style="background-color:red"><a href="{{url_for('joblog', id=job.id)}}">Job #{{job.id}} - {{job.name}}</a>'
|
||||||
|
{% else %}
|
||||||
|
row='<tr><td><a href="{{url_for('joblog', id=job.id)}}">Job #{{job.id}} - {{job.name}}</a>'
|
||||||
|
{% endif %}
|
||||||
{% if job.name != "rmdups" %}
|
{% if job.name != "rmdups" %}
|
||||||
{% for ex in job.extra %}
|
{% for ex in job.extra %}
|
||||||
{% if 'path' == ex.name or ('path_prefix'==ex.name and job.name == 'checkdups') %}
|
{% if 'path' == ex.name or ('path_prefix'==ex.name and job.name == 'checkdups') %}
|
||||||
|
|||||||
Reference in New Issue
Block a user