-
Notifications
You must be signed in to change notification settings - Fork 19
/
QSHPYCALLC.CLLE
468 lines (431 loc) · 24.5 KB
/
QSHPYCALLC.CLLE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
PGM PARM(&PYSCRDIR &SCRIPTFILE &ARGS &PYVERSION +
&PYPATH &SETPKGPATH &USEVENV &VENVPATH +
&DSPSTDOUT &LOGSTDOUT &PRTSTDOUT +
&DLTSTDOUT &IFSSTDOUT &IFSFILE &IFSOPT +
&CCSID &PRTSPLF &PRTUSRDTA &PRTTXT +
&PRTHOLD &PRTOUTQALL &OUTFILE &MBROPT +
&PASEJOBNAM &DEBUGCMD &CHGSCRDIR +
&RETURN01 &RETURN02 &RETURN03 &RETURN04 +
&RETURN05 &RETURN06 &RETURN07 &RETURN08 +
&RETURN09 &RETURN10)
DCL VAR(&RETURN01) TYPE(*CHAR) LEN(255)
DCL VAR(&RETURN02) TYPE(*CHAR) LEN(255)
DCL VAR(&RETURN03) TYPE(*CHAR) LEN(255)
DCL VAR(&RETURN04) TYPE(*CHAR) LEN(255)
DCL VAR(&RETURN05) TYPE(*CHAR) LEN(255)
DCL VAR(&RETURN06) TYPE(*CHAR) LEN(255)
DCL VAR(&RETURN07) TYPE(*CHAR) LEN(255)
DCL VAR(&RETURN08) TYPE(*CHAR) LEN(255)
DCL VAR(&RETURN09) TYPE(*CHAR) LEN(255)
DCL VAR(&RETURN10) TYPE(*CHAR) LEN(255)
DCL VAR(&PASEJOBNAM) TYPE(*CHAR) LEN(10)
DCL VAR(&CHGSCRDIR) TYPE(*CHAR) LEN(4) /* 1.0.20 */
DCL VAR(&CHGDIRCMD) TYPE(*CHAR) LEN(255) /* 1.0.20 */
DCL VAR(&DEBUGCMD) TYPE(*CHAR) LEN(4)
DCL VAR(&USEVENV) TYPE(*CHAR) LEN(4)
DCL VAR(&VENVPATH) TYPE(*CHAR) LEN(255)
DCL VAR(&VENVACT) TYPE(*CHAR) LEN(300)
DCL VAR(&VENVDEACT) TYPE(*CHAR) LEN(300)
DCL VAR(&MBROPT) TYPE(*CHAR) LEN(10)
DCL VAR(&OUTFILE) TYPE(*CHAR) LEN(20)
DCL VAR(&OUTFILPATH) TYPE(*CHAR) LEN(255)
DCL VAR(&OFILE) TYPE(*CHAR) LEN(10)
DCL VAR(&OLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&PRTHOLD) TYPE(*CHAR) LEN(4)
DCL VAR(&PRTOUTQALL) TYPE(*CHAR) LEN(20)
DCL VAR(&PRTOUTQ) TYPE(*CHAR) LEN(10)
DCL VAR(&PRTOUTQLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&SETPKGPATH) TYPE(*CHAR) LEN(4)
DCL VAR(&CCSID) TYPE(*CHAR) LEN(10)
DCL VAR(&PYSCRDIR) TYPE(*CHAR) LEN(255)
DCL VAR(&PYPATH) TYPE(*CHAR) LEN(255)
DCL VAR(&PYEXE) TYPE(*CHAR) LEN(100)
DCL VAR(&PYVERSION) TYPE(*CHAR) LEN(5)
DCL VAR(&SCRIPTFILE) TYPE(*CHAR) LEN(255)
DCL VAR(&SCRIPTFULL) TYPE(*CHAR) LEN(255) /* 1.0.20 */
DCL VAR(&SCRIPTSTR) TYPE(*CHAR) LEN(1)
DCL VAR(&ARGS) TYPE(*CHAR) LEN(8002)
DCL VAR(&ARGS2) TYPE(*CHAR) LEN(8000)
DCL VAR(&CT) TYPE(*DEC) STG(*AUTO) LEN(3 0)
DCL VAR(&PRTTEXT) TYPE(*CHAR) LEN(30) +
VALUE('Python Script Stdout')
DCL VAR(&APPDIR) TYPE(*CHAR) LEN(255)
DCL VAR(&CMD) TYPE(*CHAR) LEN(5000)
DCL VAR(&STDOUTFILE) TYPE(*CHAR) LEN(255)
DCL VAR(&STDOUTIFS) TYPE(*CHAR) LEN(255)
DCL VAR(&QDATE) TYPE(*CHAR) LEN(6)
DCL VAR(&QTIME) TYPE(*CHAR) LEN(9)
DCL VAR(&JOB) TYPE(*CHAR) LEN(10)
DCL VAR(&USER) TYPE(*CHAR) LEN(10)
DCL VAR(&JOBNBR) TYPE(*CHAR) LEN(6)
DCL VAR(&TEMPDIR) TYPE(*CHAR) LEN(255) +
VALUE('/tmp')
DCL VAR(&PYTEMP) TYPE(*CHAR) LEN(255) +
VALUE('/tmp/qsh')
DCL VAR(&QSHRTN) TYPE(*DEC) LEN(5 0)
DCL VAR(&QSHRTNC) TYPE(*CHAR) LEN(5)
DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(200)
DCL VAR(&MSGDTA4) TYPE(*CHAR) LEN(4)
DCL VAR(&CPFID) TYPE(*CHAR) LEN(7)
DCL VAR(&DSPSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&DLTSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&LOGSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&PRTSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&PRTSPLF) TYPE(*CHAR) LEN(10)
DCL VAR(&PRTUSRDTA) TYPE(*CHAR) LEN(10)
DCL VAR(&PRTTXT) TYPE(*CHAR) LEN(30)
DCL VAR(&IFSSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&IFSOPT) TYPE(*CHAR) LEN(10)
DCL VAR(&IFSFILE) TYPE(*CHAR) LEN(255)
DCL VAR(&PYPATHSEP) TYPE(*CHAR) LEN(1) VALUE(' ') /* 1.0.19 */
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERRORS))
/*----------------------------------------------------------------------------*/
/* Init return parm values */
/*----------------------------------------------------------------------------*/
CHGVAR VAR(&RETURN01) VALUE(' ')
CHGVAR VAR(&RETURN02) VALUE(' ')
CHGVAR VAR(&RETURN03) VALUE(' ')
CHGVAR VAR(&RETURN04) VALUE(' ')
CHGVAR VAR(&RETURN05) VALUE(' ')
CHGVAR VAR(&RETURN06) VALUE(' ')
CHGVAR VAR(&RETURN07) VALUE(' ')
CHGVAR VAR(&RETURN08) VALUE(' ')
CHGVAR VAR(&RETURN09) VALUE(' ')
CHGVAR VAR(&RETURN10) VALUE(' ')
/*----------------------------------------------------------------------------*/
/* Extract output queue info. */
/*----------------------------------------------------------------------------*/
CHGVAR VAR(&PRTOUTQ) VALUE(%SST(&PRTOUTQALL 1 10))
CHGVAR VAR(&PRTOUTQLIB) VALUE(%SST(&PRTOUTQALL 11 10))
/*----------------------------------------------------------------------------*/
/* Extract output file info. Added V1.0.16 */
/*----------------------------------------------------------------------------*/
CHGVAR VAR(&OFILE) VALUE(%SST(&OUTFILE 1 10))
CHGVAR VAR(&OLIB) VALUE(%SST(&OUTFILE 11 10))
/*----------------------------------------------------------------------------*/
/* Set virtual env activate and deactivate commands if using venv */
/*----------------------------------------------------------------------------*/
/* Set the activate and deactivate command line values */
IF COND(&USEVENV *EQ *YES) THEN(DO)
CHGVAR VAR(&VENVACT) VALUE('source' |> &VENVPATH |< +
'/bin/activate;')
CHGVAR VAR(&VENVDEACT) VALUE(';deactivate')
/* If env path blank, bail out */
IF COND(&VENVPATH *EQ ' ') THEN(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Virtual +
environment base path cannot be blank') +
MSGTYPE(*ESCAPE)
ENDDO
/* Make sure venv exists */
QSHIFSCHK FILNAM(&VENVPATH)
/* EXISTS, DO NOTHING SPECIAL */
MONMSG MSGID(CPF9897) EXEC(DO)
ENDDO
/* VENV PATH NOT FOUND. BAIL OUT */
MONMSG MSGID(CPF9898) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) +
MSGDTA('Virtual environment base path' +
|> &VENVPATH |> 'not found') +
MSGTYPE(*ESCAPE)
ENDDO
/* Log environment name in the joblog */
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('VENV: Using +
Python virtual environment' |> &VENVPATH) +
TOPGMQ(*SAME) MSGTYPE(*DIAG)
ENDDO
/*----------------------------------------------------------------------------*/
/* If default python path data area, retreive from data area */
/*----------------------------------------------------------------------------*/
IF COND(&PYPATH *EQ *DEFAULT) THEN(DO)
RTVDTAARA DTAARA(QSHONI/PYPATH *ALL) RTNVAR(&PYPATH)
ENDDO
/*----------------------------------------------------------------------------*/
/* If PYPATH <> ' ', add path separator because we will prefix Python command */
/* Otherwise we don't need a path separator because we will call Python */
/* without a path qualifier. V1.0.19 */
/*----------------------------------------------------------------------------*/
IF COND(&PYPATH *NE ' ') THEN(DO)
CHGVAR VAR(&PYPATHSEP) VALUE('/')
ENDDO
/*----------------------------------------------------------------------------*/
/* Parse command line parms - up to 40 cmd line args */
/*----------------------------------------------------------------------------*/
CHGVAR VAR(&CT) VALUE(%BINARY(&ARGS 1 2))
IF COND(&CT > 0) THEN(CHGVAR VAR(&ARGS2) +
VALUE('"' |< %SST(&ARGS 3 200) |< '"'))
IF COND(&CT > 1) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 203 +
200) |< '"'))
IF COND(&CT > 2) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 403 +
200) |< '"'))
IF COND(&CT > 3) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 603 +
200) |< '"'))
IF COND(&CT > 4) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 803 +
200) |< '"'))
IF COND(&CT > 5) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 1003 +
200) |< '"'))
IF COND(&CT > 6) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 1203 +
200) |< '"'))
IF COND(&CT > 7) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 1403 +
200) |< '"'))
IF COND(&CT > 8) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 1603 +
200) |< '"'))
IF COND(&CT > 9) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 1803 +
200) |< '"'))
IF COND(&CT > 10) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 2003 +
200) |< '"'))
IF COND(&CT > 11) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 2203 +
200) |< '"'))
IF COND(&CT > 12) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 2403 +
200) |< '"'))
IF COND(&CT > 13) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 2603 +
200) |< '"'))
IF COND(&CT > 14) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 2803 +
200) |< '"'))
IF COND(&CT > 15) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 3003 +
200) |< '"'))
IF COND(&CT > 16) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 3203 +
200) |< '"'))
IF COND(&CT > 17) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 3403 +
200) |< '"'))
IF COND(&CT > 18) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 3603 +
200) |< '"'))
IF COND(&CT > 19) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 3803 +
200) |< '"'))
IF COND(&CT > 20) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 4003 +
200) |< '"'))
IF COND(&CT > 21) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 4203 +
200) |< '"'))
IF COND(&CT > 22) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 4403 +
200) |< '"'))
IF COND(&CT > 23) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 4603 +
200) |< '"'))
IF COND(&CT > 24) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 4803 +
200) |< '"'))
IF COND(&CT > 25) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 5003 +
200) |< '"'))
IF COND(&CT > 26) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 5203 +
200) |< '"'))
IF COND(&CT > 27) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 5403 +
200) |< '"'))
IF COND(&CT > 28) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 5603 +
200) |< '"'))
IF COND(&CT > 29) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 5803 +
200) |< '"'))
IF COND(&CT > 30) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 6003 +
200) |< '"'))
IF COND(&CT > 31) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 6203 +
200) |< '"'))
IF COND(&CT > 32) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 6403 +
200) |< '"'))
IF COND(&CT > 33) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 6603 +
200) |< '"'))
IF COND(&CT > 34) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 6803 +
200) |< '"'))
IF COND(&CT > 35) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 7003 +
200) |< '"'))
IF COND(&CT > 36) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 7203 +
200) |< '"'))
IF COND(&CT > 37) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 7403 +
200) |< '"'))
IF COND(&CT > 38) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 7603 +
200) |< '"'))
IF COND(&CT > 39) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 7803 +
200) |< '"'))
/*----------------------------------------------------------------------------*/
/* Set python executable */
/* Added PYPATHSEP - V1.0.19 */
/*----------------------------------------------------------------------------*/
IF COND(&PYVERSION *EQ '2') THEN(CHGVAR +
VAR(&PYEXE) VALUE(&PYPATH |< &PYPATHSEP |< 'python2'))
IF COND(&PYVERSION *EQ '2.7') THEN(CHGVAR +
VAR(&PYEXE) VALUE(&PYPATH |< &PYPATHSEP |< 'python2.7'))
IF COND(&PYVERSION *EQ '3') THEN(CHGVAR +
VAR(&PYEXE) VALUE(&PYPATH |< &PYPATHSEP |< 'python3'))
IF COND(&PYVERSION *EQ '3.6') THEN(CHGVAR +
VAR(&PYEXE) VALUE(&PYPATH |< &PYPATHSEP |< 'python3.6'))
IF COND(&PYVERSION *EQ '3.9') THEN(CHGVAR +
VAR(&PYEXE) VALUE(&PYPATH |< &PYPATHSEP |< 'python3.9'))
/* Catch all set to python3 if blank or invalid version passed */
IF COND(&PYEXE *EQ ' ') THEN(CHGVAR +
VAR(&PYEXE) VALUE(&PYPATH |< &PYPATHSEP |< 'python3'))
/*----------------------------------------------------------------------------*/
/* Make sure QSHONITMP library and IFS directory created */
/*----------------------------------------------------------------------------*/
CHKOBJ OBJ(QSHONITMP) OBJTYPE(*LIB)
MONMSG MSGID(CPF9801) EXEC(DO)
CRTLIB LIB(QSHONITMP) TEXT('Qshoni Temp File +
Library') AUT(*ALL)
ENDDO
/*----------------------------------------------------------------------------*/
/* Make sure /tmp folder exists */
/*----------------------------------------------------------------------------*/
QSHIFSCHK FILNAM(&TEMPDIR)
/* EXISTS, DO NOTHING SPECIAL */
MONMSG MSGID(CPF9897) EXEC(DO)
ENDDO
/* DOES NOT EXIST. BAIL OUT */
MONMSG MSGID(CPF9898) EXEC(DO)
MKDIR DIR(&TEMPDIR) DTAAUT(*RWX) OBJAUT(*ALL)
ENDDO
/*----------------------------------------------------------------------------*/
/* Make sure /tmp/qsh exist for logs */
/*----------------------------------------------------------------------------*/
QSHIFSCHK FILNAM(&PYTEMP)
/* EXISTS, DO NOTHING SPECIAL */
MONMSG MSGID(CPF9897) EXEC(DO)
ENDDO
/* DOES NOT EXIST. BAIL OUT */
MONMSG MSGID(CPF9898) EXEC(DO)
MKDIR DIR(&PYTEMP) DTAAUT(*RWX) OBJAUT(*ALL)
ENDDO
/*----------------------------------------------------------------------------*/
/* Retreive system values for job */
/*----------------------------------------------------------------------------*/
RTVSYSVAL SYSVAL(QDATE) RTNVAR(&QDATE)
RTVSYSVAL SYSVAL(QTIME) RTNVAR(&QTIME)
RTVJOBA JOB(&JOB) USER(&USER) NBR(&JOBNBR)
/* Get first char of script file to check for / */
/* If path starts with slash do not use dtaara */
CHGVAR VAR(&SCRIPTSTR) VALUE(%SST(&SCRIPTFILE 1 1))
/* If cur py dir set and script file has no slash / */
/* concatenate py dir with script file name */
IF COND(&PYSCRDIR *NE ' ' *AND &SCRIPTSTR *NE +
'/') THEN(DO)
/* Build full path to script for existence check */
CHGVAR VAR(&SCRIPTFULL) VALUE(&PYSCRDIR |< '/' +
|< &SCRIPTFILE)
/* Qualify script dir if not changing directory to script dir */
IF COND(&CHGSCRDIR *NE *YES) THEN(DO)
CHGVAR VAR(&SCRIPTFILE) VALUE(&PYSCRDIR |< '/' +
|< &SCRIPTFILE)
ENDDO
/* Don't qualify script file dir if changing directory to script dir */
/* because we will be in the correct directory already. */
IF COND(&CHGSCRDIR *EQ *YES) THEN(DO)
CHGVAR VAR(&SCRIPTFILE) VALUE(&SCRIPTFILE)
ENDDO
ENDDO
/*----------------------------------------------------------------------------*/
/* Make sure python script exists */
/*----------------------------------------------------------------------------*/
QSHIFSCHK FILNAM(&SCRIPTFULL)
/* EXISTS, DO NOTHING SPECIAL */
MONMSG MSGID(CPF9897) EXEC(DO)
ENDDO
/* DOES NOT EXIST. BAIL OUT */
MONMSG MSGID(CPF9898) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Python +
script file' |> &SCRIPTFULL |> 'does not +
exist') MSGTYPE(*ESCAPE)
ENDDO
/*----------------------------------------------------------------------------*/
/* Append change directory command to python script file if needed */
/*----------------------------------------------------------------------------*/
IF COND(&CHGSCRDIR *NE *YES) THEN(DO)
CHGVAR VAR(&CHGDIRCMD) VALUE(' ')
ENDDO
IF COND(&CHGSCRDIR *EQ *YES) THEN(DO)
CHGVAR VAR(&CHGDIRCMD) VALUE('cd' |> &PYSCRDIR |< ';')
ENDDO
/*----------------------------------------------------------------------------*/
/* Build python command call with parms for venv is *YES */
/*----------------------------------------------------------------------------*/
IF COND(&USEVENV *NE *YES) THEN(DO)
CHGVAR VAR(&CMD) VALUE(&CHGDIRCMD |< &PYEXE |> &SCRIPTFILE |> +
&ARGS2)
ENDDO
IF COND(&USEVENV *EQ *YES) THEN(DO)
CHGVAR VAR(&CMD) VALUE(&VENVACT |< &CHGDIRCMD |< &PYEXE |> &SCRIPTFILE |> +
&ARGS2 |< &VENVDEACT)
ENDDO
/*----------------------------------------------------------------------------*/
/* Call QSHEXEC command to run python script via Qshell */
/*----------------------------------------------------------------------------*/
IF COND(&DEBUGCMD *EQ *YES) THEN(DO)
? QSHONI/QSHEXEC CMDLINE(&CMD) SETPKGPATH(&SETPKGPATH) +
DSPSTDOUT(&DSPSTDOUT) +
LOGSTDOUT(&LOGSTDOUT) +
PRTSTDOUT(&PRTSTDOUT) +
DLTSTDOUT(&DLTSTDOUT) +
IFSSTDOUT(&IFSSTDOUT) IFSFILE(&IFSFILE) +
IFSOPT(&IFSOPT) CCSID(&CCSID) +
PRTSPLF(&PRTSPLF) PRTUSRDTA(&PRTUSRDTA) +
PRTTXT(&PRTTXT) PRTHOLD(&PRTHOLD) +
PRTOUTQ(&PRTOUTQLIB/&PRTOUTQ) +
OUTFILE(&OLIB/&OFILE) MBROPT(&MBROPT) +
PASEJOBNAM(&PASEJOBNAM)
ENDDO
IF COND(&DEBUGCMD *NE *YES) THEN(DO)
QSHONI/QSHEXEC CMDLINE(&CMD) SETPKGPATH(&SETPKGPATH) +
DSPSTDOUT(&DSPSTDOUT) +
LOGSTDOUT(&LOGSTDOUT) +
PRTSTDOUT(&PRTSTDOUT) +
DLTSTDOUT(&DLTSTDOUT) +
IFSSTDOUT(&IFSSTDOUT) IFSFILE(&IFSFILE) +
IFSOPT(&IFSOPT) CCSID(&CCSID) +
PRTSPLF(&PRTSPLF) PRTUSRDTA(&PRTUSRDTA) +
PRTTXT(&PRTTXT) PRTHOLD(&PRTHOLD) +
PRTOUTQ(&PRTOUTQLIB/&PRTOUTQ) +
OUTFILE(&OLIB/&OFILE) MBROPT(&MBROPT) +
PASEJOBNAM(&PASEJOBNAM)
ENDDO
/*----------------------------------------------------------------------------*/
/* Extract return parameter values from STDOUTQSH log file */
/*----------------------------------------------------------------------------*/
QSHGETPARM RETURN01(&RETURN01) RETURN02(&RETURN02) +
RETURN03(&RETURN03) RETURN04(&RETURN04) +
RETURN05(&RETURN05) RETURN06(&RETURN06) +
RETURN07(&RETURN07) RETURN08(&RETURN08) +
RETURN09(&RETURN09) RETURN10(&RETURN10)
NORMAL:
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Python +
script' |> &SCRIPTFULL |> 'completed +
successfully with no errors') MSGTYPE(*COMP)
RETURN
/*----------------------------------------------------------------------------*/
/* Handle Errors */
/*----------------------------------------------------------------------------*/
ERRORS:
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('Python +
script' |> &SCRIPTFULL |> 'failed. See +
the joblog or stdout log') MSGTYPE(*ESCAPE)
ENDPGM