try job submission yet again
This commit is contained in:
parent
d16ae2178c
commit
d7f329d49f
@ -1,5 +1,5 @@
|
|||||||
//GMG0001 JOB (GCC),'C Program',
|
//GMG0001 JOB (GCC),'C Program',
|
||||||
// NOTIFY=@05054,CLASS=A,MSGCLASS=H,
|
// NOTIFY=@05054,CLASS=A,MSGCLASS=A,
|
||||||
// MSGLEVEL=(1,1),REGION=4M,TIME=1440
|
// MSGLEVEL=(1,1),REGION=4M,TIME=1440
|
||||||
//STEP1 EXEC GCCCG,INFILE='@05054.SRCLIB.C(GMG0001)'
|
//STEP1 EXEC GCCCG,INFILE='@05054.SRCLIB.C(GMG0001)'
|
||||||
//
|
//
|
||||||
@ -1,5 +1,5 @@
|
|||||||
//{NAME} JOB (GCC),'C Program',
|
//{NAME} JOB (GCC),'C Program',
|
||||||
// NOTIFY=@05054,CLASS=A,MSGCLASS=H,
|
// NOTIFY=@05054,CLASS=A,MSGCLASS=A,
|
||||||
// MSGLEVEL=(1,1),REGION=4M,TIME=1440
|
// MSGLEVEL=(1,1),REGION=4M,TIME=1440
|
||||||
//STEP1 EXEC GCCCG,INFILE='@05054.SRCLIB.C({NAME})'
|
//STEP1 EXEC GCCCG,INFILE='@05054.SRCLIB.C({NAME})'
|
||||||
//
|
//
|
||||||
@ -37,11 +37,17 @@ def find_job_number(syslog, jobname):
|
|||||||
return match.group(1)
|
return match.group(1)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def check_job_completed(syslog, jobname, job_number):
|
def check_job_ended(syslog, jobname, job_number):
|
||||||
"""Check if a job has completed printing (HASP150 message)"""
|
"""Check if a job has ended (HASP395 ENDED)"""
|
||||||
# Pattern: /12.28.03 JOB 257 $HASP150 SIMPLE2 ON PRINTER1
|
# Pattern for job ended: /18.24.41 JOB 276 $HASP395 GMG0001 ENDED
|
||||||
pattern = rf'/\d+\.\d+\.\d+\s+JOB\s+{job_number}\s+\$HASP150\s+{jobname}\s+ON\s+PRINTER'
|
ended_pattern = rf'/\d+\.\d+\.\d+\s+JOB\s+{job_number}\s+\$HASP395\s+{jobname}\s+ENDED'
|
||||||
return re.search(pattern, syslog, re.IGNORECASE) is not None
|
return re.search(ended_pattern, syslog, re.IGNORECASE) is not None
|
||||||
|
|
||||||
|
def check_job_printed(syslog, jobname, job_number):
|
||||||
|
"""Check if a job has printed output (HASP150)"""
|
||||||
|
# Pattern for job printed: /12.28.03 JOB 257 $HASP150 SIMPLE2 ON PRINTER1
|
||||||
|
printed_pattern = rf'/\d+\.\d+\.\d+\s+JOB\s+{job_number}\s+\$HASP150\s+{jobname}\s+ON\s+PRINTER'
|
||||||
|
return re.search(printed_pattern, syslog, re.IGNORECASE) is not None
|
||||||
|
|
||||||
def list_pdfs_local(local_dir):
|
def list_pdfs_local(local_dir):
|
||||||
"""List PDF files in a local directory (for mounted volumes)"""
|
"""List PDF files in a local directory (for mounted volumes)"""
|
||||||
@ -136,22 +142,39 @@ def poll_for_job(jn, to=300, poll_interval=5):
|
|||||||
return 1
|
return 1
|
||||||
|
|
||||||
# Phase 2: Wait for completion
|
# Phase 2: Wait for completion
|
||||||
print(f"Phase 2: Waiting for job completion ($HASP150)...")
|
print(f"Phase 2: Waiting for job completion ($HASP395 ENDED)...")
|
||||||
|
job_ended = False
|
||||||
|
job_printed = False
|
||||||
|
|
||||||
while time.time() - start_time < to:
|
while time.time() - start_time < to:
|
||||||
syslog = get_syslog()
|
syslog = get_syslog()
|
||||||
if not syslog:
|
if not syslog:
|
||||||
time.sleep(poll_interval)
|
time.sleep(poll_interval)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if check_job_completed(syslog, jobname_upper, job_number):
|
job_ended = check_job_ended(syslog, jobname_upper, job_number)
|
||||||
print(f"Job J{job_number} completed and printed!")
|
job_printed = check_job_printed(syslog, jobname_upper, job_number)
|
||||||
|
|
||||||
|
if job_ended:
|
||||||
|
print(f"Job J{job_number} has ended")
|
||||||
break
|
break
|
||||||
|
|
||||||
time.sleep(poll_interval)
|
time.sleep(poll_interval)
|
||||||
else:
|
|
||||||
|
if not job_ended:
|
||||||
print(f"Timeout: Job J{job_number} did not complete after {to}s")
|
print(f"Timeout: Job J{job_number} did not complete after {to}s")
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
# Check if output was printed (required for PDF retrieval)
|
||||||
|
if not job_printed:
|
||||||
|
print(f"ERROR: Job J{job_number} completed but no output was printed ($HASP150 not found)")
|
||||||
|
print(f"This usually means MSGCLASS=H (hold) was used in the JCL")
|
||||||
|
print(f"Check TSO SDSF or console for job output manually")
|
||||||
|
print(f"To fix: Change JCL to use MSGCLASS=A for automatic printing")
|
||||||
|
return 1
|
||||||
|
|
||||||
|
print(f"Job J{job_number} completed and output printed!")
|
||||||
|
|
||||||
# Phase 3: Retrieve PDF
|
# Phase 3: Retrieve PDF
|
||||||
print("Phase 3: Retrieving PDF...")
|
print("Phase 3: Retrieving PDF...")
|
||||||
# Give the PDF a moment to be written to disk
|
# Give the PDF a moment to be written to disk
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user