0000: 23 21 2f 75 73 72 2f 62 69 6e 2f 65 6e 76 20 40 #!/usr/bin/env @
0010: 50 59 43 4d 44 40 0a 23 20 2d 2a 2d 20 63 6f 64 PYCMD@.# -*- cod
0020: 69 6e 67 3a 20 75 74 66 2d 38 20 2d 2a 2d 0a 23 ing: utf-8 -*-.#
0030: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0040: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0050: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0060: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0070: 23 23 23 23 23 23 23 0a 23 20 73 69 6d 68 2d 6f #######.# simh-o
0080: 73 38 2d 73 63 72 69 70 74 2e 70 79 20 4c 69 62 s8-script.py Lib
0090: 72 61 72 79 20 66 6f 72 20 73 63 72 69 70 74 69 rary for scripti
00a0: 6e 67 20 4f 53 2f 38 20 75 6e 64 65 72 20 53 49 ng OS/8 under SI
00b0: 4d 48 0a 23 20 43 6f 6e 74 61 69 6e 73 20 76 61 MH.# Contains va
00c0: 6c 69 64 61 74 6f 72 73 20 61 6e 64 20 63 61 6c lidators and cal
00d0: 6c 65 72 73 20 66 6f 72 20 6f 73 38 20 61 6e 64 lers for os8 and
00e0: 20 73 69 6d 68 20 63 6f 6d 6d 61 6e 64 73 20 74 simh commands t
00f0: 6f 20 6d 61 6b 65 0a 23 20 69 74 20 65 61 73 69 o make.# it easi
0100: 65 72 20 74 6f 20 63 72 65 61 74 65 20 73 63 72 er to create scr
0110: 69 70 74 73 2e 0a 23 0a 23 20 43 6f 70 79 72 69 ipts..#.# Copyri
0120: 67 68 74 20 c2 a9 20 32 30 31 37 2d 32 30 31 39 ght © 2017-2019
0130: 20 62 79 20 4a 6f 6e 61 74 68 61 6e 20 54 72 69 by Jonathan Tri
0140: 74 65 73 2c 20 57 69 6c 6c 69 61 6d 20 43 61 74 tes, William Cat
0150: 74 65 79 2c 20 61 6e 64 0a 23 20 57 61 72 72 65 tey, and.# Warre
0160: 6e 20 59 6f 75 6e 67 2e 0a 23 0a 23 20 50 65 72 n Young..#.# Per
0170: 6d 69 73 73 69 6f 6e 20 69 73 20 68 65 72 65 62 mission is hereb
0180: 79 20 67 72 61 6e 74 65 64 2c 20 66 72 65 65 20 y granted, free
0190: 6f 66 20 63 68 61 72 67 65 2c 20 74 6f 20 61 6e of charge, to an
01a0: 79 20 70 65 72 73 6f 6e 20 6f 62 74 61 69 6e 69 y person obtaini
01b0: 6e 67 0a 23 20 61 20 63 6f 70 79 20 6f 66 20 74 ng.# a copy of t
01c0: 68 69 73 20 73 6f 66 74 77 61 72 65 20 61 6e 64 his software and
01d0: 20 61 73 73 6f 63 69 61 74 65 64 20 64 6f 63 75 associated docu
01e0: 6d 65 6e 74 61 74 69 6f 6e 20 66 69 6c 65 73 20 mentation files
01f0: 28 74 68 65 0a 23 20 22 53 6f 66 74 77 61 72 65 (the.# "Software
0200: 22 29 2c 20 74 6f 20 64 65 61 6c 20 69 6e 20 74 "), to deal in t
0210: 68 65 20 53 6f 66 74 77 61 72 65 20 77 69 74 68 he Software with
0220: 6f 75 74 20 72 65 73 74 72 69 63 74 69 6f 6e 2c out restriction,
0230: 20 69 6e 63 6c 75 64 69 6e 67 0a 23 20 77 69 74 including.# wit
0240: 68 6f 75 74 20 6c 69 6d 69 74 61 74 69 6f 6e 20 hout limitation
0250: 74 68 65 20 72 69 67 68 74 73 20 74 6f 20 75 73 the rights to us
0260: 65 2c 20 63 6f 70 79 2c 20 6d 6f 64 69 66 79 2c e, copy, modify,
0270: 20 6d 65 72 67 65 2c 20 70 75 62 6c 69 73 68 2c merge, publish,
0280: 0a 23 20 64 69 73 74 72 69 62 75 74 65 2c 20 73 .# distribute, s
0290: 75 62 6c 69 63 65 6e 73 65 2c 20 61 6e 64 2f 6f ublicense, and/o
02a0: 72 20 73 65 6c 6c 20 63 6f 70 69 65 73 20 6f 66 r sell copies of
02b0: 20 74 68 65 20 53 6f 66 74 77 61 72 65 2c 20 61 the Software, a
02c0: 6e 64 20 74 6f 0a 23 20 70 65 72 6d 69 74 20 70 nd to.# permit p
02d0: 65 72 73 6f 6e 73 20 74 6f 20 77 68 6f 6d 20 74 ersons to whom t
02e0: 68 65 20 53 6f 66 74 77 61 72 65 20 69 73 20 66 he Software is f
02f0: 75 72 6e 69 73 68 65 64 20 74 6f 20 64 6f 20 73 urnished to do s
0300: 6f 2c 20 73 75 62 6a 65 63 74 20 74 6f 0a 23 20 o, subject to.#
0310: 74 68 65 20 66 6f 6c 6c 6f 77 69 6e 67 20 63 6f the following co
0320: 6e 64 69 74 69 6f 6e 73 3a 0a 23 0a 23 20 54 68 nditions:.#.# Th
0330: 65 20 61 62 6f 76 65 20 63 6f 70 79 72 69 67 68 e above copyrigh
0340: 74 20 6e 6f 74 69 63 65 20 61 6e 64 20 74 68 69 t notice and thi
0350: 73 20 70 65 72 6d 69 73 73 69 6f 6e 20 6e 6f 74 s permission not
0360: 69 63 65 20 73 68 61 6c 6c 20 62 65 0a 23 20 69 ice shall be.# i
0370: 6e 63 6c 75 64 65 64 20 69 6e 20 61 6c 6c 20 63 ncluded in all c
0380: 6f 70 69 65 73 20 6f 72 20 73 75 62 73 74 61 6e opies or substan
0390: 74 69 61 6c 20 70 6f 72 74 69 6f 6e 73 20 6f 66 tial portions of
03a0: 20 74 68 65 20 53 6f 66 74 77 61 72 65 2e 0a 23 the Software..#
03b0: 0a 23 20 54 48 45 20 53 4f 46 54 57 41 52 45 20 .# THE SOFTWARE
03c0: 49 53 20 50 52 4f 56 49 44 45 44 20 22 41 53 20 IS PROVIDED "AS
03d0: 49 53 22 2c 20 57 49 54 48 4f 55 54 20 57 41 52 IS", WITHOUT WAR
03e0: 52 41 4e 54 59 20 4f 46 20 41 4e 59 20 4b 49 4e RANTY OF ANY KIN
03f0: 44 2c 0a 23 20 45 58 50 52 45 53 53 20 4f 52 20 D,.# EXPRESS OR
0400: 49 4d 50 4c 49 45 44 2c 20 49 4e 43 4c 55 44 49 IMPLIED, INCLUDI
0410: 4e 47 20 42 55 54 20 4e 4f 54 20 4c 49 4d 49 54 NG BUT NOT LIMIT
0420: 45 44 20 54 4f 20 54 48 45 20 57 41 52 52 41 4e ED TO THE WARRAN
0430: 54 49 45 53 20 4f 46 0a 23 20 4d 45 52 43 48 41 TIES OF.# MERCHA
0440: 4e 54 41 42 49 4c 49 54 59 2c 20 46 49 54 4e 45 NTABILITY, FITNE
0450: 53 53 20 46 4f 52 20 41 20 50 41 52 54 49 43 55 SS FOR A PARTICU
0460: 4c 41 52 20 50 55 52 50 4f 53 45 20 41 4e 44 20 LAR PURPOSE AND
0470: 4e 4f 4e 49 4e 46 52 49 4e 47 45 4d 45 4e 54 2e NONINFRINGEMENT.
0480: 0a 23 20 49 4e 20 4e 4f 20 45 56 45 4e 54 20 53 .# IN NO EVENT S
0490: 48 41 4c 4c 20 54 48 45 20 41 55 54 48 4f 52 53 HALL THE AUTHORS
04a0: 20 4c 49 53 54 45 44 20 41 42 4f 56 45 20 42 45 LISTED ABOVE BE
04b0: 20 4c 49 41 42 4c 45 20 46 4f 52 20 41 4e 59 20 LIABLE FOR ANY
04c0: 43 4c 41 49 4d 2c 0a 23 20 44 41 4d 41 47 45 53 CLAIM,.# DAMAGES
04d0: 20 4f 52 20 4f 54 48 45 52 20 4c 49 41 42 49 4c OR OTHER LIABIL
04e0: 49 54 59 2c 20 57 48 45 54 48 45 52 20 49 4e 20 ITY, WHETHER IN
04f0: 41 4e 20 41 43 54 49 4f 4e 20 4f 46 20 43 4f 4e AN ACTION OF CON
0500: 54 52 41 43 54 2c 20 54 4f 52 54 0a 23 20 4f 52 TRACT, TORT.# OR
0510: 20 4f 54 48 45 52 57 49 53 45 2c 20 41 52 49 53 OTHERWISE, ARIS
0520: 49 4e 47 20 46 52 4f 4d 2c 20 4f 55 54 20 4f 46 ING FROM, OUT OF
0530: 20 4f 52 20 49 4e 20 43 4f 4e 4e 45 43 54 49 4f OR IN CONNECTIO
0540: 4e 20 57 49 54 48 20 54 48 45 20 53 4f 46 54 57 N WITH THE SOFTW
0550: 41 52 45 0a 23 20 4f 52 20 54 48 45 20 55 53 45 ARE.# OR THE USE
0560: 20 4f 52 20 4f 54 48 45 52 20 44 45 41 4c 49 4e OR OTHER DEALIN
0570: 47 53 20 49 4e 20 54 48 45 20 53 4f 46 54 57 41 GS IN THE SOFTWA
0580: 52 45 2e 0a 23 0a 23 20 45 78 63 65 70 74 20 61 RE..#.# Except a
0590: 73 20 63 6f 6e 74 61 69 6e 65 64 20 69 6e 20 74 s contained in t
05a0: 68 69 73 20 6e 6f 74 69 63 65 2c 20 74 68 65 20 his notice, the
05b0: 6e 61 6d 65 73 20 6f 66 20 74 68 65 20 61 75 74 names of the aut
05c0: 68 6f 72 73 20 61 62 6f 76 65 0a 23 20 73 68 61 hors above.# sha
05d0: 6c 6c 20 6e 6f 74 20 62 65 20 75 73 65 64 20 69 ll not be used i
05e0: 6e 20 61 64 76 65 72 74 69 73 69 6e 67 20 6f 72 n advertising or
05f0: 20 6f 74 68 65 72 77 69 73 65 20 74 6f 20 70 72 otherwise to pr
0600: 6f 6d 6f 74 65 20 74 68 65 20 73 61 6c 65 2c 0a omote the sale,.
0610: 23 20 75 73 65 20 6f 72 20 6f 74 68 65 72 20 64 # use or other d
0620: 65 61 6c 69 6e 67 73 20 69 6e 20 74 68 69 73 20 ealings in this
0630: 53 6f 66 74 77 61 72 65 20 77 69 74 68 6f 75 74 Software without
0640: 20 70 72 69 6f 72 20 77 72 69 74 74 65 6e 0a 23 prior written.#
0650: 20 61 75 74 68 6f 72 69 7a 61 74 69 6f 6e 20 66 authorization f
0660: 72 6f 6d 20 74 68 6f 73 65 20 61 75 74 68 6f 72 rom those author
0670: 73 2e 0a 23 23 23 23 23 23 23 23 23 23 23 23 23 s..#############
0680: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0690: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
06a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
06b0: 23 23 23 23 23 23 23 23 23 23 23 0a 0a 23 20 42 ###########..# B
06c0: 72 69 6e 67 20 69 6e 20 6a 75 73 74 20 74 68 65 ring in just the
06d0: 20 62 61 73 69 63 73 20 73 6f 20 77 65 20 63 61 basics so we ca
06e0: 6e 20 62 72 69 6e 67 20 69 6e 20 6f 75 72 20 6c n bring in our l
06f0: 6f 63 61 6c 20 6d 6f 64 75 6c 65 73 0a 69 6d 70 ocal modules.imp
0700: 6f 72 74 20 6f 73 0a 69 6d 70 6f 72 74 20 73 79 ort os.import sy
0710: 73 0a 69 6d 70 6f 72 74 20 74 65 6d 70 66 69 6c s.import tempfil
0720: 65 0a 69 6d 70 6f 72 74 20 74 69 6d 65 0a 73 79 e.import time.sy
0730: 73 2e 70 61 74 68 2e 69 6e 73 65 72 74 20 28 30 s.path.insert (0
0740: 2c 20 6f 73 2e 70 61 74 68 2e 64 69 72 6e 61 6d , os.path.dirnam
0750: 65 20 28 5f 5f 66 69 6c 65 5f 5f 29 20 2b 20 27 e (__file__) + '
0760: 2f 2e 2e 2f 6c 69 62 27 29 0a 73 79 73 2e 70 61 /../lib').sys.pa
0770: 74 68 2e 69 6e 73 65 72 74 20 28 30 2c 20 6f 73 th.insert (0, os
0780: 2e 67 65 74 63 77 64 20 28 29 20 2b 20 27 2f 6c .getcwd () + '/l
0790: 69 62 27 29 0a 0a 23 20 50 79 74 68 6f 6e 20 63 ib')..# Python c
07a0: 6f 72 65 20 6d 6f 64 75 6c 65 73 20 77 65 20 75 ore modules we u
07b0: 73 65 0a 69 6d 70 6f 72 74 20 72 65 0a 66 72 6f se.import re.fro
07c0: 6d 20 73 74 72 69 6e 67 20 69 6d 70 6f 72 74 20 m string import
07d0: 54 65 6d 70 6c 61 74 65 0a 69 6d 70 6f 72 74 20 Template.import
07e0: 73 68 75 74 69 6c 0a 69 6d 70 6f 72 74 20 73 75 shutil.import su
07f0: 62 70 72 6f 63 65 73 73 0a 0a 23 20 4f 75 72 20 bprocess..# Our
0800: 6c 6f 63 61 6c 20 6d 6f 64 75 6c 65 73 0a 66 72 local modules.fr
0810: 6f 6d 20 70 69 64 70 38 69 20 69 6d 70 6f 72 74 om pidp8i import
0820: 20 2a 0a 66 72 6f 6d 20 73 69 6d 68 20 69 6d 70 *.from simh imp
0830: 6f 72 74 20 2a 0a 0a 23 20 53 63 72 69 70 74 20 ort *..# Script
0840: 4c 61 6e 67 75 61 67 65 20 56 65 72 73 69 6f 6e Language Version
0850: 0a 23 20 55 70 64 61 74 65 20 74 68 69 73 20 76 .# Update this v
0860: 65 72 73 69 6f 6e 20 6e 75 6d 62 65 72 20 61 73 ersion number as
0870: 20 74 68 65 20 6c 61 6e 67 75 61 67 65 20 65 76 the language ev
0880: 6f 6c 76 65 73 2e 0a 23 20 56 65 72 73 69 6f 6e olves..# Version
0890: 20 31 2e 30 20 69 73 20 74 68 65 20 66 69 72 73 1.0 is the firs
08a0: 74 20 70 75 62 6c 69 63 20 76 65 72 73 69 6f 6e t public version
08b0: 2e 0a 4c 41 4e 47 5f 56 45 52 53 49 4f 4e 20 3d ..LANG_VERSION =
08c0: 20 22 31 2e 30 22 0a 0a 23 20 45 72 72 6f 72 20 "1.0"..# Error
08d0: 43 6c 61 73 73 20 44 65 66 69 6e 69 74 69 6f 6e Class Definition
08e0: 73 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 s ##############
08f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0900: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0910: 0a 23 20 45 6e 61 62 6c 65 73 20 75 73 20 74 6f .# Enables us to
0920: 20 75 73 65 20 65 78 63 65 70 74 69 6f 6e 73 20 use exceptions
0930: 66 72 6f 6d 20 77 69 74 68 69 6e 20 74 68 69 73 from within this
0940: 20 6d 6f 64 75 6c 65 2e 0a 0a 63 6c 61 73 73 20 module...class
0950: 45 72 72 6f 72 28 45 78 63 65 70 74 69 6f 6e 29 Error(Exception)
0960: 3a 0a 20 20 22 22 22 42 61 73 65 20 43 6c 61 73 :. """Base Clas
0970: 73 20 66 6f 72 20 65 78 63 65 70 74 69 6f 6e 73 s for exceptions
0980: 20 69 6e 20 74 68 69 73 20 6d 6f 64 75 6c 65 2e in this module.
0990: 22 22 22 0a 20 20 70 61 73 73 0a 0a 63 6c 61 73 """. pass..clas
09a0: 73 20 49 6e 70 75 74 45 72 72 6f 72 28 45 72 72 s InputError(Err
09b0: 6f 72 29 3a 0a 20 20 22 22 22 45 78 63 65 70 74 or):. """Except
09c0: 69 6f 6e 20 72 61 69 73 65 64 20 66 6f 72 20 65 ion raised for e
09d0: 72 72 6f 72 73 20 69 6e 20 74 68 65 20 69 6e 70 rrors in the inp
09e0: 75 74 2e 0a 0a 20 20 41 74 74 72 69 62 75 74 65 ut... Attribute
09f0: 73 3a 0a 20 20 65 78 70 72 20 2d 2d 20 69 6e 70 s:. expr -- inp
0a00: 75 74 20 65 78 70 72 65 73 73 69 6f 6e 20 69 6e ut expression in
0a10: 20 77 68 69 63 68 20 74 68 65 20 65 72 72 6f 72 which the error
0a20: 20 6f 63 63 75 72 72 65 64 0a 20 20 6d 73 67 20 occurred. msg
0a30: 20 2d 2d 20 65 78 70 6c 61 6e 61 74 69 6f 6e 20 -- explanation
0a40: 6f 66 20 74 68 65 20 65 72 72 6f 72 0a 20 20 22 of the error. "
0a50: 22 22 0a 0a 20 20 64 65 66 20 5f 5f 69 6e 69 74 "".. def __init
0a60: 5f 5f 28 73 65 6c 66 2c 20 6d 73 67 29 3a 0a 20 __(self, msg):.
0a70: 20 20 20 73 65 6c 66 2e 6d 73 67 20 3d 20 6d 73 self.msg = ms
0a80: 67 0a 0a 20 20 64 65 66 20 5f 5f 73 74 72 5f 5f g.. def __str__
0a90: 28 73 65 6c 66 29 3a 0a 20 20 20 20 72 65 74 75 (self):. retu
0aa0: 72 6e 20 73 65 6c 66 2e 6d 73 67 0a 0a 20 20 20 rn self.msg..
0ab0: 20 20 20 0a 23 20 50 72 69 76 61 74 65 20 67 6c .# Private gl
0ac0: 6f 62 61 6c 73 20 23 23 23 23 23 23 23 23 23 23 obals ##########
0ad0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0ae0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0af0: 23 23 23 23 23 23 23 23 23 23 23 23 0a 23 20 56 ############.# V
0b00: 69 73 69 62 6c 65 20 77 69 74 68 69 6e 20 74 68 isible within th
0b10: 69 73 20 66 69 6c 65 2c 20 62 75 74 20 6e 6f 74 is file, but not
0b20: 20 74 6f 20 74 68 65 20 6f 75 74 73 69 64 65 2e to the outside.
0b30: 0a 0a 23 20 49 64 65 6e 74 69 66 79 20 61 20 62 ..# Identify a b
0b40: 65 67 69 6e 20 65 6e 61 62 6c 65 64 2f 6e 6f 74 egin enabled/not
0b50: 5f 64 69 73 61 62 6c 65 64 20 63 6f 6d 6d 61 6e _disabled comman
0b60: 64 2e 20 67 72 6f 75 70 28 31 29 20 63 6f 6e 74 d. group(1) cont
0b70: 61 69 6e 73 20 65 69 74 68 65 72 20 74 68 65 20 ains either the
0b80: 65 6e 61 62 6c 65 64 20 6f 72 0a 23 20 64 69 73 enabled or.# dis
0b90: 61 62 6c 65 64 20 66 6c 61 67 2e 20 50 75 74 20 abled flag. Put
0ba0: 74 68 65 20 72 65 73 74 20 6f 66 20 74 68 65 20 the rest of the
0bb0: 6c 69 6e 65 20 69 6e 20 67 72 6f 75 70 28 32 29 line in group(2)
0bc0: 0a 5f 62 65 67 69 6e 5f 65 6e 5f 64 69 73 5f 63 ._begin_en_dis_c
0bd0: 6f 6d 6d 5f 72 65 20 3d 20 72 65 2e 63 6f 6d 70 omm_re = re.comp
0be0: 69 6c 65 20 28 22 5e 62 65 67 69 6e 5c 73 2b 28 ile ("^begin\s+(
0bf0: 65 6e 61 62 6c 65 64 7c 64 65 66 61 75 6c 74 7c enabled|default|
0c00: 76 65 72 73 69 6f 6e 29 5c 73 2b 28 2e 2b 29 24 version)\s+(.+)$
0c10: 22 29 0a 20 20 0a 23 20 49 64 65 6e 74 69 66 79 "). .# Identify
0c20: 20 61 6e 20 65 6e 64 20 65 6e 61 62 6c 65 64 2f an end enabled/
0c30: 6e 6f 74 5f 64 69 73 61 62 6c 65 64 20 63 6f 6d not_disabled com
0c40: 6d 61 6e 64 2e 20 67 72 6f 75 70 28 31 29 20 63 mand. group(1) c
0c50: 6f 6e 74 61 69 6e 73 20 65 69 74 68 65 72 20 74 ontains either t
0c60: 68 65 20 65 6e 61 62 6c 65 64 20 6f 72 0a 23 20 he enabled or.#
0c70: 64 69 73 61 62 6c 65 64 20 66 6c 61 67 2e 20 50 disabled flag. P
0c80: 75 74 20 74 68 65 20 72 65 73 74 20 6f 66 20 74 ut the rest of t
0c90: 68 65 20 6c 69 6e 65 20 69 6e 20 67 72 6f 75 70 he line in group
0ca0: 28 32 29 0a 5f 65 6e 64 5f 65 6e 5f 64 69 73 5f (2)._end_en_dis_
0cb0: 63 6f 6d 6d 5f 72 65 20 3d 20 72 65 2e 63 6f 6d comm_re = re.com
0cc0: 70 69 6c 65 20 28 22 5e 65 6e 64 5c 73 2b 28 65 pile ("^end\s+(e
0cd0: 6e 61 62 6c 65 64 7c 64 65 66 61 75 6c 74 7c 76 nabled|default|v
0ce0: 65 72 73 69 6f 6e 29 5c 73 2b 28 2e 2b 29 24 22 ersion)\s+(.+)$"
0cf0: 29 0a 20 20 0a 23 20 49 64 65 6e 74 69 66 79 20 ). .# Identify
0d00: 61 6e 20 65 6e 64 20 63 6f 6d 6d 20 61 6e 64 20 an end comm and
0d10: 70 75 74 20 74 68 65 20 72 65 73 74 20 6f 66 20 put the rest of
0d20: 74 68 65 20 6c 69 6e 65 20 69 6e 20 67 72 6f 75 the line in grou
0d30: 70 28 31 29 0a 5f 65 6e 64 5f 63 6f 6d 6d 5f 72 p(1)._end_comm_r
0d40: 65 20 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 20 28 e = re.compile (
0d50: 22 5e 65 6e 64 5c 73 2b 28 2e 2b 29 3f 24 22 29 "^end\s+(.+)?$")
0d60: 0a 20 20 0a 23 20 49 64 65 6e 74 69 66 79 20 61 . .# Identify a
0d70: 6e 20 65 6e 64 20 6f 70 74 69 6f 6e 20 63 6f 6d n end option com
0d80: 6d 61 6e 64 20 61 6e 64 20 70 75 74 20 74 68 65 mand and put the
0d90: 20 72 65 73 74 20 6f 66 20 74 68 65 20 6c 69 6e rest of the lin
0da0: 65 20 69 6e 20 67 72 6f 75 70 28 31 29 0a 5f 65 e in group(1)._e
0db0: 6e 64 5f 6f 70 74 69 6f 6e 5f 63 6f 6d 6d 5f 72 nd_option_comm_r
0dc0: 65 20 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 20 28 e = re.compile (
0dd0: 22 5e 65 6e 64 5c 73 2b 6f 70 74 69 6f 6e 5c 73 "^end\s+option\s
0de0: 2b 28 2e 2b 29 24 22 29 0a 0a 23 20 41 20 76 61 +(.+)$")..# A va
0df0: 6c 69 64 20 76 65 72 73 69 6f 6e 20 73 70 65 63 lid version spec
0e00: 0a 5f 76 65 72 73 69 6f 6e 5f 70 61 72 73 65 5f ._version_parse_
0e10: 72 65 20 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 20 re = re.compile
0e20: 28 22 5e 28 28 5c 64 2b 5c 2e 29 2a 29 3f 28 5c ("^((\d+\.)*)?(\
0e30: 64 2b 29 3f 24 22 29 0a 20 20 0a 23 20 4e 61 6d d+)?$"). .# Nam
0e40: 65 20 6f 66 20 74 68 65 20 44 45 43 74 61 70 65 e of the DECtape
0e50: 20 69 6d 61 67 65 20 66 69 6c 65 20 77 65 20 63 image file we c
0e60: 72 65 61 74 65 0a 5f 6e 65 77 5f 73 79 73 5f 74 reate._new_sys_t
0e70: 61 70 65 5f 70 72 65 66 69 78 20 3d 20 22 73 79 ape_prefix = "sy
0e80: 73 74 65 6d 22 0a 0a 23 20 50 61 72 73 65 72 20 stem"..# Parser
0e90: 72 65 67 65 78 70 73 20 75 73 65 64 20 69 6e 20 regexps used in
0ea0: 70 61 74 63 68 65 72 0a 5f 63 6f 6d 5f 6f 73 38 patcher._com_os8
0eb0: 5f 70 61 72 73 65 5f 73 74 72 20 3d 20 22 5e 5c _parse_str = "^\
0ec0: 2e 28 5b 61 2d 7a 41 2d 5a 5d 2b 29 5c 73 2a 28 .([a-zA-Z]+)\s*(
0ed0: 2e 2a 29 24 22 0a 5f 63 6f 6d 5f 6f 73 38 5f 70 .*)$"._com_os8_p
0ee0: 61 72 73 65 20 3d 20 72 65 2e 63 6f 6d 70 69 6c arse = re.compil
0ef0: 65 28 5f 63 6f 6d 5f 6f 73 38 5f 70 61 72 73 65 e(_com_os8_parse
0f00: 5f 73 74 72 29 0a 5f 63 6f 6d 5f 73 70 6c 69 74 _str)._com_split
0f10: 5f 73 74 72 20 3d 20 22 5e 28 5b 61 2d 7a 41 2d _str = "^([a-zA-
0f20: 5a 5d 2b 29 5c 73 2a 28 2e 2a 29 24 22 0a 5f 63 Z]+)\s*(.*)$"._c
0f30: 6f 6d 5f 73 70 6c 69 74 5f 70 61 72 73 65 20 3d om_split_parse =
0f40: 20 72 65 2e 63 6f 6d 70 69 6c 65 28 5f 63 6f 6d re.compile(_com
0f50: 5f 73 70 6c 69 74 5f 73 74 72 29 0a 5f 6f 64 74 _split_str)._odt
0f60: 5f 70 61 72 73 65 5f 73 74 72 20 3d 20 22 5e 28 _parse_str = "^(
0f70: 5b 30 2d 37 5d 2b 29 5c 73 2a 2f 5c 73 2a 28 5c [0-7]+)\s*/\s*(\
0f80: 53 2b 29 5c 73 2b 28 5b 30 2d 37 3b 5d 2b 29 22 S+)\s+([0-7;]+)"
0f90: 0a 5f 6f 64 74 5f 70 61 72 73 65 20 3d 20 72 65 ._odt_parse = re
0fa0: 2e 63 6f 6d 70 69 6c 65 28 5f 6f 64 74 5f 70 61 .compile(_odt_pa
0fb0: 72 73 65 5f 73 74 72 29 0a 0a 23 20 50 75 74 20 rse_str)..# Put
0fc0: 63 6f 6d 6d 61 6e 64 20 6b 65 79 77 6f 72 64 20 command keyword
0fd0: 69 6e 20 67 72 6f 75 70 28 31 29 20 61 6e 64 20 in group(1) and
0fe0: 74 68 65 20 72 65 73 74 20 69 73 20 69 6e 20 67 the rest is in g
0ff0: 72 6f 75 70 28 33 29 0a 5f 63 6f 6d 6d 5f 72 65 roup(3)._comm_re
1000: 5f 73 74 72 20 3d 20 22 5e 28 5c 53 2b 29 28 5c _str = "^(\S+)(\
1010: 73 2b 28 2e 2b 29 29 3f 24 22 0a 5f 63 6f 6d 6d s+(.+))?$"._comm
1020: 5f 72 65 20 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 _re = re.compile
1030: 28 5f 63 6f 6d 6d 5f 72 65 5f 73 74 72 29 0a 0a (_comm_re_str)..
1040: 23 20 49 64 65 6e 74 69 66 79 20 61 6e 20 65 6e # Identify an en
1050: 64 20 63 6f 6d 6d 20 61 6e 64 20 70 75 74 20 74 d comm and put t
1060: 68 65 20 72 65 73 74 20 6f 66 20 74 68 65 20 6c he rest of the l
1070: 69 6e 65 20 69 6e 20 67 72 6f 75 70 28 31 29 0a ine in group(1).
1080: 5f 65 6e 64 5f 63 6f 6d 6d 5f 72 65 20 3d 20 72 _end_comm_re = r
1090: 65 2e 63 6f 6d 70 69 6c 65 20 28 22 5e 65 6e 64 e.compile ("^end
10a0: 5c 73 2b 28 2e 2b 29 3f 24 22 29 0a 0a 23 20 49 \s+(.+)?$")..# I
10b0: 64 65 6e 74 69 66 79 20 61 6e 20 65 6e 64 20 6f dentify an end o
10c0: 70 74 69 6f 6e 20 63 6f 6d 6d 61 6e 64 20 61 6e ption command an
10d0: 64 20 70 75 74 20 74 68 65 20 72 65 73 74 20 6f d put the rest o
10e0: 66 20 74 68 65 20 6c 69 6e 65 20 69 6e 20 67 72 f the line in gr
10f0: 6f 75 70 28 31 29 0a 5f 65 6e 64 5f 6f 70 74 69 oup(1)._end_opti
1100: 6f 6e 5f 63 6f 6d 6d 5f 72 65 20 3d 20 72 65 2e on_comm_re = re.
1110: 63 6f 6d 70 69 6c 65 20 28 22 5e 65 6e 64 5c 73 compile ("^end\s
1120: 2b 6f 70 74 69 6f 6e 5c 73 2b 28 2e 2b 29 24 22 +option\s+(.+)$"
1130: 29 0a 0a 23 20 49 64 65 6e 74 69 66 79 20 61 20 )..# Identify a
1140: 62 65 67 69 6e 20 63 6f 6d 6d 61 6e 64 20 61 6e begin command an
1150: 64 20 70 75 74 20 74 68 65 20 72 65 73 74 20 6f d put the rest o
1160: 66 20 74 68 65 20 6c 69 6e 65 20 69 6e 20 67 72 f the line in gr
1170: 6f 75 70 28 31 29 0a 5f 62 65 67 69 6e 5f 6f 70 oup(1)._begin_op
1180: 74 69 6f 6e 5f 63 6f 6d 6d 5f 72 65 20 3d 20 72 tion_comm_re = r
1190: 65 2e 63 6f 6d 70 69 6c 65 20 28 22 5e 62 65 67 e.compile ("^beg
11a0: 69 6e 5c 73 2b 6f 70 74 69 6f 6e 5c 73 2b 28 2e in\s+option\s+(.
11b0: 2b 29 24 22 29 0a 0a 23 20 50 61 72 73 65 20 61 +)$")..# Parse a
11c0: 6e 20 61 72 67 75 6d 65 6e 74 20 73 74 72 69 6e n argument strin
11d0: 67 20 69 6e 74 6f 20 61 20 73 79 73 20 64 65 76 g into a sys dev
11e0: 69 63 65 20 77 69 74 68 0a 23 20 64 65 76 69 63 ice with.# devic
11f0: 65 20 6e 61 6d 65 20 69 6e 20 67 72 6f 75 70 28 e name in group(
1200: 31 29 2c 20 75 6e 69 74 20 6e 75 6d 62 65 72 20 1), unit number
1210: 69 6e 20 67 72 6f 75 70 28 32 29 0a 23 20 57 65 in group(2).# We
1220: 20 70 75 74 20 61 6c 6c 20 62 6f 6f 74 61 62 6c put all bootabl
1230: 65 20 64 65 76 69 63 65 73 20 69 6e 74 6f 20 74 e devices into t
1240: 68 69 73 20 73 74 72 69 6e 67 20 73 6f 20 74 68 his string so th
1250: 61 74 20 77 68 65 6e 0a 23 20 77 65 20 61 64 64 at when.# we add
1260: 20 6d 6f 72 65 20 64 65 76 69 63 65 73 2c 20 66 more devices, f
1270: 6f 72 20 65 78 61 6d 70 6c 65 20 72 6c 20 66 6f or example rl fo
1280: 72 20 52 4c 30 31 2c 20 77 65 20 63 68 61 6e 67 r RL01, we chang
1290: 65 20 6f 6e 65 0a 23 20 73 74 72 69 6e 67 20 6e e one.# string n
12a0: 6f 74 20 6d 61 6e 79 2e 0a 5f 73 69 6d 68 5f 62 ot many.._simh_b
12b0: 6f 6f 74 5f 64 65 76 5f 73 74 72 20 3d 20 22 28 oot_dev_str = "(
12c0: 72 6b 7c 74 64 7c 64 74 7c 72 78 29 28 5c 64 2a rk|td|dt|rx)(\d*
12d0: 29 22 0a 5f 73 69 6d 68 5f 62 6f 6f 74 5f 72 65 )"._simh_boot_re
12e0: 20 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 28 22 5e = re.compile("^
12f0: 22 20 2b 20 5f 73 69 6d 68 5f 62 6f 6f 74 5f 64 " + _simh_boot_d
1300: 65 76 5f 73 74 72 20 2b 20 22 24 22 29 0a 0a 23 ev_str + "$")..#
1310: 20 50 61 72 73 65 20 61 6e 20 61 72 67 75 6d 65 Parse an argume
1320: 6e 74 20 73 74 72 69 6e 67 20 66 6f 72 20 6d 6f nt string for mo
1330: 75 6e 74 20 69 6e 74 6f 20 53 49 4d 48 20 64 65 unt into SIMH de
1340: 76 69 63 65 0a 23 20 64 65 76 69 63 65 20 6e 61 vice.# device na
1350: 6d 65 20 69 6e 20 67 72 6f 75 70 28 31 29 2c 20 me in group(1),
1360: 75 6e 69 74 20 6e 75 6d 62 65 72 20 69 6e 20 67 unit number in g
1370: 72 6f 75 70 28 32 29 0a 23 20 41 6e 64 20 74 68 roup(2).# And th
1380: 65 20 72 65 73 74 20 69 6e 20 67 72 6f 75 70 20 e rest in group
1390: 28 33 29 0a 5f 6d 6f 75 6e 74 5f 72 65 67 65 78 (3)._mount_regex
13a0: 5f 73 74 72 20 3d 20 22 5e 22 20 2b 20 5f 73 69 _str = "^" + _si
13b0: 6d 68 5f 62 6f 6f 74 5f 64 65 76 5f 73 74 72 20 mh_boot_dev_str
13c0: 2b 20 22 5c 73 2b 28 2e 2b 29 24 22 0a 5f 6d 6f + "\s+(.+)$"._mo
13d0: 75 6e 74 5f 72 65 20 3d 20 72 65 2e 63 6f 6d 70 unt_re = re.comp
13e0: 69 6c 65 28 5f 6d 6f 75 6e 74 5f 72 65 67 65 78 ile(_mount_regex
13f0: 5f 73 74 72 29 0a 0a 23 20 4d 61 70 20 6f 66 20 _str)..# Map of
1400: 53 49 4d 48 20 64 65 76 69 63 65 20 6e 61 6d 65 SIMH device name
1410: 73 20 74 6f 20 4f 53 2f 38 20 64 65 76 69 63 65 s to OS/8 device
1420: 20 6e 61 6d 65 20 70 72 65 66 69 78 65 73 2e 0a name prefixes..
1430: 5f 6f 73 38 5f 66 72 6f 6d 5f 73 69 6d 68 5f 64 _os8_from_simh_d
1440: 65 76 20 3d 20 7b 22 72 6b 22 20 3a 20 22 52 4b ev = {"rk" : "RK
1450: 22 2c 20 22 74 64 22 20 3a 20 22 44 54 41 22 2c ", "td" : "DTA",
1460: 20 22 64 74 22 20 3a 20 22 44 54 41 22 2c 20 22 "dt" : "DTA", "
1470: 72 78 22 20 3a 20 22 52 58 22 7d 0a 0a 5f 6f 73 rx" : "RX"}.._os
1480: 38 5f 70 61 72 74 69 74 69 6f 6e 73 20 3d 20 7b 8_partitions = {
1490: 22 52 4b 22 3a 20 5b 22 41 22 2c 20 22 42 22 5d "RK": ["A", "B"]
14a0: 7d 0a 0a 23 20 4f 53 2f 38 20 66 69 6c 65 20 6e }..# OS/8 file n
14b0: 61 6d 65 20 6d 61 74 63 68 69 6e 67 20 72 65 67 ame matching reg
14c0: 65 78 0a 5f 6f 73 38 5f 66 69 6c 65 5f 72 65 20 ex._os8_file_re
14d0: 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 28 22 28 5c = re.compile("(\
14e0: 53 2b 29 3a 28 5c 53 2b 29 3f 22 29 0a 0a 23 20 S+):(\S+)?")..#
14f0: 52 65 67 75 6c 61 72 20 65 78 70 72 65 73 73 69 Regular expressi
1500: 6f 6e 20 66 6f 72 20 73 79 6e 74 61 78 20 63 68 on for syntax ch
1510: 65 63 6b 69 6e 67 20 69 6e 73 69 64 65 20 46 4f ecking inside FO
1520: 54 50 0a 23 20 44 65 73 74 69 6e 61 74 69 6f 6e TP.# Destination
1530: 20 69 73 20 69 6e 20 67 72 6f 75 70 28 31 29 2c is in group(1),
1540: 20 53 6f 75 72 63 65 20 69 73 20 69 6e 20 67 72 Source is in gr
1550: 6f 75 70 28 33 29 0a 5f 66 6f 74 70 5f 72 65 20 oup(3)._fotp_re
1560: 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 20 28 22 5e = re.compile ("^
1570: 28 28 5c 53 2b 3a 29 3f 5c 53 2b 29 3c 28 28 5c ((\S+:)?\S+)<((\
1580: 53 2b 3a 29 3f 5c 53 2b 29 24 22 29 0a 0a 23 20 S+:)?\S+)$")..#
1590: 52 65 67 75 6c 61 72 20 65 78 70 72 65 73 73 69 Regular expressi
15a0: 6f 6e 20 66 6f 72 20 64 65 74 65 63 74 69 6e 67 on for detecting
15b0: 20 74 68 65 20 32 20 61 72 67 20 61 6e 64 20 33 the 2 arg and 3
15c0: 20 61 72 67 20 66 6f 72 6d 73 0a 23 20 6f 66 20 arg forms.# of
15d0: 74 68 65 20 22 70 61 6c 38 22 20 73 63 72 69 70 the "pal8" scrip
15e0: 74 20 63 6f 6d 6d 61 6e 64 2e 0a 0a 23 20 4f 53 t command...# OS
15f0: 2f 38 20 6e 61 6d 65 20 72 65 67 65 78 20 74 65 /8 name regex te
1600: 6d 70 6c 61 74 65 3a 0a 23 20 4f 70 74 69 6f 6e mplate:.# Option
1610: 61 6c 20 64 65 76 69 63 65 20 73 70 65 63 2c 20 al device spec,
1620: 69 2e 65 2e 20 44 54 41 30 3a 0a 23 20 46 69 6c i.e. DTA0:.# Fil
1630: 65 20 73 70 65 63 20 77 69 74 68 20 61 20 73 70 e spec with a sp
1640: 65 63 69 66 69 63 20 65 78 74 65 6e 73 69 6f 6e ecific extension
1650: 20 6f 72 20 6e 6f 20 65 78 74 65 6e 73 69 6f 6e or no extension
1660: 2e 0a 0a 5f 6f 73 38 5f 66 73 70 65 63 20 3d 20 ..._os8_fspec =
1670: 54 65 6d 70 6c 61 74 65 20 28 22 28 28 5c 53 2b Template ("((\S+
1680: 3a 29 3f 28 5b 41 2d 5a 30 2d 39 5d 7b 31 2c 36 :)?([A-Z0-9]{1,6
1690: 7d 7c 5b 41 2d 5a 30 2d 39 5d 7b 31 2c 36 7d 5c }|[A-Z0-9]{1,6}\
16a0: 2e 24 65 78 74 29 29 22 29 0a 5f 6f 73 38 5f 42 .$ext))")._os8_B
16b0: 4e 5f 66 73 70 65 63 20 3d 20 5f 6f 73 38 5f 66 N_fspec = _os8_f
16c0: 73 70 65 63 2e 73 75 62 73 74 69 74 75 74 65 28 spec.substitute(
16d0: 65 78 74 3d 22 42 4e 22 29 0a 5f 6f 73 38 5f 50 ext="BN")._os8_P
16e0: 41 5f 66 73 70 65 63 20 3d 20 5f 6f 73 38 5f 66 A_fspec = _os8_f
16f0: 73 70 65 63 2e 73 75 62 73 74 69 74 75 74 65 28 spec.substitute(
1700: 65 78 74 3d 22 50 41 22 29 0a 5f 6f 73 38 5f 4c ext="PA")._os8_L
1710: 53 5f 66 73 70 65 63 20 3d 20 5f 6f 73 38 5f 66 S_fspec = _os8_f
1720: 73 70 65 63 2e 73 75 62 73 74 69 74 75 74 65 28 spec.substitute(
1730: 65 78 74 3d 22 4c 53 22 29 0a 0a 23 20 52 65 67 ext="LS")..# Reg
1740: 65 78 20 74 6f 20 70 61 72 73 65 20 61 20 76 61 ex to parse a va
1750: 6c 69 64 20 4f 53 2f 38 20 6f 70 74 69 6f 6e 20 lid OS/8 option
1760: 73 74 72 69 6e 67 20 65 69 74 68 65 72 20 77 69 string either wi
1770: 74 68 20 73 6c 61 73 68 20 6f 72 20 70 61 72 65 th slash or pare
1780: 6e 73 2e 0a 5f 6f 70 74 5f 73 74 72 20 3d 20 20 ns.._opt_str =
1790: 22 28 28 2f 5b 41 2d 5a 30 2d 39 5d 29 2b 7c 5c "((/[A-Z0-9])+|\
17a0: 28 5b 41 2d 5a 30 2d 39 5d 2b 5c 29 29 3f 22 0a ([A-Z0-9]+\))?".
17b0: 0a 23 20 52 65 67 75 6c 61 72 20 65 78 70 72 65 .# Regular expre
17c0: 73 73 69 6f 6e 20 66 6f 72 20 73 79 6e 74 61 78 ssion for syntax
17d0: 20 63 68 65 63 6b 69 6e 67 20 69 6e 73 69 64 65 checking inside
17e0: 20 41 42 53 4c 44 52 0a 23 20 46 49 58 4d 45 3a ABSLDR.# FIXME:
17f0: 20 55 73 65 20 28 61 6e 64 20 74 65 73 74 29 20 Use (and test)
1800: 5f 6f 70 74 5f 73 74 72 20 66 6f 72 20 66 75 6c _opt_str for ful
1810: 6c 20 4f 53 2f 38 20 4f 70 74 69 6f 6e 20 73 70 l OS/8 Option sp
1820: 65 63 20 63 6f 6d 70 61 74 69 62 69 6c 69 74 79 ec compatibility
1830: 0a 23 20 4f 6e 65 20 6f 72 20 6d 6f 72 65 20 4f .# One or more O
1840: 53 2f 38 20 62 69 6e 61 72 79 20 66 69 6c 65 73 S/8 binary files
1850: 20 61 6e 64 20 6f 70 74 69 6f 6e 61 6c 20 61 72 and optional ar
1860: 67 73 20 62 65 67 69 6e 6e 69 6e 67 20 77 69 74 gs beginning wit
1870: 68 20 61 20 73 6c 61 73 68 2e 0a 0a 5f 61 62 73 h a slash..._abs
1880: 6c 64 72 5f 72 65 20 3d 20 72 65 2e 63 6f 6d 70 ldr_re = re.comp
1890: 69 6c 65 20 28 22 5e 22 20 2b 20 5f 6f 73 38 5f ile ("^" + _os8_
18a0: 42 4e 5f 66 73 70 65 63 20 2b 20 22 28 2c 22 20 BN_fspec + "(,"
18b0: 2b 20 5f 6f 73 38 5f 42 4e 5f 66 73 70 65 63 20 + _os8_BN_fspec
18c0: 2b 20 22 29 2a 28 2f 5c 53 29 2a 24 22 29 0a 0a + ")*(/\S)*$")..
18d0: 23 20 52 65 67 75 6c 61 72 20 65 78 70 72 65 73 # Regular expres
18e0: 73 69 6f 6e 73 20 66 6f 72 20 73 79 6e 74 61 78 sions for syntax
18f0: 20 63 68 65 63 6b 69 6e 67 20 66 6f 72 20 63 70 checking for cp
1900: 74 6f 20 61 6e 64 20 63 70 66 72 6f 6d 2e 0a 23 to and cpfrom..#
1910: 20 4d 61 79 20 62 65 20 3c 73 6f 75 72 63 65 3e May be <source>
1920: 20 77 68 65 72 65 20 64 65 73 74 69 6e 61 74 69 where destinati
1930: 6f 6e 20 61 6e 64 20 64 65 66 61 75 6c 74 20 6f on and default o
1940: 70 74 69 6f 6e 20 2f 41 20 69 73 20 69 6d 70 6c ption /A is impl
1950: 69 65 64 2e 0a 23 20 4f 72 20 3c 73 6f 75 72 63 ied..# Or <sourc
1960: 65 3e 20 3c 6f 70 74 69 6f 6e 3e 20 77 68 65 72 e> <option> wher
1970: 65 20 64 65 73 74 69 6e 61 74 69 6f 6e 20 69 73 e destination is
1980: 20 69 6d 70 6c 69 65 64 20 61 6e 64 20 6f 70 74 implied and opt
1990: 69 6f 6e 20 69 73 20 73 65 74 2e 0a 23 20 4f 72 ion is set..# Or
19a0: 20 3c 73 6f 75 72 63 65 3e 20 3c 64 65 73 74 69 <source> <desti
19b0: 6e 61 74 69 6f 6e 3e 20 77 68 65 72 65 20 6f 70 nation> where op
19c0: 74 69 6f 6e 20 2f 41 20 69 73 20 69 6d 70 6c 69 tion /A is impli
19d0: 65 64 2e 0a 23 20 4f 72 20 3c 73 6f 75 72 63 65 ed..# Or <source
19e0: 3e 20 3c 64 65 73 74 69 6e 61 74 69 6f 6e 3e 20 > <destination>
19f0: 3c 6f 70 74 69 6f 6e 3e 20 61 72 65 20 65 78 70 <option> are exp
1a00: 6c 69 63 69 74 2e 0a 23 20 56 61 6c 69 64 20 6f licit..# Valid o
1a10: 70 74 69 6f 6e 73 20 61 72 65 20 22 2f 41 22 2c ptions are "/A",
1a20: 20 22 2f 49 22 2c 20 61 6e 64 20 22 2f 42 22 0a "/I", and "/B".
1a30: 23 20 55 73 65 20 74 77 6f 20 72 65 67 65 78 27 # Use two regex'
1a40: 73 20 69 6e 20 6f 72 64 65 72 3a 0a 23 20 3c 73 s in order:.# <s
1a50: 6f 75 72 63 65 3e 20 69 6e 20 67 72 6f 75 70 20 ource> in group
1a60: 31 2c 20 3c 64 65 73 74 3e 20 69 6e 20 67 72 6f 1, <dest> in gro
1a70: 75 70 20 32 2e 0a 23 20 4f 70 74 69 6f 6e 20 69 up 2..# Option i
1a80: 73 20 6f 6e 65 20 6f 66 20 2f 49 20 2f 42 20 2f s one of /I /B /
1a90: 41 20 69 6e 20 67 72 6f 75 70 20 34 2e 0a 0a 23 A in group 4...#
1aa0: 20 73 6f 75 72 63 65 20 69 6e 20 67 72 6f 75 70 source in group
1ab0: 20 31 2c 20 6f 70 74 69 6f 6e 20 69 6e 20 67 72 1, option in gr
1ac0: 6f 75 70 20 33 2e 0a 5f 66 72 6f 6d 5f 74 6f 5f oup 3.._from_to_
1ad0: 72 65 5f 31 20 3d 20 72 65 2e 63 6f 6d 70 69 6c re_1 = re.compil
1ae0: 65 20 28 22 5e 28 5c 53 2b 29 28 5c 73 2b 28 2f e ("^(\S+)(\s+(/
1af0: 5b 41 49 42 5d 29 29 3f 24 22 29 0a 23 20 73 6f [AIB]))?$").# so
1b00: 75 72 63 65 20 69 6e 20 67 72 6f 75 70 20 31 2c urce in group 1,
1b10: 20 64 65 73 74 69 6e 61 74 69 6f 6e 20 69 6e 20 destination in
1b20: 67 72 6f 75 70 20 32 2c 20 6f 70 74 69 6f 6e 20 group 2, option
1b30: 69 6e 20 67 72 6f 75 70 20 34 2e 0a 5f 66 72 6f in group 4.._fro
1b40: 6d 5f 74 6f 5f 72 65 5f 32 20 3d 20 72 65 2e 63 m_to_re_2 = re.c
1b50: 6f 6d 70 69 6c 65 20 28 22 5e 28 5c 53 2b 29 5c ompile ("^(\S+)\
1b60: 73 2b 28 5c 53 2b 29 28 5c 73 2b 28 2f 5b 41 49 s+(\S+)(\s+(/[AI
1b70: 42 5d 29 29 3f 24 22 29 0a 0a 23 20 41 72 72 61 B]))?$")..# Arra
1b80: 79 20 6f 66 20 72 65 67 75 6c 61 72 20 65 78 70 y of regular exp
1b90: 72 65 73 73 69 6f 6e 73 20 66 6f 72 20 73 79 6e ressions for syn
1ba0: 74 61 78 20 63 68 65 63 6b 69 6e 67 20 69 6e 73 tax checking ins
1bb0: 69 64 65 20 42 55 49 4c 44 0a 5f 62 75 69 6c 64 ide BUILD._build
1bc0: 5f 63 6f 6d 6d 5f 72 65 67 73 20 3d 20 7b 22 4c _comm_regs = {"L
1bd0: 4f 41 44 22 20 20 3a 20 72 65 2e 63 6f 6d 70 69 OAD" : re.compi
1be0: 6c 65 28 22 5e 28 5c 53 2b 3a 29 3f 5c 53 2b 28 le("^(\S+:)?\S+(
1bf0: 2e 42 4e 29 3f 24 22 29 2c 0a 20 20 20 20 20 20 .BN)?$"),.
1c00: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 55 "U
1c10: 4e 4c 4f 41 44 22 3a 20 72 65 2e 63 6f 6d 70 69 NLOAD": re.compi
1c20: 6c 65 28 22 5e 5c 53 2b 28 2c 5c 53 2b 29 3f 24 le("^\S+(,\S+)?$
1c30: 22 29 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 "),.
1c40: 20 20 20 20 20 20 20 20 22 49 4e 53 45 52 54 22 "INSERT"
1c50: 3a 20 72 65 2e 63 6f 6d 70 69 6c 65 28 22 5e 5c : re.compile("^\
1c60: 53 2b 2c 5c 53 2b 28 2c 5c 53 2b 29 3f 24 22 29 S+,\S+(,\S+)?$")
1c70: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,.
1c80: 20 20 20 20 20 20 22 44 45 4c 45 54 45 22 3a 20 "DELETE":
1c90: 72 65 2e 63 6f 6d 70 69 6c 65 28 22 5e 5c 53 2b re.compile("^\S+
1ca0: 28 2c 5c 53 2b 29 3f 24 22 29 2c 0a 20 20 20 20 (,\S+)?$"),.
1cb0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1cc0: 22 53 59 53 54 45 4d 22 3a 20 72 65 2e 63 6f 6d "SYSTEM": re.com
1cd0: 70 69 6c 65 28 22 5e 5c 53 2b 24 22 29 2c 0a 20 pile("^\S+$"),.
1ce0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
1cf0: 20 20 20 22 44 53 4b 22 20 20 20 3a 20 72 65 2e "DSK" : re.
1d00: 63 6f 6d 70 69 6c 65 28 22 5e 28 5c 53 2b 3a 29 compile("^(\S+:)
1d10: 3f 5c 53 2b 24 22 29 2c 0a 20 20 20 20 20 20 20 ?\S+$"),.
1d20: 20 20 20 20 20 20 20 20 20 20 20 20 20 22 42 55 "BU
1d30: 49 4c 44 22 20 3a 20 72 65 2e 63 6f 6d 70 69 6c ILD" : re.compil
1d40: 65 28 22 5e 28 5c 53 2b 28 2e 42 4e 29 3f 29 5c e("^(\S+(.BN)?)\
1d50: 73 2b 28 5c 53 2b 28 2e 42 4e 29 3f 29 24 22 29 s+(\S+(.BN)?)$")
1d60: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,.
1d70: 20 20 20 20 20 20 22 50 52 49 4e 54 22 20 3a 20 "PRINT" :
1d80: 4e 6f 6e 65 2c 0a 20 20 20 20 20 20 20 20 20 20 None,.
1d90: 20 20 20 20 20 20 20 20 20 20 22 42 4f 4f 54 22 "BOOT"
1da0: 20 20 3a 20 4e 6f 6e 65 2c 0a 20 20 20 20 20 20 : None,.
1db0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 65 "e
1dc0: 6e 64 22 20 20 20 3a 20 4e 6f 6e 65 7d 0a 0a 0a nd" : None}...
1dd0: 23 20 50 61 72 73 65 20 74 77 6f 20 77 68 69 74 # Parse two whit
1de0: 73 70 61 63 65 20 73 65 70 61 72 61 74 65 64 20 space separated
1df0: 61 72 67 75 6d 65 6e 74 73 20 69 6e 74 6f 20 67 arguments into g
1e00: 72 6f 75 70 28 31 29 20 61 6e 64 20 67 72 6f 75 roup(1) and grou
1e10: 70 28 32 29 0a 5f 74 77 6f 5f 61 72 67 73 5f 72 p(2)._two_args_r
1e20: 65 20 3d 20 72 65 2e 63 6f 6d 70 69 6c 65 28 22 e = re.compile("
1e30: 5e 28 5c 53 2b 29 5c 73 2b 28 5c 53 2b 29 24 22 ^(\S+)\s+(\S+)$"
1e40: 29 0a 0a 5f 72 78 5f 73 65 74 74 69 6e 67 73 20 ).._rx_settings
1e50: 3d 20 5b 22 72 78 30 31 22 2c 20 22 72 78 30 32 = ["rx01", "rx02
1e60: 22 2c 20 22 52 58 38 45 22 2c 20 22 52 58 32 38 ", "RX8E", "RX28
1e70: 22 5d 0a 5f 74 61 70 65 5f 73 65 74 74 69 6e 67 "]._tape_setting
1e80: 73 20 3d 20 5b 22 74 64 22 2c 20 22 64 74 22 5d s = ["td", "dt"]
1e90: 0a 5f 74 74 69 5f 73 65 74 74 69 6e 67 73 20 3d ._tti_settings =
1ea0: 20 5b 22 4b 53 52 22 2c 20 22 37 62 22 5d 0a 5f ["KSR", "7b"]._
1eb0: 63 6f 6e 66 69 67 75 72 61 62 6c 65 73 20 3d 20 configurables =
1ec0: 7b 22 72 78 22 3a 20 5f 72 78 5f 73 65 74 74 69 {"rx": _rx_setti
1ed0: 6e 67 73 2c 20 22 74 61 70 65 22 3a 20 5f 74 61 ngs, "tape": _ta
1ee0: 70 65 5f 73 65 74 74 69 6e 67 73 2c 0a 20 20 20 pe_settings,.
1ef0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 "
1f00: 74 74 69 22 3a 20 5f 74 74 69 5f 73 65 74 74 69 tti": _tti_setti
1f10: 6e 67 73 7d 0a 0a 23 20 4d 61 74 63 68 65 73 20 ngs}..# Matches
1f20: 69 66 20 74 68 65 20 73 74 72 69 6e 67 20 62 65 if the string be
1f30: 67 69 6e 73 20 77 69 74 68 20 61 20 64 6f 6c 6c gins with a doll
1f40: 61 72 20 73 69 67 6e 2c 20 61 6e 64 20 68 61 73 ar sign, and has
1f50: 20 61 74 20 6c 65 61 73 74 0a 23 20 6f 6e 65 20 at least.# one
1f60: 73 6c 61 73 68 2c 20 72 65 74 75 72 6e 69 6e 67 slash, returning
1f70: 20 74 68 65 20 73 74 72 69 6e 67 20 62 65 74 77 the string betw
1f80: 65 65 6e 20 74 68 65 20 64 6f 6c 6c 61 72 20 73 een the dollar s
1f90: 69 67 6e 20 61 6e 64 20 74 68 65 0a 23 20 66 69 ign and the.# fi
1fa0: 72 73 74 20 73 6c 61 73 68 20 69 6e 20 67 72 6f rst slash in gro
1fb0: 75 70 20 31 20 61 6e 64 20 74 68 65 20 72 65 73 up 1 and the res
1fc0: 74 20 69 6e 20 67 72 6f 75 70 20 32 2e 0a 23 20 t in group 2..#
1fd0: 4e 6f 20 77 68 69 74 65 73 70 61 63 65 20 69 6e No whitespace in
1fe0: 20 74 68 65 20 73 74 72 69 6e 67 2e 0a 5f 65 78 the string.._ex
1ff0: 70 61 6e 64 61 62 6c 65 5f 72 65 20 3d 20 72 65 pandable_re = re
2000: 2e 63 6f 6d 70 69 6c 65 20 28 22 5e 5c 24 28 5b .compile ("^\$([
2010: 5e 2f 5c 73 5d 2b 29 2f 28 5c 53 2a 29 24 22 29 ^/\s]+)/(\S*)$")
2020: 0a 0a 23 20 50 61 72 73 65 20 61 6e 20 65 78 69 ..# Parse an exi
2030: 74 20 61 72 67 20 66 6f 72 20 61 6e 20 69 6e 74 t arg for an int
2040: 65 67 65 72 20 6f 72 20 61 6e 20 69 6e 74 65 67 eger or an integ
2050: 65 72 20 69 6e 20 70 61 72 65 6e 74 68 65 73 65 er in parenthese
2060: 73 0a 5f 65 78 69 74 5f 61 72 67 5f 72 65 20 3d s._exit_arg_re =
2070: 20 72 65 2e 63 6f 6d 70 69 6c 65 20 28 22 5e 28 re.compile ("^(
2080: 5c 73 2a 5b 2b 2d 5d 3f 5c 73 2a 5c 64 2b 29 7c \s*[+-]?\s*\d+)|
2090: 5c 73 2a 5c 28 5c 73 2a 28 5b 2b 2d 5d 3f 5c 73 \s*\(\s*([+-]?\s
20a0: 2a 5c 64 2b 29 5c 73 2a 5c 29 5c 73 2a 24 22 29 *\d+)\s*\)\s*$")
20b0: 0a 0a 23 20 4f 70 74 69 6f 6e 73 20 65 6e 61 62 ..# Options enab
20c0: 6c 65 64 2f 6e 6f 74 5f 64 69 73 61 62 6c 65 64 led/not_disabled
20d0: 20 66 6f 72 20 63 6f 6e 64 69 74 69 6f 6e 61 6c for conditional
20e0: 20 65 78 65 63 75 74 69 6f 6e 20 69 6e 20 73 63 execution in sc
20f0: 72 69 70 74 73 2e 0a 23 0a 23 20 45 61 72 6c 69 ripts..#.# Earli
2100: 65 72 20 63 6f 64 65 20 61 6c 6c 6f 77 65 64 20 er code allowed
2110: 2d 2d 65 6e 61 62 6c 65 20 61 6e 64 20 2d 2d 64 --enable and --d
2120: 69 73 61 62 6c 65 2e 20 57 65 20 69 6e 74 65 72 isable. We inter
2130: 66 61 63 65 20 74 6f 20 69 74 2e 0a 23 20 57 65 face to it..# We
2140: 20 6d 61 69 6e 74 61 69 6e 20 74 77 6f 20 61 72 maintain two ar
2150: 72 61 79 73 3a 20 6f 70 74 69 6f 6e 73 5f 65 6e rays: options_en
2160: 61 62 6c 65 20 61 6e 64 20 6f 70 74 69 6f 6e 73 able and options
2170: 5f 64 69 73 61 62 6c 65 64 20 66 6f 72 20 74 68 _disabled for th
2180: 6f 73 65 0a 23 20 74 77 6f 20 61 72 67 75 6d 65 ose.# two argume
2190: 6e 74 20 63 6f 6e 73 74 72 75 63 74 73 2e 0a 23 nt constructs..#
21a0: 0a 23 20 41 72 67 75 6d 65 6e 74 20 70 61 72 73 .# Argument pars
21b0: 69 6e 67 20 6f 66 20 72 65 70 65 61 74 65 64 20 ing of repeated
21c0: 65 6e 61 62 6c 65 20 61 6e 64 20 64 69 73 61 62 enable and disab
21d0: 6c 65 20 61 72 67 75 6d 65 6e 74 73 20 69 73 20 le arguments is
21e0: 61 73 20 66 6f 6c 6c 6f 77 73 3a 0a 23 20 2d 2d as follows:.# --
21f0: 65 6e 61 62 6c 65 20 6c 6f 6f 6b 73 20 6f 6e 20 enable looks on
2200: 6f 70 74 69 6f 6e 73 5f 64 69 73 61 62 6c 65 64 options_disabled
2210: 20 61 6e 64 20 69 66 20 70 72 65 73 65 6e 74 20 and if present
2220: 72 65 6d 6f 76 65 73 20 69 74 2c 20 74 68 65 6e removes it, then
2230: 20 61 64 64 73 0a 23 20 74 6f 20 6f 70 74 69 6f adds.# to optio
2240: 6e 73 5f 65 6e 61 62 6c 65 64 2e 0a 23 20 2d 2d ns_enabled..# --
2250: 64 69 73 61 62 6c 65 20 6c 6f 6f 6b 73 20 6f 6e disable looks on
2260: 20 6f 70 74 69 6f 6e 73 5f 65 6e 61 62 6c 65 64 options_enabled
2270: 20 61 6e 64 20 69 66 20 70 72 65 73 65 6e 74 20 and if present
2280: 72 65 6d 6f 76 65 73 20 69 74 2c 20 74 68 65 6e removes it, then
2290: 20 61 64 64 73 0a 23 20 74 6f 20 6f 70 74 69 6f adds.# to optio
22a0: 6e 73 5f 65 6e 61 62 6c 65 64 2e 0a 23 0a 23 20 ns_enabled..#.#
22b0: 4c 61 73 74 20 73 65 65 6e 20 65 6e 61 62 6c 65 Last seen enable
22c0: 2f 64 69 73 61 62 6c 65 20 63 6f 6d 6d 61 6e 64 /disable command
22d0: 20 6c 69 6e 65 20 6f 72 20 65 78 65 63 75 74 65 line or execute
22e0: 64 20 63 6f 6d 6d 61 6e 64 20 66 6f 72 20 61 0a d command for a.
22f0: 23 20 70 61 72 74 69 63 75 6c 61 72 20 6f 70 74 # particular opt
2300: 69 6f 6e 20 77 69 6e 73 2e 0a 23 0a 23 20 53 63 ion wins..#.# Sc
2310: 72 69 70 74 73 20 68 61 76 65 20 65 6e 61 62 6c ripts have enabl
2320: 65 2f 64 69 73 61 62 6c 65 20 63 6f 6d 6d 61 6e e/disable comman
2330: 64 73 20 74 68 61 74 20 61 72 65 20 72 75 6e 2d ds that are run-
2340: 74 69 6d 65 0a 23 20 63 68 61 6e 67 65 72 73 20 time.# changers
2350: 6f 66 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 20 of the contents
2360: 6f 66 20 6f 70 74 69 6f 6e 73 5f 65 6e 61 62 6c of options_enabl
2370: 65 64 20 61 6e 64 20 6f 70 74 69 6f 6e 73 5f 64 ed and options_d
2380: 69 73 61 62 6c 65 64 2e 0a 23 0a 23 20 57 68 65 isabled..#.# Whe
2390: 6e 20 77 65 20 72 75 6e 20 61 20 73 63 72 69 70 n we run a scrip
23a0: 74 20 77 65 20 68 61 76 65 20 62 65 67 69 6e 2f t we have begin/
23b0: 65 6e 64 20 62 6c 6f 63 6b 73 20 66 6f 72 20 65 end blocks for e
23c0: 6e 61 62 6c 65 64 2f 6e 6f 74 5f 64 69 73 61 62 nabled/not_disab
23d0: 6c 65 64 20 6f 70 74 69 6f 6e 73 3a 0a 23 20 22 led options:.# "
23e0: 62 65 67 69 6e 20 65 6e 61 62 6c 65 64 20 3c 6f begin enabled <o
23f0: 70 74 69 6f 6e 20 6e 61 6d 65 3e 22 20 2e 2e 2e ption name>" ...
2400: 20 22 65 6e 64 20 65 6e 61 62 6c 65 64 20 3c 6f "end enabled <o
2410: 70 74 69 6f 6e 20 6e 61 6d 65 3e 0a 23 20 22 62 ption name>.# "b
2420: 65 67 69 6e 20 6e 6f 74 5f 64 69 73 61 62 6c 65 egin not_disable
2430: 64 20 3c 6f 70 74 69 6f 6e 20 6e 61 6d 65 3e 22 d <option name>"
2440: 20 2e 2e 2e 20 22 65 6e 64 20 6e 6f 74 5f 64 69 ... "end not_di
2450: 73 61 62 6c 65 64 20 3c 6f 70 74 69 6f 6e 20 6e sabled <option n
2460: 61 6d 65 3e 0a 23 0a 23 20 54 68 65 20 65 6e 61 ame>.#.# The ena
2470: 62 6c 65 64 20 62 6c 6f 63 6b 20 6c 6f 6f 6b 73 bled block looks
2480: 20 66 6f 72 20 61 6e 20 65 78 70 6c 69 63 69 74 for an explicit
2490: 20 65 6e 61 62 6c 65 6d 65 6e 74 20 6f 6e 20 74 enablement on t
24a0: 68 65 20 6f 70 74 69 6f 6e 73 5f 65 6e 61 62 6c he options_enabl
24b0: 65 64 0a 23 20 6c 69 73 74 2e 20 49 66 20 6e 6f ed.# list. If no
24c0: 6e 65 20 69 73 20 66 6f 75 6e 64 20 77 65 20 64 ne is found we d
24d0: 65 66 61 75 6c 74 20 74 6f 20 69 67 6e 6f 72 69 efault to ignori
24e0: 6e 67 20 74 68 65 20 63 6f 6e 74 65 6e 74 73 20 ng the contents
24f0: 6f 66 20 74 68 65 20 62 6c 6f 63 6b 2e 0a 23 0a of the block..#.
2500: 23 20 54 68 65 20 6e 6f 74 5f 64 69 73 61 62 6c # The not_disabl
2510: 65 64 20 62 6c 6f 63 6b 20 6c 6f 6f 6b 73 20 66 ed block looks f
2520: 6f 72 20 61 6e 20 65 78 70 6c 69 63 69 74 20 64 or an explicit d
2530: 69 73 61 62 6c 65 6d 65 6e 74 20 6f 6e 20 74 68 isablement on th
2540: 65 0a 23 20 6f 70 74 69 6f 6e 73 5f 64 69 73 61 e.# options_disa
2550: 62 6c 65 64 20 6c 69 73 2e 20 20 49 66 20 66 6f bled lis. If fo
2560: 75 6e 64 2c 20 74 68 65 20 62 6c 6f 63 6b 20 69 und, the block i
2570: 73 20 69 67 6e 6f 72 65 64 2e 20 4f 74 68 65 72 s ignored. Other
2580: 77 69 73 65 0a 23 20 74 68 65 20 62 6c 6f 63 6b wise.# the block
2590: 20 64 65 66 61 75 6c 74 73 20 74 6f 20 62 65 69 defaults to bei
25a0: 6e 67 20 65 78 65 63 75 74 65 64 2e 0a 23 0a 23 ng executed..#.#
25b0: 20 62 65 67 69 6e 2f 65 6e 64 20 62 6c 6f 63 6b begin/end block
25c0: 73 20 63 61 6e 20 62 65 20 6e 65 73 74 65 64 2e s can be nested.
25d0: 20 20 57 65 20 74 72 61 63 6b 20 74 68 65 20 6e We track the n
25e0: 65 73 74 69 6e 67 20 77 69 74 68 20 6f 70 74 69 esting with opti
25f0: 6f 6e 73 5f 73 74 61 63 6b 2e 0a 23 20 54 65 73 ons_stack..# Tes
2600: 74 69 6e 67 20 66 6f 72 20 6f 70 74 69 6f 6e 73 ting for options
2610: 20 68 61 70 70 65 6e 73 20 77 68 65 6e 20 74 68 happens when th
2620: 65 20 62 65 67 69 6e 20 63 6f 6d 6d 61 6e 64 20 e begin command
2630: 69 73 20 65 76 61 6c 75 61 74 65 64 2e 0a 23 20 is evaluated..#
2640: 53 6f 20 63 68 61 6e 67 69 6e 67 20 61 6e 20 65 So changing an e
2650: 6e 61 62 6c 65 2f 64 69 73 61 62 6c 65 20 6f 70 nable/disable op
2660: 74 69 6f 6e 20 69 6e 73 69 64 65 20 61 20 62 65 tion inside a be
2670: 67 69 6e 2f 65 6e 64 20 62 6c 6f 63 6b 0a 23 20 gin/end block.#
2680: 74 61 6b 65 73 20 65 66 66 65 63 74 20 61 74 20 takes effect at
2690: 74 68 65 20 6e 65 78 74 20 62 65 67 69 6e 20 73 the next begin s
26a0: 74 61 74 65 6d 65 6e 74 2e 20 0a 23 20 59 6f 75 tatement. .# You
26b0: 20 63 61 6e 20 77 72 69 74 65 20 61 20 73 63 72 can write a scr
26c0: 69 70 74 20 61 73 20 66 6f 6c 6c 6f 77 73 3a 0a ipt as follows:.
26d0: 23 20 65 6e 61 62 6c 65 20 66 6f 6f 0a 23 20 62 # enable foo.# b
26e0: 65 67 69 6e 20 65 6e 61 62 6c 65 64 20 66 6f 6f egin enabled foo
26f0: 0a 23 20 23 20 43 6f 6d 6d 61 6e 64 73 20 74 6f .# # Commands to
2700: 20 65 78 65 63 75 74 65 64 0a 23 20 64 69 73 61 executed.# disa
2710: 62 6c 65 20 66 6f 6f 0a 23 20 23 20 43 6f 6d 6d ble foo.# # Comm
2720: 61 6e 64 73 20 73 74 69 6c 6c 20 62 65 69 6e 67 ands still being
2730: 20 65 78 65 63 75 74 65 64 2e 0a 23 20 62 65 67 executed..# beg
2740: 69 6e 20 65 6e 61 62 6c 65 64 20 66 6f 6f 0a 23 in enabled foo.#
2750: 20 23 20 43 6f 6d 6d 61 6e 64 73 20 74 6f 20 69 # Commands to i
2760: 67 6e 6f 72 65 0a 23 20 65 6e 64 20 65 6e 61 62 gnore.# end enab
2770: 6c 65 64 20 66 6f 6f 0a 23 20 65 6e 64 20 65 6e led foo.# end en
2780: 61 62 6c 65 64 20 66 6f 6f 0a 0a 23 20 4c 6f 63 abled foo..# Loc
2790: 61 6c 20 72 6f 75 74 69 6e 65 20 74 6f 20 70 65 al routine to pe
27a0: 72 66 6f 72 6d 20 61 20 73 61 76 65 20 6f 66 20 rform a save of
27b0: 61 20 70 72 65 2d 65 78 69 73 74 69 6e 67 20 66 a pre-existing f
27c0: 69 6c 65 0a 23 20 62 65 63 61 75 73 65 20 77 65 ile.# because we
27d0: 20 64 6f 20 74 68 69 73 20 69 6e 20 61 20 63 6f do this in a co
27e0: 75 70 6c 65 20 70 6c 61 63 65 73 0a 0a 64 65 66 uple places..def
27f0: 20 73 61 76 65 5f 69 66 5f 6e 65 65 64 65 64 28 save_if_needed(
2800: 70 61 74 68 29 3a 0a 20 20 69 66 20 6f 73 2e 70 path):. if os.p
2810: 61 74 68 2e 69 73 66 69 6c 65 28 70 61 74 68 29 ath.isfile(path)
2820: 3a 0a 20 20 20 20 73 61 76 65 5f 70 61 74 68 20 :. save_path
2830: 3d 20 70 61 74 68 20 2b 20 22 2e 73 61 76 65 22 = path + ".save"
2840: 0a 20 20 20 20 70 72 69 6e 74 28 22 50 72 65 2d . print("Pre-
2850: 65 78 69 73 74 69 6e 67 20 22 20 2b 20 70 61 74 existing " + pat
2860: 68 20 2b 20 22 20 66 6f 75 6e 64 2e 20 20 53 61 h + " found. Sa
2870: 76 69 6e 67 20 61 73 20 22 20 2b 20 70 61 74 68 ving as " + path
2880: 20 2b 20 22 2e 73 61 76 65 22 29 0a 20 20 20 20 + ".save").
2890: 69 66 20 6f 73 2e 70 61 74 68 2e 69 73 66 69 6c if os.path.isfil
28a0: 65 28 73 61 76 65 5f 70 61 74 68 29 3a 0a 20 20 e(save_path):.
28b0: 20 20 20 20 70 72 69 6e 74 28 22 4f 76 65 72 77 print("Overw
28c0: 72 69 74 69 6e 67 20 6f 6c 64 20 22 20 2b 20 70 riting old " + p
28d0: 61 74 68 20 2b 20 22 2e 73 61 76 65 22 29 0a 20 ath + ".save").
28e0: 20 20 20 20 20 6f 73 2e 72 65 6d 6f 76 65 28 73 os.remove(s
28f0: 61 76 65 5f 70 61 74 68 29 0a 20 20 20 20 6f 73 ave_path). os
2900: 2e 72 65 6e 61 6d 65 28 70 61 74 68 2c 20 73 61 .rename(path, sa
2910: 76 65 5f 70 61 74 68 29 0a 20 20 0a 64 65 66 20 ve_path). .def
2920: 76 65 72 73 69 6f 6e 5f 74 6f 5f 61 72 72 61 79 version_to_array
2930: 20 28 76 65 72 73 69 6f 6e 29 3a 0a 20 20 76 65 (version):. ve
2940: 72 73 5f 61 72 72 61 79 20 3d 20 5b 5d 0a 20 20 rs_array = [].
2950: 74 68 69 73 5f 73 74 72 20 3d 20 22 22 0a 0a 20 this_str = ""..
2960: 20 66 6f 72 20 63 20 69 6e 20 76 65 72 73 69 6f for c in versio
2970: 6e 3a 0a 20 20 20 20 69 66 20 63 20 21 3d 20 22 n:. if c != "
2980: 2e 22 3a 0a 20 20 20 20 20 20 74 68 69 73 5f 73 .":. this_s
2990: 74 72 20 2b 3d 20 63 0a 20 20 20 20 65 6c 73 65 tr += c. else
29a0: 3a 0a 20 20 20 20 20 20 76 65 72 73 5f 61 72 72 :. vers_arr
29b0: 61 79 2e 61 70 70 65 6e 64 28 74 68 69 73 5f 73 ay.append(this_s
29c0: 74 72 29 0a 20 20 20 20 20 20 74 68 69 73 5f 73 tr). this_s
29d0: 74 72 20 3d 20 22 22 0a 20 20 69 66 20 74 68 69 tr = "". if thi
29e0: 73 5f 73 74 72 20 21 3d 20 22 22 3a 20 76 65 72 s_str != "": ver
29f0: 73 5f 61 72 72 61 79 2e 61 70 70 65 6e 64 28 74 s_array.append(t
2a00: 68 69 73 5f 73 74 72 29 0a 20 20 72 65 74 75 72 his_str). retur
2a10: 6e 20 76 65 72 73 5f 61 72 72 61 79 0a 0a 0a 63 n vers_array...c
2a20: 6c 61 73 73 20 6f 73 38 73 63 72 69 70 74 3a 0a lass os8script:.
2a30: 20 20 23 20 43 6f 6e 74 61 69 6e 73 20 61 20 73 # Contains a s
2a40: 69 6d 68 20 6f 62 6a 65 63 74 2c 20 6f 74 68 65 imh object, othe
2a50: 72 20 67 6c 6f 62 61 6c 20 73 74 61 74 65 20 61 r global state a
2a60: 6e 64 20 6d 65 74 68 6f 64 73 0a 20 20 23 20 66 nd methods. # f
2a70: 6f 72 20 72 75 6e 6e 69 6e 67 20 4f 53 2f 38 20 or running OS/8
2a80: 73 63 72 69 70 74 73 20 75 6e 64 65 72 20 73 69 scripts under si
2a90: 6d 68 2e 0a 20 20 23 23 23 23 20 67 6c 6f 62 61 mh.. #### globa
2aa0: 6c 73 20 61 6e 64 20 63 6f 6e 73 74 61 6e 74 73 ls and constants
2ab0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
2ac0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
2ad0: 23 23 23 23 23 23 23 23 23 23 23 23 0a 0a 20 20 ############..
2ae0: 23 20 52 65 70 6c 69 65 73 20 74 68 61 74 20 70 # Replies that p
2af0: 61 6c 38 20 61 64 64 73 2e 0a 20 20 5f 70 61 6c al8 adds.. _pal
2b00: 38 5f 72 65 70 5f 61 64 64 73 20 3d 20 5b 0a 20 8_rep_adds = [.
2b10: 20 20 20 23 20 50 72 6f 6d 70 74 73 20 63 6f 6d # Prompts com
2b20: 65 20 66 72 6f 6d 20 74 68 65 20 65 78 69 73 74 e from the exist
2b30: 69 6e 67 20 5f 6f 73 38 5f 72 65 70 6c 69 65 73 ing _os8_replies
2b40: 0a 20 20 20 20 23 20 53 74 61 74 75 73 3a 0a 20 . # Status:.
2b50: 20 20 20 5b 22 45 52 52 4f 52 53 20 44 45 54 45 ["ERRORS DETE
2b60: 43 54 45 44 22 2c 20 22 45 52 52 4f 52 53 20 44 CTED", "ERRORS D
2b70: 45 54 45 43 54 45 44 3a 20 22 2c 20 46 61 6c 73 ETECTED: ", Fals
2b80: 65 5d 2c 0a 20 20 20 20 5b 22 4c 49 4e 4b 53 20 e],. ["LINKS
2b90: 47 45 4e 45 52 41 54 45 44 22 2c 20 22 4c 49 4e GENERATED", "LIN
2ba0: 4b 53 20 47 45 4e 45 52 41 54 45 44 3a 20 22 2c KS GENERATED: ",
2bb0: 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 23 20 45 False],. # E
2bc0: 72 72 6f 72 73 3a 0a 20 20 20 20 5b 22 42 75 66 rrors:. ["Buf
2bd0: 66 65 72 20 45 78 63 65 65 64 65 64 22 2c 20 22 fer Exceeded", "
2be0: 42 45 5c 73 2b 5c 53 2b 2e 2a 5c 72 22 2c 20 54 BE\s+\S+.*\r", T
2bf0: 72 75 65 5d 2c 0a 20 20 20 20 5b 22 43 72 65 66 rue],. ["Cref
2c00: 20 6e 6f 74 20 46 6f 75 6e 64 22 2c 20 22 43 46 not Found", "CF
2c10: 5c 73 2b 5c 53 2b 2e 2a 5c 72 22 2c 20 46 61 6c \s+\S+.*\r", Fal
2c20: 73 65 5d 2c 0a 20 20 20 20 5b 22 44 65 76 69 63 se],. ["Devic
2c30: 65 20 45 72 72 6f 72 22 2c 20 22 44 45 5c 73 2b e Error", "DE\s+
2c40: 5c 53 2b 2e 2a 5c 72 22 2c 20 54 72 75 65 5d 2c \S+.*\r", True],
2c50: 0a 20 20 20 20 5b 22 44 65 76 69 63 65 20 46 75 . ["Device Fu
2c60: 6c 6c 22 2c 20 22 44 46 5c 72 22 2c 20 54 72 75 ll", "DF\r", Tru
2c70: 65 5d 2c 0a 20 20 20 20 5b 22 49 6c 6c 65 67 61 e],. ["Illega
2c80: 6c 20 43 68 61 72 61 63 74 65 72 22 2c 20 22 49 l Character", "I
2c90: 43 5c 73 2b 5c 53 2b 2e 2a 5c 72 22 2c 20 46 61 C\s+\S+.*\r", Fa
2ca0: 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 49 6c 6c 65 lse],. ["Ille
2cb0: 67 61 6c 20 72 65 2d 44 65 66 69 6e 69 74 69 6f gal re-Definitio
2cc0: 6e 22 2c 20 22 49 44 5c 73 2b 5c 53 2b 2e 2a 5c n", "ID\s+\S+.*\
2cd0: 72 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 r", False],.
2ce0: 5b 22 49 6c 6c 65 67 61 6c 20 45 71 75 61 6c 73 ["Illegal Equals
2cf0: 22 2c 20 22 49 45 5c 73 2b 5c 53 2b 2e 2a 5c 72 ", "IE\s+\S+.*\r
2d00: 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b ", False],. [
2d10: 22 49 6c 6c 65 67 61 6c 20 49 6e 64 69 72 65 63 "Illegal Indirec
2d20: 74 22 2c 20 22 49 49 5c 73 2b 5c 53 2b 2e 2a 5c t", "II\s+\S+.*\
2d30: 72 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 r", False],.
2d40: 5b 22 49 6c 6c 65 67 61 6c 20 50 73 65 75 64 6f ["Illegal Pseudo
2d50: 4f 70 22 2c 20 22 49 50 5c 73 2b 5c 53 2b 2e 2a Op", "IP\s+\S+.*
2d60: 5c 72 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 \r", False],.
2d70: 20 5b 22 49 6c 6c 65 67 61 6c 20 70 61 67 65 20 ["Illegal page
2d80: 5a 65 72 6f 20 72 65 66 65 72 65 6e 63 65 22 2c Zero reference",
2d90: 20 22 49 5a 5c 73 2b 5c 53 2b 2e 2a 5c 72 22 2c "IZ\s+\S+.*\r",
2da0: 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 4c False],. ["L
2db0: 6f 61 64 65 72 20 6e 6f 74 20 66 6f 75 6e 44 22 oader not founD"
2dc0: 2c 20 22 4c 44 5c 73 2b 5c 53 2b 2e 2a 5c 72 22 , "LD\s+\S+.*\r"
2dd0: 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 , False],. ["
2de0: 4c 69 6e 6b 20 47 65 6e 65 72 61 74 65 64 22 2c Link Generated",
2df0: 20 22 4c 47 5c 73 2b 5c 53 2b 2e 2a 5c 72 22 2c "LG\s+\S+.*\r",
2e00: 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 63 False],. ["c
2e10: 75 72 72 65 6e 74 20 50 61 67 65 20 45 78 63 65 urrent Page Exce
2e20: 65 64 65 64 22 2c 20 22 50 45 5c 73 2b 5c 53 2b eded", "PE\s+\S+
2e30: 2e 2a 5c 72 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 .*\r", False],.
2e40: 20 20 20 5b 22 50 48 61 73 65 20 45 72 72 6f 72 ["PHase Error
2e50: 22 2c 20 22 50 48 5c 73 2b 5c 53 2b 2e 2a 5c 72 ", "PH\s+\S+.*\r
2e60: 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b ", False],. [
2e70: 22 52 65 20 44 65 66 69 6e 69 74 69 6f 6e 22 2c "Re Definition",
2e80: 20 22 52 44 5c 73 2b 5c 53 2b 2e 2a 5c 72 22 2c "RD\s+\S+.*\r",
2e90: 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 53 False],. ["S
2ea0: 79 6d 62 6f 6c 20 74 61 62 6c 65 20 45 78 63 65 ymbol table Exce
2eb0: 65 64 65 64 22 2c 20 22 53 45 5c 73 2b 5c 53 2b eded", "SE\s+\S+
2ec0: 2e 2a 5c 72 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 .*\r", False],.
2ed0: 20 20 20 5b 22 55 6e 64 65 66 69 6e 65 64 20 4f ["Undefined O
2ee0: 72 69 67 69 6e 22 2c 20 22 55 4f 5c 73 2b 5c 53 rigin", "UO\s+\S
2ef0: 2b 2e 2a 5c 72 22 2c 20 46 61 6c 73 65 5d 2c 0a +.*\r", False],.
2f00: 20 20 20 20 5b 22 55 6e 64 65 66 69 6e 65 64 20 ["Undefined
2f10: 53 79 6d 62 6f 6c 22 2c 20 22 55 53 5c 73 2b 5c Symbol", "US\s+\
2f20: 53 2e 2a 5c 72 22 2c 20 46 61 6c 73 65 5d 2c 0a S.*\r", False],.
2f30: 20 20 20 20 5b 22 70 61 67 65 20 5a 65 72 6f 20 ["page Zero
2f40: 45 78 63 65 65 64 65 64 22 2c 20 22 5a 45 5c 73 Exceeded", "ZE\s
2f50: 2b 5c 53 2b 2e 2a 5c 72 22 2c 20 46 61 6c 73 65 +\S+.*\r", False
2f60: 5d 2c 0a 20 20 20 20 5b 22 4e 4f 54 20 46 4f 55 ],. ["NOT FOU
2f70: 4e 44 22 2c 20 22 5c 53 2b 20 4e 4f 54 20 46 4f ND", "\S+ NOT FO
2f80: 55 4e 44 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 UND", False],.
2f90: 5d 0a 20 20 0a 20 20 5f 62 75 69 6c 64 5f 72 65 ]. . _build_re
2fa0: 70 5f 61 64 64 73 20 3d 20 5b 0a 20 20 20 20 23 p_adds = [. #
2fb0: 20 50 72 6f 6d 70 74 73 3a 0a 20 20 20 20 23 20 Prompts:. #
2fc0: 41 64 64 20 74 68 65 20 42 55 49 4c 44 20 70 72 Add the BUILD pr
2fd0: 6f 6d 70 74 0a 20 20 20 20 23 20 53 75 62 74 6c ompt. # Subtl
2fe0: 65 20 70 6f 69 6e 74 3a 20 20 44 6f 6c 6c 61 72 e point: Dollar
2ff0: 20 73 69 67 6e 20 61 70 70 65 61 72 73 20 69 6e sign appears in
3000: 20 61 6c 6c 20 6b 69 6e 64 73 20 6f 66 20 6f 75 all kinds of ou
3010: 74 70 75 74 0a 20 20 20 20 23 20 73 6f 20 77 65 tput. # so we
3020: 20 74 72 79 20 74 6f 20 6d 69 6e 69 6d 69 7a 65 try to minimize
3030: 20 77 68 65 72 65 20 77 65 20 6c 6f 6f 6b 20 66 where we look f
3040: 6f 72 20 69 74 20 73 6f 20 61 73 20 74 6f 20 61 or it so as to a
3050: 76 6f 69 64 0a 20 20 20 20 23 20 63 6f 6e 66 75 void. # confu
3060: 73 69 6e 67 20 70 65 78 70 65 63 74 2e 0a 20 20 sing pexpect..
3070: 20 20 5b 22 42 55 49 4c 44 20 50 72 6f 6d 70 74 ["BUILD Prompt
3080: 22 2c 20 22 5c 6e 5c 5c 24 24 22 2c 20 54 72 75 ", "\n\\$$", Tru
3090: 65 5d 2c 0a 20 20 20 20 23 20 53 74 61 74 75 73 e],. # Status
30a0: 3a 0a 20 20 20 20 5b 22 53 59 53 20 42 55 49 4c :. ["SYS BUIL
30b0: 54 22 2c 20 22 53 59 53 20 42 55 49 4c 54 22 2c T", "SYS BUILT",
30c0: 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 57 False],. ["W
30d0: 52 49 54 45 20 5a 45 52 4f 20 44 49 52 45 43 54 RITE ZERO DIRECT
30e0: 3f 22 2c 20 22 57 52 49 54 45 20 5a 45 52 4f 20 ?", "WRITE ZERO
30f0: 44 49 52 45 43 54 5c 5c 3f 22 2c 20 46 61 6c 73 DIRECT\\?", Fals
3100: 65 5d 2c 0a 20 20 20 20 5b 22 4c 4f 41 44 20 4f e],. ["LOAD O
3110: 53 38 22 2c 20 22 4c 4f 41 44 20 4f 53 2f 38 3a S8", "LOAD OS/8:
3120: 20 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 ", False],.
3130: 5b 22 4c 4f 41 44 20 43 44 22 2c 20 22 4c 4f 41 ["LOAD CD", "LOA
3140: 44 20 43 44 3a 20 22 2c 20 46 61 6c 73 65 5d 2c D CD: ", False],
3150: 0a 20 20 20 20 23 20 45 72 72 6f 72 73 3a 0a 20 . # Errors:.
3160: 20 20 20 5b 22 42 41 44 20 41 52 47 22 2c 20 22 ["BAD ARG", "
3170: 5c 5c 3f 42 41 44 20 41 52 47 22 2c 20 46 61 6c \\?BAD ARG", Fal
3180: 73 65 5d 2c 0a 20 20 20 20 5b 22 42 41 44 20 49 se],. ["BAD I
3190: 4e 50 55 54 22 2c 20 22 5c 5c 3f 42 41 44 20 49 NPUT", "\\?BAD I
31a0: 4e 50 55 54 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 NPUT", False],.
31b0: 20 20 20 5b 22 42 41 44 20 4c 4f 41 44 22 2c 20 ["BAD LOAD",
31c0: 22 5c 5c 3f 42 41 44 20 4c 4f 41 44 22 2c 20 46 "\\?BAD LOAD", F
31d0: 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 42 41 44 alse],. ["BAD
31e0: 20 4f 52 49 47 49 4e 22 2c 20 22 5c 5c 3f 42 41 ORIGIN", "\\?BA
31f0: 44 20 4f 52 49 47 49 4e 22 2c 20 46 61 6c 73 65 D ORIGIN", False
3200: 5d 2c 0a 20 20 20 20 5b 22 43 4f 52 45 22 2c 20 ],. ["CORE",
3210: 22 5c 5c 3f 43 4f 52 45 22 2c 20 46 61 6c 73 65 "\\?CORE", False
3220: 5d 2c 0a 20 20 20 20 5b 22 44 53 4b 22 2c 20 22 ],. ["DSK", "
3230: 5c 5c 3f 44 53 4b 22 2c 20 46 61 6c 73 65 5d 2c \\?DSK", False],
3240: 0a 20 20 20 20 5b 22 48 41 4e 44 4c 45 52 53 22 . ["HANDLERS"
3250: 2c 20 22 5c 5c 3f 48 41 4e 44 4c 45 52 53 22 2c , "\\?HANDLERS",
3260: 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 5b 22 49 False],. ["I
3270: 2f 4f 20 45 52 52 22 2c 20 22 49 2f 4f 20 45 52 /O ERR", "I/O ER
3280: 52 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 R", False],.
3290: 5b 22 4e 41 4d 45 22 2c 20 22 5c 5c 3f 4e 41 4d ["NAME", "\\?NAM
32a0: 45 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 20 20 E", False],.
32b0: 5b 22 4e 4f 20 52 4f 4f 4d 22 2c 20 22 4e 4f 20 ["NO ROOM", "NO
32c0: 52 4f 4f 4d 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 ROOM", False],.
32d0: 20 20 20 5b 22 53 59 53 20 4e 4f 54 20 46 4f 55 ["SYS NOT FOU
32e0: 4e 44 22 2c 20 22 53 59 53 20 4e 4f 54 20 46 4f ND", "SYS NOT FO
32f0: 55 4e 44 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 UND", False],.
3300: 20 20 5b 22 50 4c 41 54 22 2c 20 22 5c 5c 3f 50 ["PLAT", "\\?P
3310: 4c 41 54 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 LAT", False],.
3320: 20 20 5b 22 53 59 4e 54 41 58 22 2c 20 22 5c 5c ["SYNTAX", "\\
3330: 3f 53 59 4e 54 41 58 22 2c 20 46 61 6c 73 65 5d ?SYNTAX", False]
3340: 2c 0a 20 20 20 20 5b 22 53 59 53 22 2c 20 22 5c ,. ["SYS", "\
3350: 5c 3f 53 59 53 22 2c 20 46 61 6c 73 65 5d 2c 0a \?SYS", False],.
3360: 20 20 20 20 5b 22 53 59 53 20 45 52 52 22 2c 20 ["SYS ERR",
3370: 22 53 59 53 20 45 52 52 22 2c 20 46 61 6c 73 65 "SYS ERR", False
3380: 5d 2c 0a 20 20 20 20 5b 22 46 69 6c 65 20 4e 4f ],. ["File NO
3390: 54 20 46 4f 55 4e 44 22 2c 20 22 5c 53 2b 20 4e T FOUND", "\S+ N
33a0: 4f 54 20 46 4f 55 4e 44 22 2c 20 46 61 6c 73 65 OT FOUND", False
33b0: 5d 0a 20 20 5d 0a 0a 20 20 5f 6f 63 6f 6d 70 5f ]. ].. _ocomp_
33c0: 72 65 70 5f 61 64 64 73 20 3d 20 5b 0a 20 20 20 rep_adds = [.
33d0: 20 5b 22 4e 4f 54 48 49 4e 47 20 4f 55 54 50 55 ["NOTHING OUTPU
33e0: 54 22 2c 20 22 4e 4f 54 48 49 4e 47 20 4f 55 54 T", "NOTHING OUT
33f0: 50 55 54 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 20 PUT", False],.
3400: 20 20 5b 22 52 45 4c 41 54 49 56 45 20 42 4c 4f ["RELATIVE BLO
3410: 43 4b 22 2c 20 22 52 45 4c 41 54 49 56 45 20 42 CK", "RELATIVE B
3420: 4c 4f 43 4b 22 2c 20 46 61 6c 73 65 5d 2c 0a 20 LOCK", False],.
3430: 20 20 20 5b 22 55 53 45 52 20 45 52 52 4f 52 22 ["USER ERROR"
3440: 2c 20 22 55 53 45 52 20 45 52 52 4f 52 22 2c 20 , "USER ERROR",
3450: 46 61 6c 73 65 5d 2c 0a 20 20 5d 0a 0a 20 20 23 False],. ].. #
3460: 23 23 23 20 69 6e 74 65 72 6e 5f 72 65 70 6c 69 ### intern_repli
3470: 65 73 20 23 23 23 23 23 23 23 23 23 23 23 23 23 es #############
3480: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3490: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
34a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
34b0: 23 0a 20 20 23 20 54 65 61 63 68 20 74 68 65 20 #. # Teach the
34c0: 6f 73 38 73 63 72 69 70 74 20 6f 62 6a 65 63 74 os8script object
34d0: 20 61 62 6f 75 74 20 61 6e 6f 74 68 65 72 20 73 about another s
34e0: 65 74 20 6f 66 20 72 65 70 6c 69 65 73 2e 0a 20 et of replies..
34f0: 20 23 20 52 65 74 75 72 6e 20 54 72 75 65 20 69 # Return True i
3500: 66 20 73 75 63 63 65 73 73 66 75 6c 2c 20 46 61 f successful, Fa
3510: 6c 73 65 20 69 66 20 74 68 65 20 72 65 70 6c 69 lse if the repli
3520: 65 73 20 6f 66 20 74 68 61 74 20 6e 61 6d 65 20 es of that name
3530: 61 72 65 20 61 6c 72 65 61 64 79 20 69 6e 20 70 are already in p
3540: 6c 61 63 65 0a 20 20 23 20 49 66 20 77 69 74 68 lace. # If with
3550: 5f 6f 73 38 20 69 73 20 54 72 75 65 2c 20 61 70 _os8 is True, ap
3560: 70 65 6e 64 20 74 68 65 20 73 69 6d 68 20 5f 6f pend the simh _o
3570: 73 38 5f 72 65 70 6c 69 65 73 20 61 72 72 61 79 s8_replies array
3580: 2e 0a 20 20 0a 20 20 64 65 66 20 69 6e 74 65 72 .. . def inter
3590: 6e 5f 72 65 70 6c 69 65 73 20 28 73 65 6c 66 2c n_replies (self,
35a0: 20 6e 61 6d 65 2c 20 72 65 70 6c 69 65 73 2c 20 name, replies,
35b0: 77 69 74 68 5f 6f 73 38 29 3a 0a 20 20 20 20 69 with_os8):. i
35c0: 66 20 6e 61 6d 65 20 69 6e 20 73 65 6c 66 2e 72 f name in self.r
35d0: 65 70 6c 69 65 73 3a 20 72 65 74 75 72 6e 20 46 eplies: return F
35e0: 61 6c 73 65 0a 20 20 20 20 73 65 6c 66 2e 72 65 alse. self.re
35f0: 70 6c 69 65 73 5b 6e 61 6d 65 5d 20 3d 20 72 65 plies[name] = re
3600: 70 6c 69 65 73 0a 20 20 20 20 69 66 20 77 69 74 plies. if wit
3610: 68 5f 6f 73 38 3a 20 73 65 6c 66 2e 72 65 70 6c h_os8: self.repl
3620: 69 65 73 5b 6e 61 6d 65 5d 2e 65 78 74 65 6e 64 ies[name].extend
3630: 28 73 65 6c 66 2e 73 69 6d 68 2e 5f 6f 73 38 5f (self.simh._os8_
3640: 72 65 70 6c 69 65 73 29 0a 20 20 20 20 23 20 43 replies). # C
3650: 72 65 61 74 65 20 74 68 65 20 70 72 65 2d 63 6f reate the pre-co
3660: 6d 70 69 6c 65 64 20 72 65 67 65 78 20 61 72 72 mpiled regex arr
3670: 61 79 20 74 6f 6f 2e 0a 20 20 20 20 73 65 6c 66 ay too.. self
3680: 2e 72 65 70 6c 69 65 73 5f 72 65 78 5b 6e 61 6d .replies_rex[nam
3690: 65 5d 20 3d 20 5b 5d 0a 20 20 20 20 66 6f 72 20 e] = []. for
36a0: 69 74 65 6d 20 69 6e 20 73 65 6c 66 2e 72 65 70 item in self.rep
36b0: 6c 69 65 73 5b 6e 61 6d 65 5d 3a 0a 20 20 20 20 lies[name]:.
36c0: 20 20 73 65 6c 66 2e 72 65 70 6c 69 65 73 5f 72 self.replies_r
36d0: 65 78 5b 6e 61 6d 65 5d 2e 61 70 70 65 6e 64 28 ex[name].append(
36e0: 72 65 2e 63 6f 6d 70 69 6c 65 28 69 74 65 6d 5b re.compile(item[
36f0: 31 5d 2e 65 6e 63 6f 64 65 28 29 29 29 0a 20 20 1].encode())).
3700: 20 20 72 65 74 75 72 6e 20 54 72 75 65 0a 0a 20 return True..
3710: 20 64 65 66 20 5f 5f 69 6e 69 74 5f 5f 20 28 73 def __init__ (s
3720: 65 6c 66 2c 20 73 69 6d 68 2c 20 65 6e 61 62 6c elf, simh, enabl
3730: 65 64 5f 6f 70 74 69 6f 6e 73 2c 20 64 69 73 61 ed_options, disa
3740: 62 6c 65 64 5f 6f 70 74 69 6f 6e 73 2c 20 76 65 bled_options, ve
3750: 72 62 6f 73 65 3d 46 61 6c 73 65 2c 20 64 65 62 rbose=False, deb
3760: 75 67 3d 54 72 75 65 29 3a 0a 20 20 20 20 73 65 ug=True):. se
3770: 6c 66 2e 6c 61 6e 67 5f 76 65 72 73 69 6f 6e 20 lf.lang_version
3780: 3d 20 4c 41 4e 47 5f 56 45 52 53 49 4f 4e 0a 20 = LANG_VERSION.
3790: 20 20 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 20 self.verbose
37a0: 3d 20 76 65 72 62 6f 73 65 0a 20 20 20 20 73 65 = verbose. se
37b0: 6c 66 2e 64 65 62 75 67 20 3d 20 64 65 62 75 67 lf.debug = debug
37c0: 0a 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 20 3d . self.simh =
37d0: 20 73 69 6d 68 0a 20 20 20 20 73 65 6c 66 2e 6f simh. self.o
37e0: 70 74 69 6f 6e 73 5f 65 6e 61 62 6c 65 64 20 3d ptions_enabled =
37f0: 20 65 6e 61 62 6c 65 64 5f 6f 70 74 69 6f 6e 73 enabled_options
3800: 0a 20 20 20 20 73 65 6c 66 2e 6f 70 74 69 6f 6e . self.option
3810: 73 5f 64 69 73 61 62 6c 65 64 20 3d 20 64 69 73 s_disabled = dis
3820: 61 62 6c 65 64 5f 6f 70 74 69 6f 6e 73 0a 20 20 abled_options.
3830: 20 20 0a 20 20 20 20 23 20 44 6f 20 77 65 20 6e . # Do we n
3840: 65 65 64 20 73 65 70 61 72 61 74 65 20 73 74 61 eed separate sta
3850: 63 6b 73 20 66 6f 72 20 65 6e 61 62 6c 65 64 2f cks for enabled/
3860: 64 69 73 61 62 6c 65 64 20 6f 70 74 69 6f 6e 73 disabled options
3870: 3f 0a 20 20 20 20 73 65 6c 66 2e 6f 70 74 69 6f ?. self.optio
3880: 6e 73 5f 73 74 61 63 6b 20 3d 20 5b 5d 0a 20 20 ns_stack = [].
3890: 20 20 23 20 4c 69 73 74 20 6f 66 20 73 63 72 61 # List of scra
38a0: 74 63 68 20 66 69 6c 65 73 20 74 6f 20 64 65 6c tch files to del
38b0: 65 74 65 20 77 68 65 6e 20 77 65 20 61 72 65 20 ete when we are
38c0: 64 6f 6e 65 20 77 69 74 68 20 61 6c 6c 20 73 63 done with all sc
38d0: 72 69 70 74 20 72 75 6e 73 2e 0a 20 20 20 20 73 ript runs.. s
38e0: 65 6c 66 2e 73 63 72 61 74 63 68 5f 6c 69 73 74 elf.scratch_list
38f0: 20 3d 20 5b 5d 0a 20 20 20 20 73 65 6c 66 2e 62 = []. self.b
3900: 6f 6f 74 65 64 20 3d 20 46 61 6c 73 65 0a 20 20 ooted = False.
3910: 20 20 23 20 49 6e 69 74 69 61 6c 20 6c 69 6e 65 # Initial line
3920: 20 63 6f 75 6e 74 20 73 74 61 63 6b 20 68 61 73 count stack has
3930: 20 61 20 73 69 6e 67 6c 65 20 65 6c 65 6d 65 6e a single elemen
3940: 74 2c 20 76 61 6c 75 65 20 30 0a 20 20 20 20 23 t, value 0. #
3950: 20 49 6e 20 74 68 69 73 20 77 61 79 20 77 65 20 In this way we
3960: 67 65 74 20 67 72 61 63 65 66 75 6c 20 6f 70 65 get graceful ope
3970: 72 61 74 69 6f 6e 20 77 68 65 6e 20 74 68 65 20 ration when the
3980: 41 50 49 0a 20 20 20 20 23 20 69 73 20 63 61 6c API. # is cal
3990: 6c 65 64 20 64 69 72 65 63 74 6c 79 20 77 69 74 led directly wit
39a0: 68 6f 75 74 20 68 61 76 69 6e 67 20 6f 70 65 6e hout having open
39b0: 65 64 20 61 20 73 63 72 69 70 74 20 66 69 6c 65 ed a script file
39c0: 2e 0a 20 20 20 20 73 65 6c 66 2e 6c 69 6e 65 5f .. self.line_
39d0: 63 74 5f 73 74 61 63 6b 20 3d 20 5b 30 5d 0a 0a ct_stack = [0]..
39e0: 20 20 20 20 23 20 43 72 65 61 74 65 20 74 68 65 # Create the
39f0: 20 74 61 62 6c 65 20 6f 66 20 72 65 70 6c 79 20 table of reply
3a00: 74 61 62 6c 65 73 2e 0a 20 20 20 20 23 20 45 6e tables.. # En
3a10: 61 62 6c 65 20 61 63 63 65 73 73 20 74 6f 20 74 able access to t
3a20: 68 65 20 73 69 6d 68 20 61 6e 64 20 6f 73 38 20 he simh and os8
3a30: 74 61 62 6c 65 73 20 74 68 72 6f 75 67 68 20 74 tables through t
3a40: 68 69 73 20 69 6e 74 65 72 66 61 63 65 2e 0a 20 his interface..
3a50: 20 20 20 73 65 6c 66 2e 72 65 70 6c 69 65 73 20 self.replies
3a60: 3d 20 7b 22 73 69 6d 68 22 3a 20 73 65 6c 66 2e = {"simh": self.
3a70: 73 69 6d 68 2e 5f 73 69 6d 68 5f 72 65 70 6c 69 simh._simh_repli
3a80: 65 73 2c 20 22 6f 73 38 22 3a 20 73 65 6c 66 2e es, "os8": self.
3a90: 73 69 6d 68 2e 5f 6f 73 38 5f 72 65 70 6c 69 65 simh._os8_replie
3aa0: 73 7d 0a 20 20 20 20 73 65 6c 66 2e 72 65 70 6c s}. self.repl
3ab0: 69 65 73 5f 72 65 78 20 3d 20 7b 22 73 69 6d 68 ies_rex = {"simh
3ac0: 22 3a 20 73 65 6c 66 2e 73 69 6d 68 2e 5f 73 69 ": self.simh._si
3ad0: 6d 68 5f 72 65 70 6c 69 65 73 5f 72 65 78 2c 20 mh_replies_rex,
3ae0: 22 6f 73 38 22 3a 20 73 65 6c 66 2e 73 69 6d 68 "os8": self.simh
3af0: 2e 5f 6f 73 38 5f 72 65 70 6c 69 65 73 5f 72 65 ._os8_replies_re
3b00: 78 7d 0a 20 20 20 20 0a 20 20 20 20 23 20 50 65 x}. . # Pe
3b10: 72 66 6f 72 6d 20 69 6e 74 65 72 6e 5f 72 65 70 rform intern_rep
3b20: 6c 69 65 73 20 6f 6e 20 61 6c 6c 20 6b 6e 6f 77 lies on all know
3b30: 6e 20 73 75 62 2d 63 6f 6d 6d 61 6e 64 73 2e 0a n sub-commands..
3b40: 20 20 20 20 73 65 6c 66 2e 69 6e 74 65 72 6e 5f self.intern_
3b50: 72 65 70 6c 69 65 73 28 22 62 75 69 6c 64 22 2c replies("build",
3b60: 20 73 65 6c 66 2e 5f 62 75 69 6c 64 5f 72 65 70 self._build_rep
3b70: 5f 61 64 64 73 2c 20 54 72 75 65 29 0a 20 20 20 _adds, True).
3b80: 20 73 65 6c 66 2e 69 6e 74 65 72 6e 5f 72 65 70 self.intern_rep
3b90: 6c 69 65 73 28 22 70 61 6c 38 22 2c 20 73 65 6c lies("pal8", sel
3ba0: 66 2e 5f 70 61 6c 38 5f 72 65 70 5f 61 64 64 73 f._pal8_rep_adds
3bb0: 2c 20 54 72 75 65 29 0a 20 20 20 20 73 65 6c 66 , True). self
3bc0: 2e 69 6e 74 65 72 6e 5f 72 65 70 6c 69 65 73 28 .intern_replies(
3bd0: 22 6f 63 6f 6d 70 22 2c 20 73 65 6c 66 2e 5f 6f "ocomp", self._o
3be0: 63 6f 6d 70 5f 72 65 70 5f 61 64 64 73 2c 20 54 comp_rep_adds, T
3bf0: 72 75 65 29 0a 0a 0a 20 20 23 23 23 23 20 70 61 rue)... #### pa
3c00: 74 68 5f 65 78 70 61 6e 64 20 23 23 23 23 23 23 th_expand ######
3c10: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3c20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3c30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3c40: 23 0a 20 20 23 20 53 69 6d 70 6c 65 20 6d 69 6e #. # Simple min
3c50: 64 65 64 20 76 61 72 69 61 62 6c 65 20 73 75 62 ded variable sub
3c60: 73 74 69 74 75 74 69 6f 6e 20 69 6e 20 61 20 70 stitution in a p
3c70: 61 74 68 2e 0a 20 20 23 20 41 20 70 61 74 68 20 ath.. # A path
3c80: 62 65 67 69 6e 6e 69 6e 67 20 77 69 74 68 20 61 beginning with a
3c90: 20 64 6f 6c 6c 61 72 20 73 69 67 6e 20 70 61 72 dollar sign par
3ca0: 73 65 73 20 74 68 65 20 63 68 61 72 61 63 74 65 ses the characte
3cb0: 72 73 20 62 65 74 77 65 65 6e 0a 20 20 23 20 74 rs between. # t
3cc0: 68 65 20 64 6f 6c 6c 61 72 20 73 69 67 6e 20 61 he dollar sign a
3cd0: 6e 64 20 74 68 65 20 66 69 72 73 74 20 73 6c 61 nd the first sla
3ce0: 73 68 20 73 65 65 6e 20 62 65 63 6f 6d 65 73 20 sh seen becomes
3cf0: 61 20 6e 61 6d 65 20 74 6f 0a 20 20 23 20 65 78 a name to. # ex
3d00: 70 61 6e 64 20 77 69 74 68 20 61 20 63 6f 75 70 pand with a coup
3d10: 6c 65 20 6c 6f 63 61 6c 20 6e 61 6d 65 73 3a 20 le local names:
3d20: 24 68 6f 6d 65 20 61 6e 64 20 74 68 65 20 61 6e $home and the an
3d30: 63 68 6f 72 20 64 69 72 65 63 74 6f 72 69 65 73 chor directories
3d40: 0a 20 20 23 20 64 65 66 69 6e 65 64 20 69 6e 20 . # defined in
3d50: 6c 69 62 2f 70 69 64 70 38 69 2f 64 69 72 73 2e lib/pidp8i/dirs.
3d60: 70 79 2e 0a 20 20 23 20 52 65 74 75 72 6e 73 20 py.. # Returns
3d70: 4e 6f 6e 65 20 69 66 20 74 68 65 20 65 78 70 61 None if the expa
3d80: 6e 73 69 6f 6e 20 66 61 69 6c 73 2e 20 20 54 68 nsion fails. Th
3d90: 61 74 20 73 69 67 6e 61 6c 73 20 74 68 65 20 63 at signals the c
3da0: 61 6c 6c 65 72 20 74 6f 20 66 61 69 6c 2e 0a 0a aller to fail...
3db0: 20 20 64 65 66 20 70 61 74 68 5f 65 78 70 61 6e def path_expan
3dc0: 64 20 28 73 65 6c 66 2c 20 70 61 74 68 29 3a 0a d (self, path):.
3dd0: 20 20 20 20 6d 20 3d 20 72 65 2e 6d 61 74 63 68 m = re.match
3de0: 28 5f 65 78 70 61 6e 64 61 62 6c 65 5f 72 65 2c (_expandable_re,
3df0: 20 70 61 74 68 29 0a 20 20 20 20 69 66 20 6d 20 path). if m
3e00: 3d 3d 20 4e 6f 6e 65 3a 20 72 65 74 75 72 6e 20 == None: return
3e10: 70 61 74 68 0a 20 20 20 20 76 61 72 20 3d 20 6d path. var = m
3e20: 2e 67 72 6f 75 70 28 31 29 0a 0a 20 20 20 20 76 .group(1).. v
3e30: 61 6c 20 3d 20 67 65 74 61 74 74 72 20 28 64 69 al = getattr (di
3e40: 72 73 2c 20 76 61 72 2c 20 4e 6f 6e 65 29 0a 20 rs, var, None).
3e50: 20 20 20 69 66 20 76 61 6c 20 21 3d 20 4e 6f 6e if val != Non
3e60: 65 3a 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 e:. return
3e70: 6f 73 2e 70 61 74 68 2e 6a 6f 69 6e 28 76 61 6c os.path.join(val
3e80: 2c 6d 2e 67 72 6f 75 70 28 32 29 29 0a 20 20 20 ,m.group(2)).
3e90: 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 70 72 69 else:. pri
3ea0: 6e 74 28 22 41 74 20 6c 69 6e 65 20 22 20 2b 20 nt("At line " +
3eb0: 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 str(self.line_ct
3ec0: 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 5c 0a 20 _stack[0]) + \.
3ed0: 20 20 20 20 20 20 20 22 3a 20 7b 24 22 20 2b 20 ": {$" +
3ee0: 76 61 72 20 2b 20 22 7d 20 69 73 20 6e 6f 74 20 var + "} is not
3ef0: 61 20 76 61 6c 69 64 20 70 61 74 68 20 65 78 70 a valid path exp
3f00: 61 6e 73 69 6f 6e 20 69 6e 20 22 20 2b 20 70 61 ansion in " + pa
3f10: 74 68 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e th). return
3f20: 20 4e 6f 6e 65 0a 20 20 20 20 0a 0a 20 20 23 23 None. .. ##
3f30: 23 23 20 70 72 69 6e 74 5f 65 78 70 61 6e 64 20 ## print_expand
3f40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3f50: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3f60: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
3f70: 23 23 23 23 23 23 0a 20 20 23 20 43 6c 6f 73 65 ######. # Close
3f80: 20 6b 69 6e 20 74 6f 20 70 61 74 68 5f 65 78 70 kin to path_exp
3f90: 61 6e 64 2e 20 20 54 61 6b 65 73 20 61 20 73 74 and. Takes a st
3fa0: 72 69 6e 67 20 74 68 61 74 20 6d 61 79 20 6e 61 ring that may na
3fb0: 6d 65 20 61 20 70 61 74 68 0a 20 20 23 20 73 75 me a path. # su
3fc0: 62 73 74 69 74 75 74 69 6f 6e 20 6f 72 20 74 68 bstitution or th
3fd0: 65 20 6d 61 67 69 63 20 24 76 65 72 73 69 6f 6e e magic $version
3fe0: 20 76 61 6c 75 65 20 61 6e 64 20 70 65 72 66 6f value and perfo
3ff0: 72 6d 73 20 74 68 65 20 61 70 70 72 6f 70 72 69 rms the appropri
4000: 61 74 65 0a 20 20 23 20 76 61 6c 75 65 20 73 75 ate. # value su
4010: 62 73 74 69 74 75 74 69 6f 6e 2e 0a 0a 20 20 64 bstitution... d
4020: 65 66 20 70 72 69 6e 74 5f 65 78 70 61 6e 64 20 ef print_expand
4030: 28 73 65 6c 66 2c 73 74 72 29 3a 0a 20 20 20 20 (self,str):.
4040: 65 6e 64 20 3d 20 73 74 72 2e 66 69 6e 64 28 22 end = str.find("
4050: 24 22 29 0a 20 20 20 20 69 66 20 65 6e 64 20 3d $"). if end =
4060: 3d 20 2d 31 3a 20 72 65 74 75 72 6e 20 73 74 72 = -1: return str
4070: 0a 0a 20 20 20 20 6d 20 3d 20 72 65 2e 66 69 6e .. m = re.fin
4080: 64 61 6c 6c 28 22 5c 24 5c 53 2b 22 2c 73 74 72 dall("\$\S+",str
4090: 29 0a 20 20 20 20 69 66 20 6d 20 3d 3d 20 4e 6f ). if m == No
40a0: 6e 65 3a 20 72 65 74 75 72 6e 20 73 74 72 0a 0a ne: return str..
40b0: 20 20 20 20 6f 75 74 73 74 72 20 3d 20 22 22 0a outstr = "".
40c0: 20 20 20 20 73 74 61 72 74 20 3d 20 30 0a 0a 20 start = 0..
40d0: 20 20 20 66 6f 72 20 6e 61 6d 65 20 69 6e 20 6d for name in m
40e0: 3a 0a 20 20 20 20 20 20 65 6e 64 20 3d 20 73 74 :. end = st
40f0: 72 2e 69 6e 64 65 78 28 6e 61 6d 65 2c 20 73 74 r.index(name, st
4100: 61 72 74 29 0a 20 20 20 20 20 20 6f 75 74 73 74 art). outst
4110: 72 20 2b 3d 20 73 74 72 5b 73 74 61 72 74 3a 65 r += str[start:e
4120: 6e 64 5d 0a 0a 20 20 20 20 20 20 73 75 62 20 3d nd].. sub =
4130: 20 67 65 74 61 74 74 72 20 28 64 69 72 73 2c 20 getattr (dirs,
4140: 6e 61 6d 65 5b 31 3a 5d 2c 20 4e 6f 6e 65 29 0a name[1:], None).
4150: 20 20 20 20 20 20 69 66 20 73 75 62 20 3d 3d 20 if sub ==
4160: 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 20 20 69 66 None:. if
4170: 20 6e 61 6d 65 20 3d 3d 20 22 24 76 65 72 73 69 name == "$versi
4180: 6f 6e 22 3a 20 73 75 62 20 3d 20 73 65 6c 66 2e on": sub = self.
4190: 6c 61 6e 67 5f 76 65 72 73 69 6f 6e 0a 20 20 20 lang_version.
41a0: 20 20 20 20 20 65 6c 73 65 3a 20 73 75 62 20 3d else: sub =
41b0: 20 6e 61 6d 65 0a 0a 20 20 20 20 20 20 6f 75 74 name.. out
41c0: 73 74 72 20 2b 3d 20 73 75 62 0a 20 20 20 20 20 str += sub.
41d0: 20 73 74 61 72 74 20 3d 20 65 6e 64 20 2b 20 6c start = end + l
41e0: 65 6e 28 6e 61 6d 65 29 0a 0a 20 20 20 20 72 65 en(name).. re
41f0: 74 75 72 6e 20 6f 75 74 73 74 72 0a 20 20 20 20 turn outstr.
4200: 20 20 0a 0a 20 20 23 23 23 23 20 76 65 72 73 69 .. #### versi
4210: 6f 6e 5f 74 65 73 74 20 23 23 23 23 23 23 23 23 on_test ########
4220: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4230: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4240: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 ##############.
4250: 20 23 20 43 6f 6d 70 61 72 65 20 65 61 63 68 20 # Compare each
4260: 63 6f 6d 70 6f 6e 65 6e 74 20 6f 66 20 74 68 65 component of the
4270: 20 76 65 72 73 69 6f 6e 20 74 65 73 74 20 61 67 version test ag
4280: 61 69 6e 73 20 74 68 65 20 61 63 74 75 61 6c 20 ains the actual
4290: 76 65 72 73 69 6f 6e 0a 20 20 23 20 52 65 74 75 version. # Retu
42a0: 72 6e 20 74 72 75 65 20 69 66 20 61 63 74 75 61 rn true if actua
42b0: 6c 20 76 65 72 73 69 6f 6e 20 69 73 20 67 72 65 l version is gre
42c0: 61 74 65 72 20 74 68 61 6e 20 6f 72 20 65 71 75 ater than or equ
42d0: 61 6c 20 74 6f 20 74 68 65 20 74 65 73 74 0a 20 al to the test.
42e0: 20 23 20 76 65 72 73 69 6f 6e 2e 0a 20 20 23 20 # version.. #
42f0: 43 61 6c 6c 65 72 20 76 61 6c 69 64 61 74 65 73 Caller validates
4300: 20 74 65 73 74 20 77 69 74 68 20 5f 76 65 72 73 test with _vers
4310: 69 6f 6e 5f 70 61 72 73 65 5f 72 65 20 73 6f 20 ion_parse_re so
4320: 77 65 20 6f 6e 6c 79 0a 20 20 23 20 6e 65 65 64 we only. # need
4330: 20 74 6f 20 72 65 74 75 72 6e 20 54 72 75 65 20 to return True
4340: 6f 72 20 46 61 6c 73 65 2c 20 6e 6f 74 20 65 72 or False, not er
4350: 72 6f 72 2e 0a 20 20 0a 20 20 64 65 66 20 76 65 ror.. . def ve
4360: 72 73 69 6f 6e 5f 74 65 73 74 20 28 73 65 6c 66 rsion_test (self
4370: 2c 20 74 65 73 74 29 3a 0a 20 20 20 20 74 65 73 , test):. tes
4380: 74 5f 61 72 72 61 79 20 3d 20 76 65 72 73 69 6f t_array = versio
4390: 6e 5f 74 6f 5f 61 72 72 61 79 28 74 65 73 74 29 n_to_array(test)
43a0: 0a 20 20 20 20 76 65 72 73 69 6f 6e 5f 61 72 72 . version_arr
43b0: 61 79 20 3d 20 76 65 72 73 69 6f 6e 5f 74 6f 5f ay = version_to_
43c0: 61 72 72 61 79 28 73 65 6c 66 2e 6c 61 6e 67 5f array(self.lang_
43d0: 76 65 72 73 69 6f 6e 29 0a 20 20 20 20 0a 20 20 version). .
43e0: 20 20 69 64 78 20 3d 20 30 0a 20 20 20 20 65 6e idx = 0. en
43f0: 64 70 6f 69 6e 74 20 3d 20 6c 65 6e 28 74 65 73 dpoint = len(tes
4400: 74 5f 61 72 72 61 79 29 0a 0a 20 20 20 20 77 68 t_array).. wh
4410: 69 6c 65 20 69 64 78 20 3c 20 65 6e 64 70 6f 69 ile idx < endpoi
4420: 6e 74 3a 0a 20 20 20 20 20 20 23 20 49 66 20 76 nt:. # If v
4430: 65 72 73 69 6f 6e 20 68 61 73 20 6d 6f 72 65 20 ersion has more
4440: 64 69 67 69 74 73 20 74 68 61 6e 20 74 65 73 74 digits than test
4450: 2c 20 74 68 65 20 67 72 65 61 74 65 72 20 74 68 , the greater th
4460: 61 6e 20 74 65 73 74 20 73 75 63 63 65 65 64 73 an test succeeds
4470: 2e 0a 20 20 20 20 20 20 69 66 20 69 64 78 20 3e .. if idx >
4480: 3d 20 6c 65 6e 28 76 65 72 73 69 6f 6e 5f 61 72 = len(version_ar
4490: 72 61 79 29 3a 0a 20 20 20 20 20 20 20 20 20 20 ray):.
44a0: 20 76 65 72 73 5f 69 74 65 6d 20 3d 20 22 30 22 vers_item = "0"
44b0: 0a 20 20 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 . else:.
44c0: 20 20 20 20 20 20 76 65 72 73 5f 69 74 65 6d 20 vers_item
44d0: 3d 20 76 65 72 73 69 6f 6e 5f 61 72 72 61 79 5b = version_array[
44e0: 69 64 78 5d 0a 20 20 20 20 20 20 74 65 73 74 5f idx]. test_
44f0: 69 74 65 6d 20 3d 20 74 65 73 74 5f 61 72 72 61 item = test_arra
4500: 79 5b 69 64 78 5d 0a 20 20 20 20 20 20 69 66 20 y[idx]. if
4510: 73 65 6c 66 2e 64 65 62 75 67 3a 0a 20 20 20 20 self.debug:.
4520: 20 20 20 20 70 72 69 6e 74 28 22 76 65 72 73 69 print("versi
4530: 6f 6e 5f 74 65 73 74 3a 20 76 65 72 73 5f 69 74 on_test: vers_it
4540: 65 6d 3a 20 22 20 2b 20 76 65 72 73 5f 69 74 65 em: " + vers_ite
4550: 6d 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 m + \.
4560: 20 22 2c 20 74 65 73 74 5f 69 74 65 6d 3a 20 22 ", test_item: "
4570: 20 2b 20 74 65 73 74 5f 69 74 65 6d 29 0a 0a 20 + test_item)..
4580: 20 20 20 20 20 76 65 72 73 5f 6e 75 6d 20 3d 20 vers_num =
4590: 69 6e 74 28 76 65 72 73 5f 69 74 65 6d 29 0a 20 int(vers_item).
45a0: 20 20 20 20 20 74 65 73 74 5f 6e 75 6d 20 3d 20 test_num =
45b0: 69 6e 74 28 74 65 73 74 5f 69 74 65 6d 29 0a 0a int(test_item)..
45c0: 20 20 20 20 20 20 23 20 46 69 72 73 74 20 74 69 # First ti
45d0: 6d 65 20 76 65 72 73 69 6f 6e 20 63 6f 6d 70 6f me version compo
45e0: 6e 65 74 20 67 72 65 61 74 65 72 20 74 68 61 6e net greater than
45f0: 20 74 65 73 74 20 2d 3e 20 73 75 63 63 65 73 73 test -> success
4600: 2e 0a 20 20 20 20 20 20 69 66 20 76 65 72 73 5f .. if vers_
4610: 6e 75 6d 20 3e 20 74 65 73 74 5f 6e 75 6d 3a 0a num > test_num:.
4620: 20 20 20 20 20 20 20 20 69 66 20 73 65 6c 66 2e if self.
4630: 64 65 62 75 67 3a 0a 20 20 20 20 20 20 20 20 20 debug:.
4640: 20 70 72 69 6e 74 28 22 76 65 72 73 69 6f 6e 5f print("version_
4650: 74 65 73 74 3a 20 53 75 63 63 65 73 73 3a 20 76 test: Success: v
4660: 65 72 73 69 6f 6e 20 67 72 65 61 74 65 72 20 74 ersion greater t
4670: 68 61 6e 20 74 65 73 74 2e 22 29 0a 20 20 20 20 han test.").
4680: 20 20 20 20 72 65 74 75 72 6e 20 54 72 75 65 0a return True.
4690: 20 20 20 20 20 20 23 20 46 69 72 73 74 20 74 69 # First ti
46a0: 6d 65 20 76 65 72 73 69 6f 6e 20 63 6f 6d 70 6f me version compo
46b0: 6e 65 6e 74 20 6c 65 73 73 20 74 68 61 6e 20 74 nent less than t
46c0: 65 73 74 20 2d 3e 20 66 61 69 6c 75 72 65 2e 0a est -> failure..
46d0: 20 20 20 20 20 20 65 6c 69 66 20 74 65 73 74 5f elif test_
46e0: 6e 75 6d 20 3e 20 76 65 72 73 5f 6e 75 6d 3a 0a num > vers_num:.
46f0: 20 20 20 20 20 20 20 20 69 66 20 73 65 6c 66 2e if self.
4700: 64 65 62 75 67 3a 20 70 72 69 6e 74 28 22 76 65 debug: print("ve
4710: 72 73 69 6f 6e 5f 74 65 73 74 3a 20 46 61 69 6c rsion_test: Fail
4720: 73 20 6f 6e 20 73 75 62 20 63 6f 6d 70 61 72 65 s on sub compare
4730: 2e 22 29 0a 20 20 20 20 20 20 20 20 72 65 74 75 ."). retu
4740: 72 6e 20 46 61 6c 73 65 0a 20 20 20 20 20 20 23 rn False. #
4750: 4f 74 68 65 72 77 69 73 65 20 69 73 20 65 71 75 Otherwise is equ
4760: 61 6c 2e 20 4b 65 65 70 20 67 6f 69 6e 67 2e 0a al. Keep going..
4770: 0a 20 20 20 20 20 20 69 64 78 20 2b 3d 20 31 0a . idx += 1.
4780: 20 20 20 20 23 20 4d 61 64 65 20 69 74 20 61 6c # Made it al
4790: 6c 20 74 68 65 20 77 61 79 20 74 68 72 6f 75 67 l the way throug
47a0: 68 2e 20 54 65 73 74 20 73 75 63 63 65 65 64 73 h. Test succeeds
47b0: 2e 0a 20 20 20 20 69 66 20 73 65 6c 66 2e 64 65 .. if self.de
47c0: 62 75 67 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 bug:. print
47d0: 28 22 76 65 72 73 69 6f 6e 5f 74 65 73 74 3a 20 ("version_test:
47e0: 53 75 63 63 65 73 73 2e 20 4d 61 64 65 20 69 74 Success. Made it
47f0: 20 74 68 72 75 20 74 65 73 74 20 73 74 72 69 6e thru test strin
4800: 67 2e 22 29 0a 20 20 20 20 72 65 74 75 72 6e 20 g."). return
4810: 54 72 75 65 0a 0a 20 20 20 20 20 20 20 20 20 20 True..
4820: 0a 20 20 23 23 23 23 20 62 61 73 69 63 5f 6c 69 . #### basic_li
4830: 6e 65 5f 70 61 72 73 65 20 23 23 23 23 23 23 23 ne_parse #######
4840: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4850: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
4860: 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 52 65 #########. # Re
4870: 74 75 72 6e 73 20 73 74 72 69 70 70 65 64 20 6c turns stripped l
4880: 69 6e 65 20 61 6e 64 20 61 6e 79 20 6f 74 68 65 ine and any othe
4890: 72 20 63 6c 65 61 6e 75 70 20 77 65 20 77 61 6e r cleanup we wan
48a0: 74 2e 0a 20 20 23 20 52 65 74 75 72 6e 73 20 4e t.. # Returns N
48b0: 6f 6e 65 20 69 66 20 77 65 20 73 68 6f 75 6c 64 one if we should
48c0: 20 6a 75 73 74 20 27 63 6f 6e 74 69 6e 75 65 27 just 'continue'
48d0: 20 6f 6e 20 74 6f 20 74 68 65 20 6e 65 78 74 20 on to the next
48e0: 6c 69 6e 65 2e 0a 20 20 23 20 46 69 6c 74 65 72 line.. # Filter
48f0: 73 20 6f 75 74 20 63 6f 6d 6d 65 6e 74 73 2e 0a s out comments..
4900: 20 20 23 20 50 72 6f 63 65 73 73 65 73 20 74 68 # Processes th
4910: 65 20 6f 70 74 69 6f 6e 20 62 65 67 69 6e 2f 65 e option begin/e
4920: 6e 64 20 62 6c 6f 63 6b 73 2e 0a 20 20 0a 20 20 nd blocks.. .
4930: 64 65 66 20 62 61 73 69 63 5f 6c 69 6e 65 5f 70 def basic_line_p
4940: 61 72 73 65 20 28 73 65 6c 66 2c 20 6c 69 6e 65 arse (self, line
4950: 2c 20 73 63 72 69 70 74 5f 66 69 6c 65 29 3a 0a , script_file):.
4960: 20 20 20 20 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 self.line_ct
4970: 5f 73 74 61 63 6b 5b 30 5d 20 2b 3d 20 31 0a 20 _stack[0] += 1.
4980: 20 20 20 72 65 74 76 61 6c 20 3d 20 6c 69 6e 65 retval = line
4990: 2e 73 74 72 69 70 28 29 0a 20 20 20 20 69 66 20 .strip(). if
49a0: 72 65 74 76 61 6c 20 3d 3d 20 22 22 3a 20 72 65 retval == "": re
49b0: 74 75 72 6e 20 4e 6f 6e 65 0a 20 20 20 20 65 6c turn None. el
49c0: 69 66 20 72 65 74 76 61 6c 5b 30 5d 20 3d 3d 20 if retval[0] ==
49d0: 22 23 22 3a 20 72 65 74 75 72 6e 20 4e 6f 6e 65 "#": return None
49e0: 0a 20 20 20 20 23 20 46 69 72 73 74 20 74 65 73 . # First tes
49f0: 74 20 69 66 20 77 65 20 61 72 65 20 69 6e 20 61 t if we are in a
4a00: 20 62 65 67 69 6e 20 6f 70 74 69 6f 6e 20 62 6c begin option bl
4a10: 6f 63 6b 0a 20 20 20 20 6d 20 3d 20 72 65 2e 6d ock. m = re.m
4a20: 61 74 63 68 20 28 5f 62 65 67 69 6e 5f 65 6e 5f atch (_begin_en_
4a30: 64 69 73 5f 63 6f 6d 6d 5f 72 65 2c 20 72 65 74 dis_comm_re, ret
4a40: 76 61 6c 29 0a 20 20 20 20 69 66 20 6d 20 21 3d val). if m !=
4a50: 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 65 6e 5f None:. en_
4a60: 64 69 73 20 3d 20 6d 2e 67 72 6f 75 70 28 31 29 dis = m.group(1)
4a70: 0a 20 20 20 20 20 20 72 65 73 74 20 3d 20 6d 2e . rest = m.
4a80: 67 72 6f 75 70 28 32 29 0a 20 20 20 20 20 20 69 group(2). i
4a90: 66 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 3a 20 f self.verbose:
4aa0: 70 72 69 6e 74 28 22 4c 69 6e 65 20 22 20 2b 20 print("Line " +
4ab0: 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 str(self.line_ct
4ac0: 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 5c 0a 20 _stack[0]) + \.
4ad0: 20 20 20 20 20 20 20 20 22 3a 20 64 6f 69 6e 67 ": doing
4ae0: 5f 62 65 67 69 6e 5f 6f 70 74 69 6f 6e 3a 20 22 _begin_option: "
4af0: 20 2b 20 65 6e 5f 64 69 73 20 2b 20 22 20 22 20 + en_dis + " "
4b00: 2b 20 72 65 73 74 29 0a 20 20 20 20 20 20 69 66 + rest). if
4b10: 20 73 65 6c 66 2e 64 65 62 75 67 3a 0a 20 20 20 self.debug:.
4b20: 20 20 20 20 20 70 72 69 6e 74 28 22 6f 70 74 69 print("opti
4b30: 6f 6e 73 5f 65 6e 61 62 6c 65 64 3a 20 22 20 2b ons_enabled: " +
4b40: 20 73 74 72 20 28 73 65 6c 66 2e 6f 70 74 69 6f str (self.optio
4b50: 6e 73 5f 65 6e 61 62 6c 65 64 29 29 0a 20 20 20 ns_enabled)).
4b60: 20 20 20 20 20 70 72 69 6e 74 28 22 6f 70 74 69 print("opti
4b70: 6f 6e 73 5f 64 69 73 61 62 6c 65 64 3a 20 22 20 ons_disabled: "
4b80: 2b 20 73 74 72 20 28 73 65 6c 66 2e 6f 70 74 69 + str (self.opti
4b90: 6f 6e 73 5f 64 69 73 61 62 6c 65 64 29 29 0a 20 ons_disabled)).
4ba0: 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 6f 70 print("op
4bb0: 74 69 6f 6e 73 5f 73 74 61 63 6b 3a 20 22 20 2b tions_stack: " +
4bc0: 20 73 74 72 28 73 65 6c 66 2e 6f 70 74 69 6f 6e str(self.option
4bd0: 73 5f 73 74 61 63 6b 29 29 0a 0a 20 20 20 20 20 s_stack))..
4be0: 20 76 65 72 73 5f 6d 61 74 63 68 20 3d 20 46 61 vers_match = Fa
4bf0: 6c 73 65 0a 20 20 20 20 20 20 69 66 20 65 6e 5f lse. if en_
4c00: 64 69 73 20 3d 3d 20 22 76 65 72 73 69 6f 6e 22 dis == "version"
4c10: 3a 0a 20 20 20 20 20 20 20 20 23 20 43 68 65 63 :. # Chec
4c20: 6b 20 66 6f 72 20 6d 61 6c 2d 66 6f 72 6d 65 64 k for mal-formed
4c30: 20 76 65 72 73 69 6f 6e 20 6d 61 74 63 68 20 66 version match f
4c40: 69 72 73 74 0a 20 20 20 20 20 20 20 20 69 66 20 irst. if
4c50: 72 65 2e 6d 61 74 63 68 20 28 5f 76 65 72 73 69 re.match (_versi
4c60: 6f 6e 5f 70 61 72 73 65 5f 72 65 2c 20 72 65 73 on_parse_re, res
4c70: 74 29 20 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 t) == None:.
4c80: 20 20 20 20 20 20 70 72 69 6e 74 28 22 4d 61 6c print("Mal
4c90: 2d 66 6f 72 6d 65 64 20 76 65 72 73 69 6f 6e 20 -formed version
4ca0: 6d 61 74 63 68 20 73 74 72 69 6e 67 20 7b 22 20 match string {"
4cb0: 2b 20 72 65 73 74 20 2b 20 22 7d 20 61 74 20 6c + rest + "} at l
4cc0: 69 6e 65 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 ine " + \.
4cd0: 20 20 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c str(self.l
4ce0: 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 ine_ct_stack[0])
4cf0: 20 2b 20 22 2e 20 49 67 6e 6f 72 69 6e 67 20 74 + ". Ignoring t
4d00: 68 69 73 20 62 6c 6f 63 6b 2e 22 29 0a 20 20 20 his block.").
4d10: 20 20 20 20 20 20 20 73 65 6c 66 2e 69 67 6e 6f self.igno
4d20: 72 65 5f 74 6f 5f 73 75 62 63 6f 6d 6d 5f 65 6e re_to_subcomm_en
4d30: 64 20 28 72 65 74 76 61 6c 2c 20 73 63 72 69 70 d (retval, scrip
4d40: 74 5f 66 69 6c 65 2c 20 65 6e 5f 64 69 73 20 2b t_file, en_dis +
4d50: 20 22 20 22 20 2b 20 72 65 73 74 29 0a 20 20 20 " " + rest).
4d60: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 4e 6f return No
4d70: 6e 65 0a 20 20 20 20 20 20 20 20 76 65 72 73 5f ne. vers_
4d80: 6d 61 74 63 68 20 3d 20 73 65 6c 66 2e 76 65 72 match = self.ver
4d90: 73 69 6f 6e 5f 74 65 73 74 20 28 72 65 73 74 29 sion_test (rest)
4da0: 0a 20 20 20 20 20 20 20 20 69 66 20 76 65 72 73 . if vers
4db0: 5f 6d 61 74 63 68 3a 0a 20 20 20 20 20 20 20 20 _match:.
4dc0: 20 20 23 20 42 6c 6f 63 6b 20 69 73 20 61 63 74 # Block is act
4dd0: 69 76 65 2e 20 57 65 20 70 75 73 68 20 69 74 20 ive. We push it
4de0: 6f 6e 74 6f 20 74 68 65 20 73 74 61 63 6b 0a 20 onto the stack.
4df0: 20 20 20 20 20 20 20 20 20 69 66 20 73 65 6c 66 if self
4e00: 2e 64 65 62 75 67 3a 0a 20 20 20 20 20 20 20 20 .debug:.
4e10: 20 20 20 20 70 72 69 6e 74 28 22 50 75 73 68 69 print("Pushi
4e20: 6e 67 20 76 65 72 73 69 6f 6e 20 65 6e 61 62 6c ng version enabl
4e30: 65 64 20 62 6c 6f 63 6b 20 22 20 2b 20 72 65 73 ed block " + res
4e40: 74 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 t + \.
4e50: 20 20 20 20 20 20 22 20 6f 6e 74 6f 20 6f 70 74 " onto opt
4e60: 69 6f 6e 73 5f 73 74 61 63 6b 22 29 0a 20 20 20 ions_stack").
4e70: 20 20 20 20 20 20 20 73 65 6c 66 2e 6f 70 74 69 self.opti
4e80: 6f 6e 73 5f 73 74 61 63 6b 2e 69 6e 73 65 72 74 ons_stack.insert
4e90: 28 30 2c 20 72 65 73 74 29 0a 20 20 20 20 20 20 (0, rest).
4ea0: 20 20 20 20 69 66 20 73 65 6c 66 2e 64 65 62 75 if self.debu
4eb0: 67 3a 20 70 72 69 6e 74 28 22 20 6e 65 77 20 6f g: print(" new o
4ec0: 70 74 69 6f 6e 73 5f 73 74 61 63 6b 3a 20 22 20 ptions_stack: "
4ed0: 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20 + \.
4ee0: 20 20 73 74 72 28 73 65 6c 66 2e 6f 70 74 69 6f str(self.optio
4ef0: 6e 73 5f 73 74 61 63 6b 29 29 0a 20 20 20 20 20 ns_stack)).
4f00: 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 20 else:.
4f10: 20 20 20 23 20 4f 70 74 69 6f 6e 20 69 73 20 69 # Option is i
4f20: 6e 61 63 74 69 76 65 2e 20 20 49 67 6e 6f 72 65 nactive. Ignore
4f30: 20 61 6c 6c 20 73 75 62 73 65 71 65 6e 74 20 6c all subseqent l
4f40: 69 6e 65 73 0a 20 20 20 20 20 20 20 20 20 20 23 ines. #
4f50: 20 75 6e 74 69 6c 20 77 65 20 67 65 74 20 74 6f until we get to
4f60: 20 61 6e 20 65 6e 64 20 63 6f 6d 6d 61 6e 64 20 an end command
4f70: 74 68 61 74 20 6d 61 74 63 68 65 73 20 6f 75 72 that matches our
4f80: 20 6f 70 74 69 6f 6e 2e 0a 20 20 20 20 20 20 20 option..
4f90: 20 20 20 73 65 6c 66 2e 69 67 6e 6f 72 65 5f 74 self.ignore_t
4fa0: 6f 5f 73 75 62 63 6f 6d 6d 5f 65 6e 64 20 28 72 o_subcomm_end (r
4fb0: 65 74 76 61 6c 2c 20 73 63 72 69 70 74 5f 66 69 etval, script_fi
4fc0: 6c 65 2c 20 65 6e 5f 64 69 73 20 2b 20 22 20 22 le, en_dis + " "
4fd0: 20 2b 20 72 65 73 74 29 0a 20 20 20 20 20 20 20 + rest).
4fe0: 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 20 20 20 return None.
4ff0: 20 20 20 20 20 0a 20 20 20 20 20 20 65 6c 69 66 . elif
5000: 20 65 6e 5f 64 69 73 20 3d 3d 20 22 65 6e 61 62 en_dis == "enab
5010: 6c 65 64 22 3a 0a 20 20 20 20 20 20 20 20 69 66 led":. if
5020: 20 72 65 73 74 20 69 6e 20 73 65 6c 66 2e 6f 70 rest in self.op
5030: 74 69 6f 6e 73 5f 65 6e 61 62 6c 65 64 3a 0a 20 tions_enabled:.
5040: 20 20 20 20 20 20 20 20 20 23 20 42 6c 6f 63 6b # Block
5050: 20 69 73 20 61 63 74 69 76 65 2e 20 57 65 20 70 is active. We p
5060: 75 73 68 20 69 74 20 6f 6e 74 6f 20 74 68 65 20 ush it onto the
5070: 73 74 61 63 6b 0a 20 20 20 20 20 20 20 20 20 20 stack.
5080: 69 66 20 73 65 6c 66 2e 64 65 62 75 67 3a 0a 20 if self.debug:.
5090: 20 20 20 20 20 20 20 20 20 20 20 20 20 70 72 69 pri
50a0: 6e 74 28 22 50 75 73 68 69 6e 67 20 65 6e 61 62 nt("Pushing enab
50b0: 6c 65 64 20 62 6c 6f 63 6b 20 22 20 2b 20 72 65 led block " + re
50c0: 73 74 20 2b 20 22 20 6f 6e 74 6f 20 6f 70 74 69 st + " onto opti
50d0: 6f 6e 73 5f 73 74 61 63 6b 22 29 0a 20 20 20 20 ons_stack").
50e0: 20 20 20 20 20 20 73 65 6c 66 2e 6f 70 74 69 6f self.optio
50f0: 6e 73 5f 73 74 61 63 6b 2e 69 6e 73 65 72 74 28 ns_stack.insert(
5100: 30 2c 20 72 65 73 74 29 0a 20 20 20 20 20 20 20 0, rest).
5110: 20 20 20 69 66 20 73 65 6c 66 2e 64 65 62 75 67 if self.debug
5120: 3a 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 72 :. pr
5130: 69 6e 74 28 22 6e 65 77 20 6f 70 74 69 6f 6e 73 int("new options
5140: 5f 73 74 61 63 6b 3a 20 22 20 2b 20 73 74 72 28 _stack: " + str(
5150: 73 65 6c 66 2e 6f 70 74 69 6f 6e 73 5f 73 74 61 self.options_sta
5160: 63 6b 29 29 0a 20 20 20 20 20 20 20 20 65 6c 73 ck)). els
5170: 65 3a 0a 20 20 20 20 20 20 20 20 20 20 23 20 4f e:. # O
5180: 70 74 69 6f 6e 20 69 73 20 69 6e 61 63 74 69 76 ption is inactiv
5190: 65 2e 20 20 49 67 6e 6f 72 65 20 61 6c 6c 20 73 e. Ignore all s
51a0: 75 62 73 65 71 65 6e 74 20 6c 69 6e 65 73 0a 20 ubseqent lines.
51b0: 20 20 20 20 20 20 20 20 20 23 20 75 6e 74 69 6c # until
51c0: 20 77 65 20 67 65 74 20 74 6f 20 61 6e 20 65 6e we get to an en
51d0: 64 20 63 6f 6d 6d 61 6e 64 20 74 68 61 74 20 6d d command that m
51e0: 61 74 63 68 65 73 20 6f 75 72 20 6f 70 74 69 6f atches our optio
51f0: 6e 2e 0a 20 20 20 20 20 20 20 20 20 20 73 65 6c n.. sel
5200: 66 2e 69 67 6e 6f 72 65 5f 74 6f 5f 73 75 62 63 f.ignore_to_subc
5210: 6f 6d 6d 5f 65 6e 64 20 28 72 65 74 76 61 6c 2c omm_end (retval,
5220: 20 73 63 72 69 70 74 5f 66 69 6c 65 2c 20 65 6e script_file, en
5230: 5f 64 69 73 20 2b 20 22 20 22 20 2b 20 72 65 73 _dis + " " + res
5240: 74 29 0a 0a 20 20 20 20 20 20 20 20 72 65 74 75 t).. retu
5250: 72 6e 20 4e 6f 6e 65 0a 20 20 20 20 20 20 23 20 rn None. #
5260: 6f 6e 6c 79 20 6f 74 68 65 72 20 63 68 6f 69 63 only other choic
5270: 65 20 69 73 20 64 69 73 61 62 6c 65 64 20 62 65 e is disabled be
5280: 63 61 75 73 65 20 6f 66 20 6f 75 72 20 72 65 67 cause of our reg
5290: 65 78 2e 0a 20 20 20 20 20 20 65 6c 73 65 3a 0a ex.. else:.
52a0: 20 20 20 20 20 20 20 20 69 66 20 72 65 73 74 20 if rest
52b0: 6e 6f 74 20 69 6e 20 73 65 6c 66 2e 6f 70 74 69 not in self.opti
52c0: 6f 6e 73 5f 64 69 73 61 62 6c 65 64 3a 0a 20 20 ons_disabled:.
52d0: 20 20 20 20 20 20 20 20 23 20 42 6c 6f 63 6b 20 # Block
52e0: 64 65 66 61 75 6c 74 73 20 74 6f 20 61 63 74 69 defaults to acti
52f0: 76 65 2e 20 57 65 20 70 75 73 68 20 69 74 20 6f ve. We push it o
5300: 6e 74 6f 20 74 68 65 20 73 74 61 63 6b 0a 20 20 nto the stack.
5310: 20 20 20 20 20 20 20 20 69 66 20 73 65 6c 66 2e if self.
5320: 64 65 62 75 67 3a 0a 20 20 20 20 20 20 20 20 20 debug:.
5330: 20 20 20 70 72 69 6e 74 28 22 50 75 73 68 69 6e print("Pushin
5340: 67 20 6e 6f 74 5f 64 69 73 61 62 6c 65 64 20 62 g not_disabled b
5350: 6c 6f 63 6b 20 22 20 2b 20 72 65 73 74 20 2b 20 lock " + rest +
5360: 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 \.
5370: 20 20 22 20 6f 6e 74 6f 20 6f 70 74 69 6f 6e 73 " onto options
5380: 5f 73 74 61 63 6b 22 29 0a 20 20 20 20 20 20 20 _stack").
5390: 20 20 20 73 65 6c 66 2e 6f 70 74 69 6f 6e 73 5f self.options_
53a0: 73 74 61 63 6b 2e 69 6e 73 65 72 74 28 30 2c 20 stack.insert(0,
53b0: 72 65 73 74 29 0a 20 20 20 20 20 20 20 20 20 20 rest).
53c0: 69 66 20 73 65 6c 66 2e 64 65 62 75 67 3a 0a 20 if self.debug:.
53d0: 20 20 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 print
53e0: 28 22 6e 65 77 20 6f 70 74 69 6f 6e 73 5f 73 74 ("new options_st
53f0: 61 63 6b 3a 20 22 20 2b 20 73 74 72 28 73 65 6c ack: " + str(sel
5400: 66 2e 6f 70 74 69 6f 6e 73 5f 73 74 61 63 6b 29 f.options_stack)
5410: 29 0a 20 20 20 20 20 20 20 20 65 6c 73 65 3a 0a ). else:.
5420: 20 20 20 20 20 20 20 20 20 20 23 20 42 6c 6f 63 # Bloc
5430: 6b 20 69 73 20 69 6e 61 63 74 69 76 65 2e 20 20 k is inactive.
5440: 49 67 6e 6f 72 65 20 61 6c 6c 20 73 75 62 73 65 Ignore all subse
5450: 71 65 6e 74 20 6c 69 6e 65 73 0a 20 20 20 20 20 qent lines.
5460: 20 20 20 20 20 23 20 75 6e 74 69 6c 20 77 65 20 # until we
5470: 67 65 74 20 74 6f 20 61 6e 20 65 6e 64 20 63 6f get to an end co
5480: 6d 6d 61 6e 64 20 74 68 61 74 20 6d 61 74 63 68 mmand that match
5490: 65 73 20 6f 75 72 20 6f 70 74 69 6f 6e 2e 0a 20 es our option..
54a0: 20 20 20 20 20 20 20 20 20 73 65 6c 66 2e 69 67 self.ig
54b0: 6e 6f 72 65 5f 74 6f 5f 73 75 62 63 6f 6d 6d 5f nore_to_subcomm_
54c0: 65 6e 64 20 28 72 65 74 76 61 6c 2c 20 73 63 72 end (retval, scr
54d0: 69 70 74 5f 66 69 6c 65 2c 20 65 6e 5f 64 69 73 ipt_file, en_dis
54e0: 20 2b 20 22 20 22 20 2b 20 72 65 73 74 29 0a 20 + " " + rest).
54f0: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 4e 6f return No
5500: 6e 65 0a 20 20 0a 20 20 20 20 6d 20 3d 20 72 65 ne. . m = re
5510: 2e 6d 61 74 63 68 28 5f 65 6e 64 5f 65 6e 5f 64 .match(_end_en_d
5520: 69 73 5f 63 6f 6d 6d 5f 72 65 2c 20 72 65 74 76 is_comm_re, retv
5530: 61 6c 29 0a 20 20 20 20 69 66 20 6d 20 21 3d 20 al). if m !=
5540: 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 72 65 73 74 None:. rest
5550: 20 3d 20 6d 2e 67 72 6f 75 70 28 32 29 0a 20 20 = m.group(2).
5560: 20 20 20 20 69 66 20 73 65 6c 66 2e 76 65 72 62 if self.verb
5570: 6f 73 65 3a 0a 20 20 20 20 20 20 20 20 70 72 69 ose:. pri
5580: 6e 74 28 22 4c 69 6e 65 20 22 20 2b 20 73 74 72 nt("Line " + str
5590: 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 (self.line_ct_st
55a0: 61 63 6b 5b 30 5d 29 20 2b 20 22 3a 20 65 6e 64 ack[0]) + ": end
55b0: 20 72 65 73 74 20 3d 20 22 20 2b 20 72 65 73 74 rest = " + rest
55c0: 29 0a 20 20 20 20 20 20 69 66 20 28 72 65 73 74 ). if (rest
55d0: 20 3d 3d 20 4e 6f 6e 65 20 6f 72 20 72 65 73 74 == None or rest
55e0: 20 3d 3d 20 22 22 29 3a 0a 20 20 20 20 20 20 20 == ""):.
55f0: 20 70 72 69 6e 74 28 22 57 61 72 6e 69 6e 67 21 print("Warning!
5600: 20 6f 70 74 69 6f 6e 20 65 6e 64 20 73 74 61 74 option end stat
5610: 65 6d 65 6e 74 20 61 74 20 6c 69 6e 65 20 22 20 ement at line "
5620: 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 73 74 + \. st
5630: 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 r(self.line_ct_s
5640: 74 61 63 6b 5b 30 5d 29 20 2b 20 22 20 65 6e 63 tack[0]) + " enc
5650: 6f 75 6e 74 65 72 65 64 20 77 69 74 68 20 6e 6f ountered with no
5660: 20 61 72 67 75 6d 65 6e 74 2e 22 29 0a 20 20 20 argument.").
5670: 20 20 20 20 20 72 65 74 75 72 6e 20 4e 6f 6e 65 return None
5680: 0a 20 20 20 20 20 20 69 66 20 6c 65 6e 28 73 65 . if len(se
5690: 6c 66 2e 6f 70 74 69 6f 6e 73 5f 73 74 61 63 6b lf.options_stack
56a0: 29 20 3d 3d 20 30 3a 0a 20 20 20 20 20 20 20 20 ) == 0:.
56b0: 70 72 69 6e 74 28 22 57 61 72 6e 69 6e 67 21 20 print("Warning!
56c0: 6f 70 74 69 6f 6e 20 65 6e 64 20 73 74 61 74 65 option end state
56d0: 6d 65 6e 74 20 61 74 20 6c 69 6e 65 20 22 20 2b ment at line " +
56e0: 20 5c 0a 20 20 20 20 20 20 20 20 20 20 73 74 72 \. str
56f0: 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 (self.line_ct_st
5700: 61 63 6b 5b 30 5d 29 20 2b 20 5c 0a 20 20 20 20 ack[0]) + \.
5710: 20 20 20 20 20 20 22 20 66 6f 75 6e 64 20 77 69 " found wi
5720: 74 68 20 6e 6f 20 6d 61 74 63 68 69 6e 67 20 62 th no matching b
5730: 65 67 69 6e 20 66 6f 72 20 6f 70 74 69 6f 6e 3a egin for option:
5740: 20 22 20 2b 20 72 65 73 74 29 0a 20 20 20 20 20 " + rest).
5750: 20 20 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 20 return None.
5760: 20 20 20 20 20 69 66 20 72 65 73 74 20 21 3d 20 if rest !=
5770: 73 65 6c 66 2e 6f 70 74 69 6f 6e 73 5f 73 74 61 self.options_sta
5780: 63 6b 5b 30 5d 3a 0a 20 20 20 20 20 20 20 20 70 ck[0]:. p
5790: 72 69 6e 74 28 22 57 61 72 6e 69 6e 67 21 20 4d rint("Warning! M
57a0: 69 73 6d 61 74 63 68 65 64 20 6f 70 74 69 6f 6e ismatched option
57b0: 20 62 65 67 69 6e 2f 65 6e 64 20 67 72 6f 75 70 begin/end group
57c0: 20 61 74 20 6c 69 6e 65 20 22 20 2b 20 5c 0a 20 at line " + \.
57d0: 20 20 20 20 20 20 20 20 20 73 74 72 28 73 65 6c str(sel
57e0: 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b f.line_ct_stack[
57f0: 30 5d 29 20 2b 20 22 2e 20 43 75 72 72 65 6e 74 0]) + ". Current
5800: 6c 79 20 69 6e 73 69 64 65 20 6f 70 74 69 6f 6e ly inside option
5810: 3a 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 : " + \.
5820: 20 20 73 65 6c 66 2e 6f 70 74 69 6f 6e 73 5f 73 self.options_s
5830: 74 61 63 6b 5b 30 5d 20 2b 20 22 20 6e 6f 74 20 tack[0] + " not
5840: 22 20 2b 20 72 65 73 74 29 0a 20 20 20 20 20 20 " + rest).
5850: 20 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a 20 20 return None.
5860: 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 else:.
5870: 20 20 69 66 20 73 65 6c 66 2e 64 65 62 75 67 3a if self.debug:
5880: 20 70 72 69 6e 74 28 22 50 6f 70 70 69 6e 67 20 print("Popping
5890: 22 20 2b 20 73 65 6c 66 2e 6f 70 74 69 6f 6e 73 " + self.options
58a0: 5f 73 74 61 63 6b 5b 30 5d 29 0a 20 20 20 20 20 _stack[0]).
58b0: 20 20 20 73 65 6c 66 2e 6f 70 74 69 6f 6e 73 5f self.options_
58c0: 73 74 61 63 6b 2e 70 6f 70 28 30 29 0a 20 20 20 stack.pop(0).
58d0: 20 20 20 20 20 69 66 20 73 65 6c 66 2e 64 65 62 if self.deb
58e0: 75 67 3a 0a 20 20 20 20 20 20 20 20 20 20 70 72 ug:. pr
58f0: 69 6e 74 28 22 6e 65 77 20 6f 70 74 69 6f 6e 73 int("new options
5900: 5f 73 74 61 63 6b 3a 20 22 20 2b 20 73 74 72 28 _stack: " + str(
5910: 73 65 6c 66 2e 6f 70 74 69 6f 6e 73 5f 73 74 61 self.options_sta
5920: 63 6b 29 29 0a 20 20 20 20 20 20 20 20 72 65 74 ck)). ret
5930: 75 72 6e 20 4e 6f 6e 65 0a 20 20 0a 20 20 20 20 urn None. .
5940: 72 65 74 75 72 6e 20 72 65 74 76 61 6c 0a 20 20 return retval.
5950: 0a 20 20 0a 20 20 23 23 23 23 20 69 67 6e 6f 72 . . #### ignor
5960: 65 5f 74 6f 5f 73 75 62 63 6f 6d 6d 5f 65 6e 64 e_to_subcomm_end
5970: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
5980: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5990: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 0a ############. .
59a0: 20 20 64 65 66 20 69 67 6e 6f 72 65 5f 74 6f 5f def ignore_to_
59b0: 73 75 62 63 6f 6d 6d 5f 65 6e 64 20 28 73 65 6c subcomm_end (sel
59c0: 66 2c 20 6f 6c 64 5f 6c 69 6e 65 2c 20 73 63 72 f, old_line, scr
59d0: 69 70 74 5f 66 69 6c 65 2c 20 65 6e 64 5f 73 74 ipt_file, end_st
59e0: 72 29 3a 0a 20 20 20 20 69 66 20 73 65 6c 66 2e r):. if self.
59f0: 64 65 62 75 67 3a 20 70 72 69 6e 74 28 22 69 67 debug: print("ig
5a00: 6e 6f 72 65 20 74 6f 3a 20 22 20 2b 20 65 6e 64 nore to: " + end
5a10: 5f 73 74 72 29 0a 20 20 20 20 66 6f 72 20 6c 69 _str). for li
5a20: 6e 65 20 69 6e 20 73 63 72 69 70 74 5f 66 69 6c ne in script_fil
5a30: 65 3a 0a 20 20 20 20 20 20 73 65 6c 66 2e 6c 69 e:. self.li
5a40: 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 20 2b ne_ct_stack[0] +
5a50: 3d 20 31 0a 20 20 20 20 20 20 6c 69 6e 65 20 3d = 1. line =
5a60: 20 6c 69 6e 65 2e 73 74 72 69 70 28 29 0a 20 20 line.strip().
5a70: 20 20 20 20 69 66 20 73 65 6c 66 2e 76 65 72 62 if self.verb
5a80: 6f 73 65 3a 0a 20 20 20 20 20 20 20 20 70 72 69 ose:. pri
5a90: 6e 74 28 22 49 67 6e 6f 72 65 20 6c 69 6e 65 20 nt("Ignore line
5aa0: 22 20 2b 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e " + str(self.lin
5ab0: 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b e_ct_stack[0]) +
5ac0: 20 22 3a 20 22 20 2b 20 6c 69 6e 65 29 0a 20 20 ": " + line).
5ad0: 20 20 20 20 0a 20 20 20 20 20 20 6d 20 3d 20 72 . m = r
5ae0: 65 2e 6d 61 74 63 68 28 5f 65 6e 64 5f 63 6f 6d e.match(_end_com
5af0: 6d 5f 72 65 2c 20 6c 69 6e 65 29 0a 20 20 20 20 m_re, line).
5b00: 20 20 69 66 20 6d 20 3d 3d 20 4e 6f 6e 65 3a 20 if m == None:
5b10: 63 6f 6e 74 69 6e 75 65 0a 20 20 0a 20 20 20 20 continue. .
5b20: 20 20 72 65 73 74 20 3d 20 6d 2e 67 72 6f 75 70 rest = m.group
5b30: 28 31 29 0a 20 20 20 20 20 20 69 66 20 72 65 73 (1). if res
5b40: 74 20 3d 3d 20 4e 6f 6e 65 3a 20 72 65 73 74 20 t == None: rest
5b50: 3d 20 22 22 0a 20 20 20 20 20 20 0a 20 20 20 20 = "". .
5b60: 20 20 69 66 20 72 65 73 74 20 3d 3d 20 65 6e 64 if rest == end
5b70: 5f 73 74 72 3a 20 72 65 74 75 72 6e 0a 20 20 0a _str: return. .
5b80: 20 20 0a 20 20 23 23 23 23 20 69 6e 63 6c 75 64 . #### includ
5b90: 65 5f 63 6f 6d 6d 61 6e 64 20 23 23 23 23 23 23 e_command ######
5ba0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5bb0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5bc0: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 ###########. #
5bd0: 43 61 6c 6c 20 72 75 6e 5f 73 63 72 69 70 74 5f Call run_script_
5be0: 66 69 6c 65 20 72 65 63 75 72 73 69 76 65 6c 79 file recursively
5bf0: 20 6f 6e 20 74 68 65 20 66 69 6c 65 20 70 61 74 on the file pat
5c00: 68 20 70 72 6f 76 69 64 65 64 2e 0a 20 20 0a 20 h provided.. .
5c10: 20 64 65 66 20 69 6e 63 6c 75 64 65 5f 63 6f 6d def include_com
5c20: 6d 61 6e 64 20 28 73 65 6c 66 2c 20 6c 69 6e 65 mand (self, line
5c30: 2c 20 73 63 72 69 70 74 5f 66 69 6c 65 29 3a 0a , script_file):.
5c40: 20 20 20 20 70 61 74 68 20 3d 20 73 65 6c 66 2e path = self.
5c50: 70 61 74 68 5f 65 78 70 61 6e 64 28 6c 69 6e 65 path_expand(line
5c60: 29 0a 20 20 20 20 69 66 20 70 61 74 68 20 3d 3d ). if path ==
5c70: 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 72 69 None:. pri
5c80: 6e 74 28 22 49 67 6e 6f 72 69 6e 67 3a 20 5c 6e nt("Ignoring: \n
5c90: 5c 74 69 6e 63 6c 75 64 65 20 22 20 2b 20 6c 69 \tinclude " + li
5ca0: 6e 65 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e ne). return
5cb0: 20 22 66 61 69 6c 22 0a 0a 20 20 20 20 69 66 20 "fail".. if
5cc0: 6e 6f 74 20 6f 73 2e 70 61 74 68 2e 69 73 66 69 not os.path.isfi
5cd0: 6c 65 28 70 61 74 68 29 3a 0a 20 20 20 20 20 20 le(path):.
5ce0: 70 72 69 6e 74 28 22 4c 69 6e 65 20 22 20 2b 20 print("Line " +
5cf0: 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 str(self.line_ct
5d00: 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 5c 0a 20 _stack[0]) + \.
5d10: 20 20 20 20 20 20 20 22 3a 20 43 6f 75 6c 64 20 ": Could
5d20: 6e 6f 74 20 66 69 6e 64 20 69 6e 63 6c 75 64 65 not find include
5d30: 20 66 69 6c 65 3a 20 22 20 2b 20 70 61 74 68 29 file: " + path)
5d40: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 66 . return "f
5d50: 61 69 6c 22 0a 20 20 20 20 69 66 20 73 65 6c 66 ail". if self
5d60: 2e 76 65 72 62 6f 73 65 3a 0a 20 20 20 20 20 20 .verbose:.
5d70: 70 72 69 6e 74 28 22 6c 69 6e 65 3a 20 22 20 2b print("line: " +
5d80: 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 str(self.line_c
5d90: 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 3a t_stack[0]) + ":
5da0: 20 69 6e 63 6c 75 64 65 20 22 20 2b 20 70 61 74 include " + pat
5db0: 68 29 0a 20 20 20 20 72 65 74 75 72 6e 20 73 65 h). return se
5dc0: 6c 66 2e 72 75 6e 5f 73 63 72 69 70 74 5f 66 69 lf.run_script_fi
5dd0: 6c 65 20 28 70 61 74 68 29 0a 20 20 20 20 20 20 le (path).
5de0: 0a 20 20 0a 20 20 23 23 23 23 20 65 6e 61 62 6c . . #### enabl
5df0: 65 5f 6f 70 74 69 6f 6e 5f 63 6f 6d 6d 61 6e 64 e_option_command
5e00: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
5e10: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
5e20: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 ############. #
5e30: 20 44 65 6c 65 74 65 73 20 61 6e 20 6f 70 74 69 Deletes an opti
5e40: 6f 6e 20 66 72 6f 6d 20 74 68 65 20 6c 69 73 74 on from the list
5e50: 20 6f 66 20 61 63 74 69 76 65 20 6f 70 74 69 6f of active optio
5e60: 6e 73 2e 0a 20 20 23 20 50 61 72 73 65 73 20 74 ns.. # Parses t
5e70: 68 65 20 66 69 72 73 74 20 61 72 67 75 6d 65 6e he first argumen
5e80: 74 20 61 66 74 65 72 20 22 65 6e 61 62 6c 65 22 t after "enable"
5e90: 20 61 73 20 74 68 65 20 6b 65 79 20 74 6f 20 65 as the key to e
5ea0: 6e 61 62 6c 65 2e 0a 20 20 23 20 54 68 65 20 65 nable.. # The e
5eb0: 6e 64 20 6f 66 20 74 68 65 20 6b 65 79 20 69 73 nd of the key is
5ec0: 20 74 68 65 20 65 6e 64 20 6f 66 20 74 68 65 20 the end of the
5ed0: 6c 69 6e 65 20 6f 72 20 74 68 65 20 66 69 72 73 line or the firs
5ee0: 74 20 77 68 69 74 65 73 70 61 63 65 0a 20 20 23 t whitespace. #
5ef0: 20 63 68 61 72 61 63 74 65 72 2e 0a 20 20 0a 20 character.. .
5f00: 20 64 65 66 20 65 6e 61 62 6c 65 5f 6f 70 74 69 def enable_opti
5f10: 6f 6e 5f 63 6f 6d 6d 61 6e 64 20 28 73 65 6c 66 on_command (self
5f20: 2c 20 6c 69 6e 65 2c 20 73 63 72 69 70 74 5f 66 , line, script_f
5f30: 69 6c 65 29 3a 0a 20 20 20 20 69 66 20 6c 69 6e ile):. if lin
5f40: 65 20 3d 3d 20 22 22 3a 0a 20 20 20 20 20 20 70 e == "":. p
5f50: 72 69 6e 74 28 22 45 6d 70 74 79 20 6f 70 74 69 rint("Empty opti
5f60: 6f 6e 20 74 6f 20 65 6e 61 62 6c 65 20 61 74 20 on to enable at
5f70: 6c 69 6e 65 3a 20 22 20 2b 20 5c 0a 20 20 20 20 line: " + \.
5f80: 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e str(self.lin
5f90: 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b e_ct_stack[0]) +
5fa0: 20 22 2e 22 29 0a 20 20 20 20 20 20 72 65 74 75 "."). retu
5fb0: 72 6e 20 22 66 61 69 6c 22 0a 20 20 20 20 6d 20 rn "fail". m
5fc0: 3d 20 72 65 2e 6d 61 74 63 68 28 5f 63 6f 6d 6d = re.match(_comm
5fd0: 5f 72 65 2c 20 6c 69 6e 65 29 0a 20 20 20 20 69 _re, line). i
5fe0: 66 20 6d 20 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 f m == None:.
5ff0: 20 20 20 70 72 69 6e 74 28 22 43 6f 75 6c 64 20 print("Could
6000: 6e 6f 74 20 70 61 72 73 65 20 65 6e 61 62 6c 65 not parse enable
6010: 20 63 6f 6d 6d 61 6e 64 20 61 74 20 6c 69 6e 65 command at line
6020: 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 73 " + \. s
6030: 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f tr(self.line_ct_
6040: 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 2e 22 29 stack[0]) + ".")
6050: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 66 . return "f
6060: 61 69 6c 22 0a 20 20 20 20 6f 70 74 69 6f 6e 20 ail". option
6070: 3d 20 6d 2e 67 72 6f 75 70 28 31 29 0a 20 20 20 = m.group(1).
6080: 20 69 66 20 6f 70 74 69 6f 6e 20 3d 3d 20 4e 6f if option == No
6090: 6e 65 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 ne:. print(
60a0: 22 45 6d 70 74 79 20 6f 70 74 69 6f 6e 20 74 6f "Empty option to
60b0: 20 65 6e 61 62 6c 65 20 63 6f 6d 6d 61 6e 64 20 enable command
60c0: 61 74 20 6c 69 6e 65 3a 20 22 20 2b 20 5c 0a 20 at line: " + \.
60d0: 20 20 20 20 20 20 20 73 74 72 28 73 65 6c 66 2e str(self.
60e0: 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d line_ct_stack[0]
60f0: 29 20 2b 20 22 2e 22 29 0a 20 20 20 20 20 20 72 ) + "."). r
6100: 65 74 75 72 6e 20 22 66 61 69 6c 22 0a 20 20 20 eturn "fail".
6110: 20 69 66 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 if self.verbose
6120: 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 4c :. print("L
6130: 69 6e 65 20 22 20 2b 20 73 74 72 28 73 65 6c 66 ine " + str(self
6140: 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 .line_ct_stack[0
6150: 5d 29 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 ]) + \.
6160: 22 3a 20 65 6e 61 62 6c 65 20 6f 70 74 69 6f 6e ": enable option
6170: 3a 20 22 20 2b 20 6f 70 74 69 6f 6e 29 0a 20 20 : " + option).
6180: 20 20 23 20 52 65 6d 6f 76 65 20 69 74 20 66 72 # Remove it fr
6190: 6f 6d 20 6f 74 68 65 72 20 73 65 74 20 69 66 20 om other set if
61a0: 70 72 65 73 65 6e 74 0a 20 20 20 20 69 66 20 6f present. if o
61b0: 70 74 69 6f 6e 20 69 6e 20 73 65 6c 66 2e 6f 70 ption in self.op
61c0: 74 69 6f 6e 73 5f 64 69 73 61 62 6c 65 64 3a 0a tions_disabled:.
61d0: 20 20 20 20 20 20 73 65 6c 66 2e 6f 70 74 69 6f self.optio
61e0: 6e 73 5f 64 69 73 61 62 6c 65 64 2e 72 65 6d 6f ns_disabled.remo
61f0: 76 65 28 6f 70 74 69 6f 6e 29 0a 20 20 20 20 23 ve(option). #
6200: 20 41 64 64 20 69 74 20 69 66 20 6e 6f 74 20 61 Add it if not a
6210: 6c 72 65 61 64 79 20 70 72 65 73 65 6e 74 2e 0a lready present..
6220: 20 20 20 20 69 66 20 6f 70 74 69 6f 6e 20 6e 6f if option no
6230: 74 20 69 6e 20 73 65 6c 66 2e 6f 70 74 69 6f 6e t in self.option
6240: 73 5f 65 6e 61 62 6c 65 64 3a 0a 20 20 20 20 20 s_enabled:.
6250: 20 73 65 6c 66 2e 6f 70 74 69 6f 6e 73 5f 65 6e self.options_en
6260: 61 62 6c 65 64 2e 61 70 70 65 6e 64 28 6f 70 74 abled.append(opt
6270: 69 6f 6e 29 0a 20 20 20 20 72 65 74 75 72 6e 20 ion). return
6280: 22 73 75 63 63 65 73 73 22 0a 0a 0a 20 20 23 23 "success"... ##
6290: 23 23 20 64 69 73 61 62 6c 65 5f 6f 70 74 69 6f ## disable_optio
62a0: 6e 5f 63 6f 6d 6d 61 6e 64 20 23 23 23 23 23 23 n_command ######
62b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
62c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
62d0: 23 23 23 23 23 0a 20 20 23 20 44 65 6c 65 74 65 #####. # Delete
62e0: 73 20 61 6e 20 6f 70 74 69 6f 6e 20 66 72 6f 6d s an option from
62f0: 20 74 68 65 20 6c 69 73 74 20 6f 66 20 61 63 74 the list of act
6300: 69 76 65 20 6f 70 74 69 6f 6e 73 2e 0a 20 20 23 ive options.. #
6310: 20 50 61 72 73 65 73 20 74 68 65 20 66 69 72 73 Parses the firs
6320: 74 20 61 72 67 75 6d 65 6e 74 20 61 66 74 65 72 t argument after
6330: 20 22 64 69 73 61 62 6c 65 22 20 61 73 20 74 68 "disable" as th
6340: 65 20 6b 65 79 20 74 6f 20 65 6e 61 62 6c 65 2e e key to enable.
6350: 0a 20 20 23 20 54 68 65 20 65 6e 64 20 6f 66 20 . # The end of
6360: 74 68 65 20 6b 65 79 20 69 73 20 74 68 65 20 65 the key is the e
6370: 6e 64 20 6f 66 20 74 68 65 20 6c 69 6e 65 20 6f nd of the line o
6380: 72 20 74 68 65 20 66 69 72 73 74 20 77 68 69 74 r the first whit
6390: 65 73 70 61 63 65 0a 20 20 23 20 63 68 61 72 61 espace. # chara
63a0: 63 74 65 72 2e 0a 20 0a 20 20 64 65 66 20 64 69 cter.. . def di
63b0: 73 61 62 6c 65 5f 6f 70 74 69 6f 6e 5f 63 6f 6d sable_option_com
63c0: 6d 61 6e 64 20 28 73 65 6c 66 2c 20 6c 69 6e 65 mand (self, line
63d0: 2c 20 73 63 72 69 70 74 5f 66 69 6c 65 29 3a 0a , script_file):.
63e0: 20 20 20 20 69 66 20 6c 69 6e 65 20 3d 3d 20 22 if line == "
63f0: 22 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 ":. print("
6400: 45 6d 70 74 79 20 6f 70 74 69 6f 6e 20 74 6f 20 Empty option to
6410: 64 69 73 61 62 6c 65 20 61 74 20 6c 69 6e 65 3a disable at line:
6420: 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 73 " + \. s
6430: 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f tr(self.line_ct_
6440: 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 2e 22 29 stack[0]) + ".")
6450: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 66 . return "f
6460: 61 69 6c 22 0a 20 20 20 20 6d 20 3d 20 72 65 2e ail". m = re.
6470: 6d 61 74 63 68 28 5f 63 6f 6d 6d 5f 72 65 2c 20 match(_comm_re,
6480: 6c 69 6e 65 29 0a 20 20 20 20 69 66 20 6d 20 3d line). if m =
6490: 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 72 = None:. pr
64a0: 69 6e 74 28 22 43 6f 75 6c 64 20 6e 6f 74 20 70 int("Could not p
64b0: 61 72 73 65 20 64 69 73 61 62 6c 65 20 6f 70 74 arse disable opt
64c0: 69 6f 6e 20 63 6f 6d 6d 61 6e 64 20 61 74 20 6c ion command at l
64d0: 69 6e 65 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 ine " + \.
64e0: 20 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f str(self.line_
64f0: 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 ct_stack[0]) + "
6500: 2e 22 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e ."). return
6510: 20 22 66 61 69 6c 22 0a 20 20 20 20 6f 70 74 69 "fail". opti
6520: 6f 6e 20 3d 20 6d 2e 67 72 6f 75 70 28 31 29 0a on = m.group(1).
6530: 20 20 20 20 69 66 20 6f 70 74 69 6f 6e 20 3d 3d if option ==
6540: 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 72 69 None:. pri
6550: 6e 74 28 22 45 6d 70 74 79 20 6f 70 74 69 6f 6e nt("Empty option
6560: 20 74 6f 20 64 69 73 61 62 6c 65 20 63 6f 6d 6d to disable comm
6570: 61 6e 64 20 61 74 20 6c 69 6e 65 20 22 20 2b 20 and at line " +
6580: 5c 0a 20 20 20 20 20 20 20 20 73 74 72 28 73 65 \. str(se
6590: 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b lf.line_ct_stack
65a0: 5b 30 5d 29 20 2b 20 22 2e 22 29 0a 20 20 20 20 [0]) + ".").
65b0: 20 20 72 65 74 75 72 6e 20 22 66 61 69 6c 22 0a return "fail".
65c0: 20 20 20 20 69 66 20 73 65 6c 66 2e 76 65 72 62 if self.verb
65d0: 6f 73 65 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 ose:. print
65e0: 28 22 6c 69 6e 65 3a 20 22 20 2b 20 73 74 72 28 ("line: " + str(
65f0: 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 self.line_ct_sta
6600: 63 6b 5b 30 5d 29 20 2b 20 5c 0a 20 20 20 20 20 ck[0]) + \.
6610: 20 20 20 20 20 22 3a 20 64 69 73 61 62 6c 65 20 ": disable
6620: 6f 70 74 69 6f 6e 3a 20 22 20 2b 20 6f 70 74 69 option: " + opti
6630: 6f 6e 29 0a 20 20 20 20 23 20 52 65 6d 6f 76 65 on). # Remove
6640: 20 69 74 20 66 72 6f 6d 20 6f 74 68 65 72 20 73 it from other s
6650: 65 74 20 69 66 20 70 72 65 73 65 6e 74 0a 20 20 et if present.
6660: 20 20 69 66 20 6f 70 74 69 6f 6e 20 69 6e 20 73 if option in s
6670: 65 6c 66 2e 6f 70 74 69 6f 6e 73 5f 65 6e 61 62 elf.options_enab
6680: 6c 65 64 3a 0a 20 20 20 20 20 20 73 65 6c 66 2e led:. self.
6690: 6f 70 74 69 6f 6e 73 5f 65 6e 61 62 6c 65 64 2e options_enabled.
66a0: 72 65 6d 6f 76 65 28 6f 70 74 69 6f 6e 29 0a 20 remove(option).
66b0: 20 20 20 23 20 41 64 64 20 69 74 20 69 66 20 6e # Add it if n
66c0: 6f 74 20 61 6c 72 65 61 64 79 20 70 72 65 73 65 ot already prese
66d0: 6e 74 2e 0a 20 20 20 20 69 66 20 6f 70 74 69 6f nt.. if optio
66e0: 6e 20 6e 6f 74 20 69 6e 20 73 65 6c 66 2e 6f 70 n not in self.op
66f0: 74 69 6f 6e 73 5f 64 69 73 61 62 6c 65 64 3a 0a tions_disabled:.
6700: 20 20 20 20 20 20 73 65 6c 66 2e 6f 70 74 69 6f self.optio
6710: 6e 73 5f 64 69 73 61 62 6c 65 64 2e 61 70 70 65 ns_disabled.appe
6720: 6e 64 28 6f 70 74 69 6f 6e 29 0a 20 20 20 20 72 nd(option). r
6730: 65 74 75 72 6e 20 22 73 75 63 63 65 73 73 22 0a eturn "success".
6740: 0a 0a 20 20 23 23 23 23 20 63 6f 6e 66 69 67 75 .. #### configu
6750: 72 65 5f 63 6f 6d 6d 61 6e 64 20 23 23 23 23 23 re_command #####
6760: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6770: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6780: 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 46 ##########. # F
6790: 69 72 73 74 20 61 72 67 20 69 73 20 74 68 65 20 irst arg is the
67a0: 69 74 65 6d 20 74 6f 20 63 6f 6e 66 69 67 75 72 item to configur
67b0: 65 2e 0a 20 20 23 20 53 65 63 6f 6e 64 20 61 72 e.. # Second ar
67c0: 67 20 69 73 20 74 68 65 20 73 65 74 74 69 6e 67 g is the setting
67d0: 2e 0a 20 20 23 20 54 68 69 73 20 65 6e 61 62 6c .. # This enabl
67e0: 65 73 20 61 64 64 69 6e 67 20 6f 70 74 69 6f 6e es adding option
67f0: 20 73 65 74 74 69 6e 67 20 69 6e 73 69 64 65 20 setting inside
6800: 61 20 73 63 72 69 70 74 20 66 69 6c 65 2e 0a 20 a script file..
6810: 20 0a 20 20 64 65 66 20 63 6f 6e 66 69 67 75 72 . def configur
6820: 65 5f 63 6f 6d 6d 61 6e 64 20 28 73 65 6c 66 2c e_command (self,
6830: 20 6c 69 6e 65 2c 20 73 63 72 69 70 74 5f 66 69 line, script_fi
6840: 6c 65 29 3a 0a 20 20 20 20 6d 20 3d 20 72 65 2e le):. m = re.
6850: 6d 61 74 63 68 28 5f 74 77 6f 5f 61 72 67 73 5f match(_two_args_
6860: 72 65 2c 20 6c 69 6e 65 29 0a 20 20 20 20 69 66 re, line). if
6870: 20 6d 20 3d 3d 20 4e 6f 6e 65 20 6f 72 20 6d 2e m == None or m.
6880: 67 72 6f 75 70 28 31 29 20 3d 3d 20 4e 6f 6e 65 group(1) == None
6890: 20 6f 72 20 6d 2e 67 72 6f 75 70 28 32 29 20 3d or m.group(2) =
68a0: 3d 20 4e 6f 6e 65 3a 20 0a 20 20 20 20 20 20 70 = None: . p
68b0: 72 69 6e 74 28 22 43 6f 75 6c 64 20 6e 6f 74 20 rint("Could not
68c0: 70 61 72 73 65 20 63 6f 6e 66 69 67 75 72 65 20 parse configure
68d0: 63 6f 6d 6d 61 6e 64 20 61 72 67 75 6d 65 6e 74 command argument
68e0: 73 20 61 74 20 6c 69 6e 65 20 22 20 2b 20 5c 0a s at line " + \.
68f0: 20 20 20 20 20 20 20 20 73 74 72 28 73 65 6c 66 str(self
6900: 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 .line_ct_stack[0
6910: 5d 29 20 2b 20 22 3a 20 7b 22 20 2b 20 6c 69 6e ]) + ": {" + lin
6920: 65 20 2b 20 22 7d 22 29 0a 20 20 20 20 20 20 72 e + "}"). r
6930: 65 74 75 72 6e 20 22 66 61 69 6c 22 0a 20 20 20 eturn "fail".
6940: 20 69 74 65 6d 20 3d 20 6d 2e 67 72 6f 75 70 28 item = m.group(
6950: 31 29 0a 20 20 20 20 73 65 74 74 69 6e 67 20 3d 1). setting =
6960: 20 6d 2e 67 72 6f 75 70 28 32 29 0a 20 20 20 20 m.group(2).
6970: 69 66 20 69 74 65 6d 20 6e 6f 74 20 69 6e 20 5f if item not in _
6980: 63 6f 6e 66 69 67 75 72 61 62 6c 65 73 3a 0a 20 configurables:.
6990: 20 20 20 20 20 70 72 69 6e 74 28 22 49 67 6e 6f print("Igno
69a0: 72 69 6e 67 20 69 6e 76 61 6c 69 64 20 63 6f 6e ring invalid con
69b0: 66 69 67 75 72 61 74 69 6f 6e 20 69 74 65 6d 20 figuration item
69c0: 61 74 20 6c 69 6e 65 20 22 20 2b 20 5c 0a 20 20 at line " + \.
69d0: 20 20 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c str(self.l
69e0: 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 ine_ct_stack[0])
69f0: 20 2b 20 22 3a 20 22 20 2b 20 69 74 65 6d 29 0a + ": " + item).
6a00: 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 66 61 return "fa
6a10: 69 6c 22 0a 20 20 20 20 69 66 20 73 65 74 74 69 il". if setti
6a20: 6e 67 20 6e 6f 74 20 69 6e 20 5f 63 6f 6e 66 69 ng not in _confi
6a30: 67 75 72 61 62 6c 65 73 5b 69 74 65 6d 5d 3a 0a gurables[item]:.
6a40: 20 20 20 20 20 20 70 72 69 6e 74 28 22 41 74 20 print("At
6a50: 6c 69 6e 65 20 22 20 2b 20 73 74 72 28 73 65 6c line " + str(sel
6a60: 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b f.line_ct_stack[
6a70: 30 5d 29 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 0]) + \.
6a80: 22 3a 20 43 61 6e 6e 6f 74 20 73 65 74 20 22 20 ": Cannot set "
6a90: 2b 20 69 74 65 6d 20 2b 20 22 20 74 6f 20 22 20 + item + " to "
6aa0: 2b 20 73 65 74 74 69 6e 67 20 2b 20 22 2e 22 29 + setting + ".")
6ab0: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 66 . return "f
6ac0: 61 69 6c 22 0a 20 20 20 20 69 66 20 69 74 65 6d ail". if item
6ad0: 20 3d 3d 20 22 74 61 70 65 22 3a 0a 20 20 20 20 == "tape":.
6ae0: 20 20 73 65 6c 66 2e 73 69 6d 68 2e 73 65 74 5f self.simh.set_
6af0: 74 61 70 65 5f 63 6f 6e 66 69 67 28 73 65 74 74 tape_config(sett
6b00: 69 6e 67 29 0a 20 20 20 20 65 6c 69 66 20 69 74 ing). elif it
6b10: 65 6d 20 3d 3d 20 22 72 78 22 3a 0a 20 20 20 20 em == "rx":.
6b20: 20 20 73 65 6c 66 2e 73 69 6d 68 2e 73 65 74 5f self.simh.set_
6b30: 72 78 5f 63 6f 6e 66 69 67 20 28 73 65 74 74 69 rx_config (setti
6b40: 6e 67 29 0a 20 20 20 20 65 6c 69 66 20 69 74 65 ng). elif ite
6b50: 6d 20 3d 3d 20 22 74 74 69 22 3a 0a 20 20 20 20 m == "tti":.
6b60: 20 20 73 65 6c 66 2e 73 69 6d 68 2e 73 65 74 5f self.simh.set_
6b70: 74 74 69 5f 63 6f 6e 66 69 67 20 28 73 65 74 74 tti_config (sett
6b80: 69 6e 67 29 0a 20 20 20 20 72 65 74 75 72 6e 20 ing). return
6b90: 22 73 75 63 63 65 73 73 22 0a 0a 0a 20 20 23 23 "success"... ##
6ba0: 23 23 20 63 70 74 6f 5f 63 6f 6d 6d 61 6e 64 20 ## cpto_command
6bb0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6bc0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
6bd0: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 ###########. #
6be0: 43 61 6c 6c 73 20 6f 73 38 5f 70 69 70 5f 74 6f Calls os8_pip_to
6bf0: 20 77 69 74 68 20 74 68 65 20 63 6f 6d 6d 61 6e with the comman
6c00: 64 20 6c 69 6e 65 20 61 72 67 75 6d 65 6e 74 73 d line arguments
6c10: 2e 0a 20 20 0a 20 20 64 65 66 20 63 70 74 6f 5f .. . def cpto_
6c20: 63 6f 6d 6d 61 6e 64 20 28 73 65 6c 66 2c 20 6c command (self, l
6c30: 69 6e 65 2c 20 73 63 72 69 70 74 5f 66 69 6c 65 ine, script_file
6c40: 29 3a 0a 20 20 20 20 69 66 20 6e 6f 74 20 73 65 ):. if not se
6c50: 6c 66 2e 62 6f 6f 74 65 64 3a 0a 20 20 20 20 20 lf.booted:.
6c60: 20 70 72 69 6e 74 28 22 43 61 6e 6e 6f 74 20 72 print("Cannot r
6c70: 75 6e 20 63 70 74 6f 20 63 6f 6d 6d 61 6e 64 20 un cpto command
6c80: 61 74 20 6c 69 6e 65 20 22 20 2b 20 5c 0a 20 20 at line " + \.
6c90: 20 20 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c str(self.l
6ca0: 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 ine_ct_stack[0])
6cb0: 20 2b 20 22 2e 20 4f 53 2f 38 20 68 61 73 20 6e + ". OS/8 has n
6cc0: 6f 74 20 62 65 65 6e 20 62 6f 6f 74 65 64 2e 22 ot been booted."
6cd0: 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 ). return "
6ce0: 64 69 65 22 0a 0a 20 20 20 20 23 20 49 73 20 32 die".. # Is 2
6cf0: 6e 64 20 61 6e 64 20 66 69 6e 61 6c 20 61 72 67 nd and final arg
6d00: 20 74 68 65 20 6f 70 74 69 6f 6e 3f 0a 20 20 20 the option?.
6d10: 20 6d 20 3d 20 72 65 2e 6d 61 74 63 68 28 5f 66 m = re.match(_f
6d20: 72 6f 6d 5f 74 6f 5f 72 65 5f 31 2c 20 6c 69 6e rom_to_re_1, lin
6d30: 65 29 0a 20 20 20 20 69 66 20 6d 20 21 3d 20 4e e). if m != N
6d40: 6f 6e 65 3a 0a 20 20 20 20 20 20 23 20 59 65 73 one:. # Yes
6d50: 2e 20 20 45 78 70 61 6e 64 20 53 6f 75 72 63 65 . Expand Source
6d60: 20 66 69 72 73 74 2e 0a 20 20 20 20 20 20 70 61 first.. pa
6d70: 74 68 20 3d 20 73 65 6c 66 2e 70 61 74 68 5f 65 th = self.path_e
6d80: 78 70 61 6e 64 28 6d 2e 67 72 6f 75 70 28 31 29 xpand(m.group(1)
6d90: 29 0a 20 20 20 20 20 20 69 66 20 70 61 74 68 20 ). if path
6da0: 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 20 == None:.
6db0: 20 70 72 69 6e 74 28 22 49 67 6e 6f 72 69 6e 67 print("Ignoring
6dc0: 3a 20 5c 6e 5c 74 63 70 74 6f 20 22 20 2b 20 6c : \n\tcpto " + l
6dd0: 69 6e 65 29 0a 20 20 20 20 20 20 20 20 72 65 74 ine). ret
6de0: 75 72 6e 20 22 66 61 69 6c 22 0a 20 20 20 20 20 urn "fail".
6df0: 20 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 70 self.simh.os8_p
6e00: 69 70 5f 74 6f 20 28 70 61 74 68 2c 20 22 44 53 ip_to (path, "DS
6e10: 4b 3a 22 2c 20 6d 2e 67 72 6f 75 70 28 32 29 29 K:", m.group(2))
6e20: 0a 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 . else:.
6e30: 20 23 20 49 73 20 74 68 69 73 20 6e 6f 72 6d 61 # Is this norma
6e40: 6c 20 63 61 73 65 20 6f 66 20 73 6f 75 72 63 65 l case of source
6e50: 2c 20 64 65 73 74 2c 20 77 69 74 68 20 70 6f 73 , dest, with pos
6e60: 73 69 62 6c 79 20 65 6d 70 74 79 20 6f 70 74 69 sibly empty opti
6e70: 6f 6e 3f 0a 20 20 20 20 20 20 6d 20 3d 20 72 65 on?. m = re
6e80: 2e 6d 61 74 63 68 28 5f 66 72 6f 6d 5f 74 6f 5f .match(_from_to_
6e90: 72 65 5f 32 2c 20 6c 69 6e 65 29 0a 20 20 20 20 re_2, line).
6ea0: 20 20 69 66 20 6d 20 3d 3d 20 4e 6f 6e 65 3a 0a if m == None:.
6eb0: 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 43 print("C
6ec0: 6f 75 6c 64 20 6e 6f 74 20 70 61 72 73 65 20 63 ould not parse c
6ed0: 70 74 6f 20 63 6f 6d 6d 61 6e 64 20 61 74 20 6c pto command at l
6ee0: 69 6e 65 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 ine " + \.
6ef0: 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e str(self.lin
6f00: 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b e_ct_stack[0]) +
6f10: 20 22 2e 22 29 0a 20 20 20 20 20 20 20 20 72 65 "."). re
6f20: 74 75 72 6e 20 22 66 61 69 6c 22 0a 20 20 20 20 turn "fail".
6f30: 20 20 70 61 74 68 20 3d 20 73 65 6c 66 2e 70 61 path = self.pa
6f40: 74 68 5f 65 78 70 61 6e 64 28 6d 2e 67 72 6f 75 th_expand(m.grou
6f50: 70 28 31 29 29 0a 20 20 20 20 20 20 69 66 20 70 p(1)). if p
6f60: 61 74 68 20 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 ath == None:.
6f70: 20 20 20 20 20 70 72 69 6e 74 28 22 49 67 6e 6f print("Igno
6f80: 72 69 6e 67 3a 20 5c 6e 5c 74 63 70 74 6f 20 22 ring: \n\tcpto "
6f90: 20 2b 20 6c 69 6e 65 29 0a 20 20 20 20 20 20 20 + line).
6fa0: 20 72 65 74 75 72 6e 20 22 66 61 69 6c 22 0a 20 return "fail".
6fb0: 20 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 2e 6f self.simh.o
6fc0: 73 38 5f 70 69 70 5f 74 6f 20 28 70 61 74 68 2c s8_pip_to (path,
6fd0: 20 6d 2e 67 72 6f 75 70 28 32 29 2c 20 6d 2e 67 m.group(2), m.g
6fe0: 72 6f 75 70 28 34 29 2c 20 73 65 6c 66 2e 64 65 roup(4), self.de
6ff0: 62 75 67 29 0a 20 20 20 20 72 65 74 75 72 6e 20 bug). return
7000: 22 73 75 63 63 65 73 73 22 0a 0a 0a 20 20 23 23 "success"... ##
7010: 23 23 20 63 70 66 72 6f 6d 5f 63 6f 6d 6d 61 6e ## cpfrom_comman
7020: 64 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 d ##############
7030: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7040: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 ###########. #
7050: 43 61 6c 6c 73 20 6f 73 38 5f 70 69 70 5f 66 72 Calls os8_pip_fr
7060: 6f 6d 20 77 69 74 68 20 74 68 65 20 63 6f 6d 6d om with the comm
7070: 61 6e 64 20 6c 69 6e 65 20 61 72 67 75 6d 65 6e and line argumen
7080: 74 73 2e 0a 20 20 0a 20 20 64 65 66 20 63 70 66 ts.. . def cpf
7090: 72 6f 6d 5f 63 6f 6d 6d 61 6e 64 20 28 73 65 6c rom_command (sel
70a0: 66 2c 20 6c 69 6e 65 2c 20 73 63 72 69 70 74 5f f, line, script_
70b0: 66 69 6c 65 29 3a 0a 20 20 20 20 69 66 20 6e 6f file):. if no
70c0: 74 20 73 65 6c 66 2e 62 6f 6f 74 65 64 3a 0a 20 t self.booted:.
70d0: 20 20 20 20 20 70 72 69 6e 74 28 22 43 61 6e 6e print("Cann
70e0: 6f 74 20 72 75 6e 20 63 70 66 72 6f 6d 20 63 6f ot run cpfrom co
70f0: 6d 6d 61 6e 64 20 61 74 20 6c 69 6e 65 20 22 20 mmand at line "
7100: 2b 20 5c 0a 20 20 20 20 20 20 20 20 73 74 72 28 + \. str(
7110: 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 self.line_ct_sta
7120: 63 6b 5b 30 5d 29 20 2b 20 22 2e 20 4f 53 2f 38 ck[0]) + ". OS/8
7130: 20 68 61 73 20 6e 6f 74 20 62 65 65 6e 20 62 6f has not been bo
7140: 6f 74 65 64 2e 22 29 0a 20 20 20 20 20 20 72 65 oted."). re
7150: 74 75 72 6e 20 22 64 69 65 22 0a 20 20 20 20 6d turn "die". m
7160: 20 3d 20 72 65 2e 6d 61 74 63 68 28 5f 66 72 6f = re.match(_fro
7170: 6d 5f 74 6f 5f 72 65 5f 32 2c 20 6c 69 6e 65 29 m_to_re_2, line)
7180: 0a 20 20 20 20 69 66 20 6d 20 3d 3d 20 4e 6f 6e . if m == Non
7190: 65 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 e:. print("
71a0: 43 6f 75 6c 64 20 6e 6f 74 20 70 61 72 73 65 20 Could not parse
71b0: 63 70 66 72 6f 6d 20 63 6f 6d 6d 61 6e 64 20 61 cpfrom command a
71c0: 74 20 6c 69 6e 65 20 22 20 2b 20 5c 0a 20 20 20 t line " + \.
71d0: 20 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c 69 str(self.li
71e0: 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 ne_ct_stack[0])
71f0: 2b 20 22 2e 22 29 0a 20 20 20 20 20 20 72 65 74 + "."). ret
7200: 75 72 6e 20 22 66 61 69 6c 22 0a 20 20 0a 20 20 urn "fail". .
7210: 20 20 70 61 74 68 20 3d 20 73 65 6c 66 2e 70 61 path = self.pa
7220: 74 68 5f 65 78 70 61 6e 64 28 6d 2e 67 72 6f 75 th_expand(m.grou
7230: 70 28 32 29 29 0a 20 20 20 20 69 66 20 70 61 74 p(2)). if pat
7240: 68 20 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 h == None:.
7250: 20 70 72 69 6e 74 28 22 49 67 6e 6f 72 69 6e 67 print("Ignoring
7260: 3a 20 5c 6e 5c 74 63 70 66 72 6f 6d 20 22 20 2b : \n\tcpfrom " +
7270: 20 6c 69 6e 65 29 0a 20 20 20 20 20 20 72 65 74 line). ret
7280: 75 72 6e 20 22 66 61 69 6c 22 0a 20 20 20 20 73 urn "fail". s
7290: 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 70 69 70 elf.simh.os8_pip
72a0: 5f 66 72 6f 6d 20 28 6d 2e 67 72 6f 75 70 28 31 _from (m.group(1
72b0: 29 2c 20 70 61 74 68 2c 20 6d 2e 67 72 6f 75 70 ), path, m.group
72c0: 28 34 29 29 0a 20 20 20 20 72 65 74 75 72 6e 20 (4)). return
72d0: 22 73 75 63 63 65 73 73 22 0a 0a 0a 20 20 23 23 "success"... ##
72e0: 23 23 20 63 6f 70 79 5f 63 6f 6d 6d 61 6e 64 20 ## copy_command
72f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7300: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7310: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a ###############.
7320: 20 20 23 20 53 69 6d 70 6c 65 20 73 63 72 69 70 # Simple scrip
7330: 74 20 69 6e 74 65 72 66 61 63 65 20 74 6f 20 63 t interface to c
7340: 72 65 61 74 65 20 61 20 63 6f 70 79 20 6f 66 20 reate a copy of
7350: 61 20 66 69 6c 65 2e 0a 0a 20 20 64 65 66 20 63 a file... def c
7360: 6f 70 79 5f 63 6f 6d 6d 61 6e 64 20 28 73 65 6c opy_command (sel
7370: 66 2c 20 6c 69 6e 65 2c 20 73 63 72 69 70 74 5f f, line, script_
7380: 66 69 6c 65 29 3a 0a 20 20 20 20 6d 20 3d 20 72 file):. m = r
7390: 65 2e 6d 61 74 63 68 28 5f 74 77 6f 5f 61 72 67 e.match(_two_arg
73a0: 73 5f 72 65 2c 20 6c 69 6e 65 29 0a 20 20 20 20 s_re, line).
73b0: 69 66 20 6d 20 3d 3d 20 4e 6f 6e 65 20 6f 72 20 if m == None or
73c0: 6d 2e 67 72 6f 75 70 28 31 29 20 3d 3d 20 4e 6f m.group(1) == No
73d0: 6e 65 20 6f 72 20 6d 2e 67 72 6f 75 70 28 32 29 ne or m.group(2)
73e0: 20 3d 3d 20 4e 6f 6e 65 3a 20 0a 20 20 20 20 20 == None: .
73f0: 20 70 72 69 6e 74 28 22 43 6f 75 6c 64 20 6e 6f print("Could no
7400: 74 20 63 6f 70 79 20 63 6f 6d 6d 61 6e 64 3a 20 t copy command:
7410: 22 20 2b 20 6c 69 6e 65 29 0a 20 20 20 20 20 20 " + line).
7420: 72 65 74 75 72 6e 20 22 66 61 69 6c 22 0a 20 20 return "fail".
7430: 20 20 66 72 6f 6d 5f 70 61 74 68 20 3d 20 73 65 from_path = se
7440: 6c 66 2e 70 61 74 68 5f 65 78 70 61 6e 64 28 6d lf.path_expand(m
7450: 2e 67 72 6f 75 70 28 31 29 29 20 20 20 20 20 20 .group(1))
7460: 0a 20 20 20 20 74 6f 5f 70 61 74 68 20 3d 20 73 . to_path = s
7470: 65 6c 66 2e 70 61 74 68 5f 65 78 70 61 6e 64 28 elf.path_expand(
7480: 6d 2e 67 72 6f 75 70 28 32 29 29 0a 0a 20 20 20 m.group(2))..
7490: 20 69 66 20 66 72 6f 6d 5f 70 61 74 68 20 3d 3d if from_path ==
74a0: 20 4e 6f 6e 65 20 6f 72 20 74 6f 5f 70 61 74 68 None or to_path
74b0: 20 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 == None:.
74c0: 70 72 69 6e 74 28 22 49 67 6e 6f 72 69 6e 67 3a print("Ignoring:
74d0: 20 5c 6e 5c 74 20 63 6f 70 79 20 22 20 2b 20 6c \n\t copy " + l
74e0: 69 6e 65 29 0a 20 20 20 20 20 20 72 65 74 75 72 ine). retur
74f0: 6e 20 22 66 61 69 6c 22 0a 0a 20 20 20 20 70 72 n "fail".. pr
7500: 69 6e 74 28 22 63 6f 70 79 20 63 6f 6d 6d 61 6e int("copy comman
7510: 64 3a 20 5c 6e 5c 74 66 72 6f 6d 3a 20 22 20 2b d: \n\tfrom: " +
7520: 20 66 72 6f 6d 5f 70 61 74 68 20 2b 20 22 2c 20 from_path + ",
7530: 5c 6e 5c 74 74 6f 3a 20 22 20 2b 20 74 6f 5f 70 \n\tto: " + to_p
7540: 61 74 68 29 0a 20 20 20 20 0a 20 20 20 20 69 66 ath). . if
7550: 20 28 6e 6f 74 20 6f 73 2e 70 61 74 68 2e 69 73 (not os.path.is
7560: 66 69 6c 65 28 66 72 6f 6d 5f 70 61 74 68 29 29 file(from_path))
7570: 3a 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 :. print(
7580: 22 41 74 20 6c 69 6e 65 20 22 20 2b 20 73 74 72 "At line " + str
7590: 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 (self.line_ct_st
75a0: 61 63 6b 5b 30 5d 29 20 2b 20 5c 0a 20 20 20 20 ack[0]) + \.
75b0: 20 20 20 20 20 20 22 3a 20 52 65 71 75 69 72 65 ": Require
75c0: 64 20 63 6f 70 79 20 69 6e 70 75 74 20 66 69 6c d copy input fil
75d0: 65 3a 20 22 20 2b 20 66 72 6f 6d 5f 70 61 74 68 e: " + from_path
75e0: 20 2b 20 22 20 6e 6f 74 20 66 6f 75 6e 64 2e 22 + " not found."
75f0: 29 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 6e ). return
7600: 20 22 66 61 69 6c 22 0a 0a 20 20 20 20 73 61 76 "fail".. sav
7610: 65 5f 69 66 5f 6e 65 65 64 65 64 28 74 6f 5f 70 e_if_needed(to_p
7620: 61 74 68 29 0a 20 20 20 20 0a 20 20 20 20 74 72 ath). . tr
7630: 79 3a 0a 20 20 20 20 20 20 73 68 75 74 69 6c 2e y:. shutil.
7640: 63 6f 70 79 66 69 6c 65 28 66 72 6f 6d 5f 70 61 copyfile(from_pa
7650: 74 68 2c 20 74 6f 5f 70 61 74 68 29 0a 20 20 20 th, to_path).
7660: 20 65 78 63 65 70 74 20 73 68 75 74 69 6c 2e 45 except shutil.E
7670: 72 72 6f 72 20 61 73 20 65 3a 0a 20 20 20 20 20 rror as e:.
7680: 20 70 72 69 6e 74 28 22 63 6f 70 79 20 63 6f 6d print("copy com
7690: 6d 61 6e 64 20 66 61 69 6c 65 64 20 77 69 74 68 mand failed with
76a0: 20 65 72 72 6f 72 3a 20 22 20 2b 20 73 74 72 28 error: " + str(
76b0: 65 29 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e e)). return
76c0: 20 22 66 61 69 6c 22 0a 20 20 20 20 65 78 63 65 "fail". exce
76d0: 70 74 20 49 4f 45 72 72 6f 72 20 61 73 20 65 3a pt IOError as e:
76e0: 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 63 6f . print("co
76f0: 70 79 20 63 6f 6d 6d 61 6e 64 20 66 61 69 6c 65 py command faile
7700: 64 20 77 69 74 68 20 49 4f 45 72 72 6f 72 3a 20 d with IOError:
7710: 22 20 2b 20 73 74 72 28 65 29 29 0a 20 20 20 20 " + str(e)).
7720: 20 20 72 65 74 75 72 6e 20 22 66 61 69 6c 22 0a return "fail".
7730: 20 20 20 20 72 65 74 75 72 6e 20 22 73 75 63 63 return "succ
7740: 65 73 73 22 0a 0a 0a 20 20 23 23 23 23 20 72 65 ess"... #### re
7750: 73 75 6d 65 5f 63 6f 6d 6d 61 6e 64 20 23 23 23 sume_command ###
7760: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7770: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7780: 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 43 ##########. # C
7790: 61 6c 6c 20 74 68 65 20 6f 73 38 5f 72 65 73 75 all the os8_resu
77a0: 6d 65 20 69 6e 20 73 69 6d 68 20 74 6f 20 72 65 me in simh to re
77b0: 73 75 6d 65 20 4f 53 2f 38 2e 0a 0a 20 20 64 65 sume OS/8... de
77c0: 66 20 72 65 73 75 6d 65 5f 63 6f 6d 6d 61 6e 64 f resume_command
77d0: 20 28 73 65 6c 66 2c 20 6c 69 6e 65 2c 20 73 63 (self, line, sc
77e0: 72 69 70 74 5f 66 69 6c 65 29 3a 0a 20 20 20 20 ript_file):.
77f0: 69 66 20 6e 6f 74 20 73 65 6c 66 2e 62 6f 6f 74 if not self.boot
7800: 65 64 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 ed:. print(
7810: 22 43 61 6e 6e 6f 74 20 72 75 6e 20 72 65 73 75 "Cannot run resu
7820: 6d 65 20 63 6f 6d 6d 61 6e 64 20 61 74 20 6c 69 me command at li
7830: 6e 65 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 20 ne " + \.
7840: 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 str(self.line_c
7850: 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 2e t_stack[0]) + ".
7860: 20 4f 53 2f 38 20 68 61 73 20 6e 6f 74 20 62 65 OS/8 has not be
7870: 65 6e 20 62 6f 6f 74 65 64 2e 22 29 0a 20 20 20 en booted.").
7880: 20 20 20 72 65 74 75 72 6e 20 22 64 69 65 22 0a return "die".
7890: 0a 20 20 20 20 69 66 20 73 65 6c 66 2e 76 65 72 . if self.ver
78a0: 62 6f 73 65 3a 0a 20 20 20 20 20 20 70 72 69 6e bose:. prin
78b0: 74 28 22 52 65 73 75 6d 69 6e 67 20 4f 53 2f 38 t("Resuming OS/8
78c0: 20 61 74 20 6c 69 6e 65 20 22 20 2b 20 73 74 72 at line " + str
78d0: 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 (self.line_ct_st
78e0: 61 63 6b 5b 30 5d 29 20 2b 20 22 2e 22 29 0a 0a ack[0]) + ".")..
78f0: 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 2e 73 69 self.simh.si
7900: 6d 68 5f 72 65 73 75 6d 65 5f 6f 73 38 28 29 0a mh_resume_os8().
7910: 20 20 20 20 72 65 74 75 72 6e 20 22 73 75 63 63 return "succ
7920: 65 73 73 22 0a 0a 0a 20 20 23 23 23 23 20 72 65 ess"... #### re
7930: 73 74 61 72 74 5f 63 6f 6d 6d 61 6e 64 20 23 23 start_command ##
7940: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7950: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7960: 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 ###########. #
7970: 43 61 6c 6c 20 74 68 65 20 6f 73 38 5f 72 65 73 Call the os8_res
7980: 74 61 72 74 20 69 6e 20 73 69 6d 68 20 74 6f 20 tart in simh to
7990: 72 65 73 75 6d 65 20 4f 53 2f 38 2e 0a 0a 20 20 resume OS/8...
79a0: 64 65 66 20 72 65 73 74 61 72 74 5f 63 6f 6d 6d def restart_comm
79b0: 61 6e 64 20 28 73 65 6c 66 2c 20 6c 69 6e 65 2c and (self, line,
79c0: 20 73 63 72 69 70 74 5f 66 69 6c 65 29 3a 0a 20 script_file):.
79d0: 20 20 20 69 66 20 6e 6f 74 20 73 65 6c 66 2e 62 if not self.b
79e0: 6f 6f 74 65 64 3a 0a 20 20 20 20 20 20 70 72 69 ooted:. pri
79f0: 6e 74 28 22 43 61 6e 6e 6f 74 20 72 75 6e 20 72 nt("Cannot run r
7a00: 65 73 74 61 72 74 20 63 6f 6d 6d 61 6e 64 20 61 estart command a
7a10: 74 20 6c 69 6e 65 20 22 20 2b 20 5c 0a 20 20 20 t line " + \.
7a20: 20 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c 69 str(self.li
7a30: 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 ne_ct_stack[0])
7a40: 2b 20 22 2e 20 4f 53 2f 38 20 68 61 73 20 6e 6f + ". OS/8 has no
7a50: 74 20 62 65 65 6e 20 62 6f 6f 74 65 64 2e 22 29 t been booted.")
7a60: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 64 . return "d
7a70: 69 65 22 0a 0a 20 20 20 20 69 66 20 73 65 6c 66 ie".. if self
7a80: 2e 76 65 72 62 6f 73 65 3a 0a 20 20 20 20 20 20 .verbose:.
7a90: 70 72 69 6e 74 28 22 52 65 73 74 61 72 74 69 6e print("Restartin
7aa0: 67 20 4f 53 2f 38 20 61 74 20 6c 69 6e 65 20 22 g OS/8 at line "
7ab0: 20 2b 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 + str(self.line
7ac0: 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 _ct_stack[0]) +
7ad0: 22 2e 22 29 0a 0a 20 20 20 20 73 65 6c 66 2e 73 ".").. self.s
7ae0: 69 6d 68 2e 73 69 6d 68 5f 72 65 73 74 61 72 74 imh.simh_restart
7af0: 5f 6f 73 38 28 29 0a 20 20 20 20 72 65 74 75 72 _os8(). retur
7b00: 6e 20 22 73 75 63 63 65 73 73 22 0a 0a 0a 20 20 n "success"...
7b10: 23 23 23 23 20 70 61 74 63 68 5f 63 6f 6d 6d 61 #### patch_comma
7b20: 6e 64 20 23 23 23 23 23 23 23 23 23 23 23 23 23 nd #############
7b30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7b40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7b50: 23 0a 20 20 23 20 52 65 61 64 20 74 68 65 20 6e #. # Read the n
7b60: 61 6d 65 64 20 70 61 74 63 68 20 66 69 6c 65 20 amed patch file
7b70: 61 6e 64 20 70 65 72 66 6f 72 6d 20 69 74 73 20 and perform its
7b80: 61 63 74 69 6f 6e 73 2e 0a 0a 20 20 64 65 66 20 actions... def
7b90: 70 61 74 63 68 5f 63 6f 6d 6d 61 6e 64 20 28 73 patch_command (s
7ba0: 65 6c 66 2c 20 6c 69 6e 65 2c 20 73 63 72 69 70 elf, line, scrip
7bb0: 74 5f 66 69 6c 65 29 3a 0a 20 20 20 20 69 66 20 t_file):. if
7bc0: 6e 6f 74 20 73 65 6c 66 2e 62 6f 6f 74 65 64 3a not self.booted:
7bd0: 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 43 61 . print("Ca
7be0: 6e 6e 6f 74 20 72 75 6e 20 70 61 74 63 68 20 63 nnot run patch c
7bf0: 6f 6d 6d 61 6e 64 20 61 74 20 6c 69 6e 65 20 22 ommand at line "
7c00: 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 73 74 72 + \. str
7c10: 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 (self.line_ct_st
7c20: 61 63 6b 5b 30 5d 29 20 2b 20 22 2e 20 4f 53 2f ack[0]) + ". OS/
7c30: 38 20 68 61 73 20 6e 6f 74 20 62 65 65 6e 20 62 8 has not been b
7c40: 6f 6f 74 65 64 2e 22 29 0a 20 20 20 20 20 20 72 ooted."). r
7c50: 65 74 75 72 6e 20 22 64 69 65 22 0a 20 20 20 20 eturn "die".
7c60: 70 61 74 68 20 3d 20 73 65 6c 66 2e 70 61 74 68 path = self.path
7c70: 5f 65 78 70 61 6e 64 28 6c 69 6e 65 29 0a 20 20 _expand(line).
7c80: 20 20 69 66 20 70 61 74 68 20 3d 3d 20 4e 6f 6e if path == Non
7c90: 65 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 e:. print("
7ca0: 49 67 6e 6f 72 69 6e 67 3a 20 5c 6e 5c 74 22 20 Ignoring: \n\t"
7cb0: 2b 20 22 70 61 74 63 68 20 22 20 2b 20 6c 69 6e + "patch " + lin
7cc0: 65 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 e). return
7cd0: 22 66 61 69 6c 22 0a 20 20 20 20 69 66 20 6e 6f "fail". if no
7ce0: 74 20 6f 73 2e 70 61 74 68 2e 69 73 66 69 6c 65 t os.path.isfile
7cf0: 28 70 61 74 68 29 3a 0a 20 20 20 20 20 20 70 72 (path):. pr
7d00: 69 6e 74 28 22 41 74 20 6c 69 6e 65 20 22 20 2b int("At line " +
7d10: 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 str(self.line_c
7d20: 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 5c 0a t_stack[0]) + \.
7d30: 20 20 20 20 20 20 20 20 22 3a 20 50 61 74 63 68 ": Patch
7d40: 20 66 69 6c 65 3a 20 22 20 2b 20 70 61 74 68 20 file: " + path
7d50: 2b 20 22 20 6e 6f 74 20 66 6f 75 6e 64 2e 22 29 + " not found.")
7d60: 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 66 . return "f
7d70: 61 69 6c 22 0a 0a 20 20 20 20 73 65 6c 66 2e 72 ail".. self.r
7d80: 75 6e 5f 70 61 74 63 68 5f 66 69 6c 65 20 28 70 un_patch_file (p
7d90: 61 74 68 2c 20 6c 69 6e 65 2c 20 73 63 72 69 70 ath, line, scrip
7da0: 74 5f 66 69 6c 65 29 0a 20 20 20 20 72 65 74 75 t_file). retu
7db0: 72 6e 20 22 73 75 63 63 65 73 73 22 0a 0a 0a 20 rn "success"...
7dc0: 20 23 23 23 23 20 65 78 69 74 5f 63 6f 6d 6d 61 #### exit_comma
7dd0: 6e 64 20 23 23 23 23 23 23 23 23 23 23 23 23 23 nd #############
7de0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7df0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
7e00: 23 23 0a 20 20 23 20 4d 61 6b 65 20 61 20 67 72 ##. # Make a gr
7e10: 61 63 65 66 75 6c 20 65 78 69 74 3a 0a 20 20 23 aceful exit:. #
7e20: 20 20 20 20 52 65 6d 6f 76 65 20 73 63 72 61 74 Remove scrat
7e30: 63 68 20 66 69 6c 65 73 2e 0a 20 20 23 20 20 20 ch files.. #
7e40: 20 44 65 74 61 63 68 20 61 6c 6c 20 64 65 76 69 Detach all devi
7e50: 63 65 73 20 66 72 6f 6d 20 72 75 6e 6e 69 6e 67 ces from running
7e60: 20 69 6d 61 67 65 2e 0a 20 20 23 20 20 20 20 51 image.. # Q
7e70: 75 69 74 20 53 49 4d 48 2e 0a 20 20 23 20 20 20 uit SIMH.. #
7e80: 20 50 61 72 73 65 20 61 6e 20 65 78 69 74 20 73 Parse an exit s
7e90: 74 61 74 75 73 20 76 61 6c 75 65 20 66 72 6f 6d tatus value from
7ea0: 20 6c 69 6e 65 2e 20 44 65 66 61 75 6c 74 20 74 line. Default t
7eb0: 6f 20 30 2e 0a 20 20 23 20 20 20 20 43 61 6c 6c o 0.. # Call
7ec0: 20 50 4f 53 49 58 20 65 78 69 74 20 74 6f 20 65 POSIX exit to e
7ed0: 78 69 74 20 74 68 65 20 72 75 6e 6e 69 6e 67 20 xit the running
7ee0: 70 72 6f 67 72 61 6d 2c 0a 20 20 0a 20 20 64 65 program,. . de
7ef0: 66 20 65 78 69 74 5f 63 6f 6d 6d 61 6e 64 20 28 f exit_command (
7f00: 73 65 6c 66 2c 20 6c 69 6e 65 2c 20 73 63 72 69 self, line, scri
7f10: 70 74 5f 66 69 6c 65 29 3a 0a 20 20 20 20 6d 20 pt_file):. m
7f20: 3d 20 72 65 2e 6d 61 74 63 68 20 28 5f 65 78 69 = re.match (_exi
7f30: 74 5f 61 72 67 5f 72 65 2c 20 6c 69 6e 65 29 0a t_arg_re, line).
7f40: 20 20 20 20 69 66 20 6d 20 21 3d 20 4e 6f 6e 65 if m != None
7f50: 3a 0a 20 20 20 20 20 20 69 66 20 6d 2e 67 72 6f :. if m.gro
7f60: 75 70 28 31 29 20 21 3d 20 4e 6f 6e 65 3a 0a 20 up(1) != None:.
7f70: 20 20 20 20 20 20 20 20 73 74 61 74 75 73 20 3d status =
7f80: 20 69 6e 74 28 6d 2e 67 72 6f 75 70 28 31 29 29 int(m.group(1))
7f90: 0a 20 20 20 20 20 20 65 6c 69 66 20 6d 2e 67 72 . elif m.gr
7fa0: 6f 75 70 28 32 29 20 21 3d 20 4e 6f 6e 65 3a 0a oup(2) != None:.
7fb0: 20 20 20 20 20 20 20 20 20 73 74 61 74 75 73 20 status
7fc0: 3d 20 69 6e 74 28 6d 2e 67 72 6f 75 70 28 32 29 = int(m.group(2)
7fd0: 29 0a 20 20 20 20 20 20 65 6c 73 65 3a 0a 20 20 ). else:.
7fe0: 20 20 20 20 20 20 73 74 61 74 75 73 20 3d 20 30 status = 0
7ff0: 0a 20 20 20 20 66 6f 72 20 66 69 6c 65 6e 61 6d . for filenam
8000: 65 20 69 6e 20 73 65 6c 66 2e 73 63 72 61 74 63 e in self.scratc
8010: 68 5f 6c 69 73 74 3a 0a 20 20 20 20 20 20 69 66 h_list:. if
8020: 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 3a 20 70 self.verbose: p
8030: 72 69 6e 74 28 22 44 65 6c 65 74 69 6e 67 20 73 rint("Deleting s
8040: 63 72 61 74 63 68 5f 63 6f 70 79 3a 20 22 20 2b cratch_copy: " +
8050: 20 66 69 6c 65 6e 61 6d 65 29 0a 20 20 20 20 20 filename).
8060: 20 6f 73 2e 72 65 6d 6f 76 65 28 66 69 6c 65 6e os.remove(filen
8070: 61 6d 65 29 0a 0a 20 20 20 20 73 65 6c 66 2e 73 ame).. self.s
8080: 69 6d 68 2e 73 69 6d 68 5f 63 6d 64 20 28 22 64 imh.simh_cmd ("d
8090: 65 74 61 63 68 20 61 6c 6c 22 29 0a 20 20 20 20 etach all").
80a0: 73 65 6c 66 2e 73 69 6d 68 2e 5f 63 68 69 6c 64 self.simh._child
80b0: 2e 73 65 6e 64 6c 69 6e 65 28 22 71 75 69 74 22 .sendline("quit"
80c0: 29 0a 0a 20 20 20 20 69 66 20 73 65 6c 66 2e 76 ).. if self.v
80d0: 65 72 62 6f 73 65 3a 0a 20 20 20 20 20 20 70 72 erbose:. pr
80e0: 69 6e 74 28 22 43 61 6c 6c 69 6e 67 20 73 79 73 int("Calling sys
80f0: 2e 65 78 69 74 20 28 22 20 2b 20 20 73 74 72 28 .exit (" + str(
8100: 73 74 61 74 75 73 29 20 2b 20 22 29 20 61 74 20 status) + ") at
8110: 6c 69 6e 65 3a 20 22 20 2b 20 5c 0a 20 20 20 20 line: " + \.
8120: 20 20 20 20 20 20 20 20 73 74 72 28 73 65 6c 66 str(self
8130: 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 .line_ct_stack[0
8140: 5d 29 20 2b 20 22 2e 22 29 0a 20 20 20 20 73 79 ]) + "."). sy
8150: 73 2e 65 78 69 74 28 73 74 61 74 75 73 29 0a 0a s.exit(status)..
8160: 0a 20 20 23 23 23 23 20 70 72 69 6e 74 5f 63 6f . #### print_co
8170: 6d 6d 61 6e 64 20 23 23 23 23 23 23 23 23 23 23 mmand ##########
8180: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8190: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
81a0: 23 23 23 23 23 0a 20 20 23 20 50 72 69 6e 74 20 #####. # Print
81b0: 74 65 78 74 20 66 72 6f 6d 20 74 68 65 20 72 75 text from the ru
81c0: 6e 6e 69 6e 67 20 73 63 72 69 70 74 0a 20 20 23 nning script. #
81d0: 20 49 66 20 76 65 72 62 6f 73 65 20 69 73 20 73 If verbose is s
81e0: 65 74 2c 20 73 61 79 20 77 68 61 74 20 6c 69 6e et, say what lin
81f0: 65 20 69 6e 20 74 68 65 20 73 63 72 69 70 74 20 e in the script
8200: 63 6f 6e 74 61 69 6e 69 6e 67 0a 20 20 23 20 74 containing. # t
8210: 68 65 20 70 72 69 6e 74 20 63 6f 6d 6d 61 6e 64 he print command
8220: 2e 0a 0a 20 20 64 65 66 20 70 72 69 6e 74 5f 63 ... def print_c
8230: 6f 6d 6d 61 6e 64 20 28 73 65 6c 66 2c 20 6c 69 ommand (self, li
8240: 6e 65 2c 20 73 63 72 69 70 74 5f 66 69 6c 65 29 ne, script_file)
8250: 3a 0a 20 20 20 20 69 66 20 73 65 6c 66 2e 76 65 :. if self.ve
8260: 72 62 6f 73 65 3a 0a 20 20 20 20 20 20 70 72 69 rbose:. pri
8270: 6e 74 28 22 4c 69 6e 65 3a 20 22 20 2b 20 73 74 nt("Line: " + st
8280: 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 r(self.line_ct_s
8290: 74 61 63 6b 5b 30 5d 29 20 2b 20 22 3a 20 22 20 tack[0]) + ": "
82a0: 2b 20 6c 69 6e 65 29 0a 20 20 20 20 65 6c 73 65 + line). else
82b0: 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 73 65 :. print(se
82c0: 6c 66 2e 70 72 69 6e 74 5f 65 78 70 61 6e 64 28 lf.print_expand(
82d0: 6c 69 6e 65 29 29 0a 20 20 20 20 72 65 74 75 72 line)). retur
82e0: 6e 20 22 73 75 63 63 65 73 73 22 0a 0a 0a 20 20 n "success"...
82f0: 23 23 23 23 20 5f 63 6f 6d 6d 61 6e 64 20 23 23 #### _command ##
8300: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8310: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
8320: 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 0a 0a #########. # ..
8330: 20 20 64 65 66 20 5f 63 6f 6d 6d 61 6e 64 20 28 def _command (
8340: 73 65 6c 66 2c 20 6c 69 6e 65 2c 20 73 63 72 69 self, line, scri
8350: 70 74 5f 66 69 6c 65 29 3a 0a 20 20 20 20 72 65 pt_file):. re
8360: 74 75 72 6e 20 22 73 75 63 63 65 73 73 22 0a 0a turn "success"..
8370: 0a 20 20 23 23 23 23 20 72 75 6e 5f 73 63 72 69 . #### run_scri
8380: 70 74 5f 66 69 6c 65 20 23 23 23 23 23 23 23 23 pt_file ########
8390: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
83a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
83b0: 23 23 23 23 0a 20 20 23 20 52 75 6e 20 6f 73 38 ####. # Run os8
83c0: 20 63 6f 6d 6d 61 6e 64 20 73 63 72 69 70 74 20 command script
83d0: 66 69 6c 65 0a 20 20 23 20 43 61 6c 6c 20 70 61 file. # Call pa
83e0: 72 73 65 72 73 20 61 73 20 6e 65 65 64 65 64 20 rsers as needed
83f0: 66 6f 72 20 73 75 70 70 6f 72 74 65 64 20 73 75 for supported su
8400: 62 20 63 6f 6d 6d 61 6e 64 73 2e 0a 20 20 23 0a b commands.. #.
8410: 20 20 23 20 43 6f 6d 6d 61 6e 64 73 3a 0a 20 20 # Commands:.
8420: 23 20 6d 6f 75 6e 74 20 3c 73 69 6d 68 2d 64 65 # mount <simh-de
8430: 76 3e 20 3c 69 6d 61 67 65 2d 66 69 6c 65 3e 20 v> <image-file>
8440: 5b 3c 6f 70 74 69 6f 6e 3e 20 2e 2e 2e 5d 0a 20 [<option> ...].
8450: 20 23 20 20 20 20 20 20 20 6f 70 74 69 6f 6e 3a # option:
8460: 20 72 65 71 75 69 72 65 64 20 7c 20 70 72 65 73 required | pres
8470: 65 72 76 65 20 7c 20 72 65 61 64 6f 6e 6c 79 20 erve | readonly
8480: 7c 20 72 6f 20 7c 20 73 63 72 61 74 63 68 0a 20 | ro | scratch.
8490: 20 23 20 75 6d 6f 75 6e 74 20 3c 73 69 6d 68 2d # umount <simh-
84a0: 64 65 76 3e 0a 20 20 23 20 62 6f 6f 74 20 3c 73 dev>. # boot <s
84b0: 69 6d 68 2d 64 65 76 3e 0a 20 20 23 20 6f 73 38 imh-dev>. # os8
84c0: 20 3c 63 6f 6d 6d 61 6e 64 2d 6c 69 6e 65 3e 0a <command-line>.
84d0: 20 20 23 20 20 20 20 20 20 20 74 68 65 20 72 65 # the re
84e0: 73 74 20 6f 66 20 74 68 65 20 6c 69 6e 65 20 69 st of the line i
84f0: 73 20 70 61 73 73 65 64 20 76 65 72 62 61 74 69 s passed verbati
8500: 6d 20 74 6f 20 4f 53 2f 38 0a 20 20 23 20 70 61 m to OS/8. # pa
8510: 6c 38 20 3c 70 61 6c 2d 63 6f 6d 6d 61 6e 64 20 l8 <pal-command
8520: 6c 69 6e 65 3e 0a 20 20 23 20 69 6e 63 6c 75 64 line>. # includ
8530: 65 20 3c 73 63 72 69 70 74 2d 66 69 6c 65 3e 0a e <script-file>.
8540: 20 20 23 20 63 6f 6e 66 69 67 75 72 65 20 3c 64 # configure <d
8550: 65 76 69 63 65 3e 20 3c 70 61 72 61 6d 65 74 65 evice> <paramete
8560: 72 3e 0a 20 20 23 20 20 20 20 20 20 20 64 65 76 r>. # dev
8570: 69 63 65 3a 20 74 74 69 20 7c 20 74 61 70 65 20 ice: tti | tape
8580: 7c 20 72 78 0a 20 20 23 20 20 20 20 20 20 20 74 | rx. # t
8590: 74 20 70 61 72 61 6d 65 74 65 72 3a 20 4b 53 52 t parameter: KSR
85a0: 20 7c 20 37 62 0a 20 20 23 20 20 20 20 20 20 20 | 7b. #
85b0: 74 61 70 65 20 70 61 72 61 6d 65 74 65 72 3a 20 tape parameter:
85c0: 74 64 20 7c 20 64 74 0a 20 20 23 20 20 20 20 20 td | dt. #
85d0: 20 20 72 78 20 70 61 72 61 6d 65 74 65 72 3a 20 rx parameter:
85e0: 72 78 38 65 20 7c 20 72 78 32 38 20 7c 20 72 78 rx8e | rx28 | rx
85f0: 30 31 20 7c 20 72 78 30 32 0a 20 20 23 20 65 6e 01 | rx02. # en
8600: 61 62 6c 65 20 3c 70 61 72 61 6d 65 74 65 72 3e able <parameter>
8610: 0a 20 20 23 20 64 69 73 61 62 6c 65 20 3c 70 61 . # disable <pa
8620: 72 61 6d 65 74 65 72 3e 0a 20 20 23 20 63 70 74 rameter>. # cpt
8630: 6f 20 3c 70 6f 73 69 78 2d 66 69 6c 65 3e 20 5b o <posix-file> [
8640: 3c 6f 73 38 2d 66 69 6c 65 3e 5d 20 5b 3c 66 6f <os8-file>] [<fo
8650: 72 6d 61 74 3e 5d 0a 20 20 23 20 63 70 66 72 6f rmat>]. # cpfro
8660: 6d 20 3c 6f 73 38 2d 66 69 6c 65 3e 20 3c 70 6f m <os8-file> <po
8670: 73 69 78 2d 66 69 6c 65 3e 20 5b 3c 66 6f 72 6d six-file> [<form
8680: 61 74 3e 5d 0a 20 20 23 20 20 20 20 20 20 20 66 at>]. # f
8690: 6f 72 6d 61 74 3a 20 2f 41 20 7c 20 2f 49 20 7c ormat: /A | /I |
86a0: 20 2f 42 0a 20 20 23 20 63 6f 70 79 20 3c 66 72 /B. # copy <fr
86b0: 6f 6d 2d 66 69 6c 65 3e 20 3c 74 6f 2d 66 69 6c om-file> <to-fil
86c0: 65 3e 0a 20 20 23 20 70 61 74 63 68 20 3c 70 61 e>. # patch <pa
86d0: 74 63 68 2d 66 69 6c 65 3e 0a 20 20 23 20 72 65 tch-file>. # re
86e0: 73 75 6d 65 0a 20 20 23 20 72 65 73 74 61 72 74 sume. # restart
86f0: 0a 20 20 23 20 62 65 67 69 6e 20 3c 73 75 62 2d . # begin <sub-
8700: 63 6f 6d 6d 61 6e 64 3e 20 3c 6f 73 38 2d 70 61 command> <os8-pa
8710: 74 68 3e 0a 20 20 23 20 65 6e 64 20 3c 73 75 62 th>. # end <sub
8720: 2d 63 6f 6d 6d 61 6e 64 3e 0a 20 20 23 20 70 72 -command>. # pr
8730: 69 6e 74 20 3c 6f 75 74 70 75 74 20 74 65 78 74 int <output text
8740: 3e 0a 20 20 23 20 65 78 69 74 20 3c 73 74 61 74 >. # exit <stat
8750: 75 73 3e 0a 0a 20 20 23 20 53 75 62 2d 63 6f 6d us>.. # Sub-com
8760: 6d 61 6e 64 73 3a 0a 20 20 23 20 62 75 69 6c 64 mands:. # build
8770: 2c 20 66 6f 74 70 2c 20 61 62 73 6c 64 72 0a 20 , fotp, absldr.
8780: 20 23 0a 20 20 23 20 43 6f 6d 6d 61 6e 64 73 20 #. # Commands
8790: 72 65 74 75 72 6e 2c 20 22 73 75 63 63 65 73 73 return, "success
87a0: 22 2c 20 22 66 61 69 6c 22 2c 20 6f 72 20 22 64 ", "fail", or "d
87b0: 69 65 22 2e 0a 0a 20 20 64 65 66 20 72 75 6e 5f ie"... def run_
87c0: 73 63 72 69 70 74 5f 66 69 6c 65 20 28 73 65 6c script_file (sel
87d0: 66 2c 20 73 63 72 69 70 74 5f 70 61 74 68 29 3a f, script_path):
87e0: 0a 20 20 20 20 74 72 79 3a 0a 20 20 20 20 20 20 . try:.
87f0: 73 63 72 69 70 74 5f 66 69 6c 65 20 3d 20 6f 70 script_file = op
8800: 65 6e 28 73 63 72 69 70 74 5f 70 61 74 68 2c 20 en(script_path,
8810: 22 72 22 29 0a 20 20 20 20 65 78 63 65 70 74 20 "r"). except
8820: 49 4f 45 72 72 6f 72 3a 0a 20 20 20 20 20 20 70 IOError:. p
8830: 72 69 6e 74 28 73 63 72 69 70 74 5f 70 61 74 68 rint(script_path
8840: 20 2b 20 22 20 6e 6f 74 20 66 6f 75 6e 64 2e 22 + " not found."
8850: 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 ). return "
8860: 66 61 69 6c 22 0a 20 20 20 20 72 65 74 75 72 6e fail". return
8870: 20 73 65 6c 66 2e 72 75 6e 5f 73 63 72 69 70 74 self.run_script
8880: 5f 68 61 6e 64 6c 65 28 73 63 72 69 70 74 5f 66 _handle(script_f
8890: 69 6c 65 2c 20 73 63 72 69 70 74 5f 70 61 74 68 ile, script_path
88a0: 29 0a 20 20 20 20 0a 20 20 64 65 66 20 72 75 6e ). . def run
88b0: 5f 73 63 72 69 70 74 5f 68 61 6e 64 6c 65 20 28 _script_handle (
88c0: 73 65 6c 66 2c 20 73 63 72 69 70 74 5f 66 69 6c self, script_fil
88d0: 65 2c 20 73 63 72 69 70 74 5f 70 61 74 68 29 3a e, script_path):
88e0: 0a 20 20 23 20 53 74 72 69 6e 67 73 2c 20 72 65 . # Strings, re
88f0: 67 65 78 70 73 2c 20 61 6e 64 20 63 6f 6d 6d 61 gexps, and comma
8900: 6e 64 20 61 72 72 61 79 73 20 75 73 65 64 20 62 nd arrays used b
8910: 79 20 72 75 6e 5f 73 79 73 74 65 6d 0a 20 20 20 y run_system.
8920: 20 63 6f 6d 6d 61 6e 64 73 20 3d 20 7b 22 6d 6f commands = {"mo
8930: 75 6e 74 22 3a 20 73 65 6c 66 2e 6d 6f 75 6e 74 unt": self.mount
8940: 5f 63 6f 6d 6d 61 6e 64 2c 0a 20 20 20 20 20 20 _command,.
8950: 20 20 20 20 20 20 20 20 20 20 22 62 6f 6f 74 22 "boot"
8960: 3a 20 73 65 6c 66 2e 62 6f 6f 74 5f 63 6f 6d 6d : self.boot_comm
8970: 61 6e 64 2c 0a 20 20 20 20 20 20 20 20 20 20 20 and,.
8980: 20 20 20 20 20 22 6f 73 38 22 3a 20 73 65 6c 66 "os8": self
8990: 2e 6f 73 38 5f 63 6f 6d 6d 61 6e 64 2c 0a 20 20 .os8_command,.
89a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 6f "o
89b0: 63 6f 6d 70 22 3a 20 73 65 6c 66 2e 6f 63 6f 6d comp": self.ocom
89c0: 70 5f 63 6f 6d 6d 61 6e 64 2c 0a 20 20 20 20 20 p_command,.
89d0: 20 20 20 20 20 20 20 20 20 20 20 22 70 61 6c 38 "pal8
89e0: 22 3a 20 73 65 6c 66 2e 70 61 6c 38 5f 63 6f 6d ": self.pal8_com
89f0: 6d 61 6e 64 2c 0a 20 20 20 20 20 20 20 20 20 20 mand,.
8a00: 20 20 20 20 20 20 22 69 6e 63 6c 75 64 65 22 3a "include":
8a10: 20 73 65 6c 66 2e 69 6e 63 6c 75 64 65 5f 63 6f self.include_co
8a20: 6d 6d 61 6e 64 2c 0a 20 20 20 20 20 20 20 20 20 mmand,.
8a30: 20 20 20 20 20 20 20 22 62 65 67 69 6e 22 3a 20 "begin":
8a40: 73 65 6c 66 2e 62 65 67 69 6e 5f 63 6f 6d 6d 61 self.begin_comma
8a50: 6e 64 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 nd,.
8a60: 20 20 20 20 22 65 6e 64 22 3a 20 73 65 6c 66 2e "end": self.
8a70: 65 6e 64 5f 63 6f 6d 6d 61 6e 64 2c 0a 20 20 20 end_command,.
8a80: 20 20 20 20 20 20 20 20 20 20 20 20 20 22 65 78 "ex
8a90: 69 74 22 3a 20 73 65 6c 66 2e 65 78 69 74 5f 63 it": self.exit_c
8aa0: 6f 6d 6d 61 6e 64 2c 0a 20 20 20 20 20 20 20 20 ommand,.
8ab0: 20 20 20 20 20 20 20 20 22 70 72 69 6e 74 22 3a "print":
8ac0: 20 73 65 6c 66 2e 70 72 69 6e 74 5f 63 6f 6d 6d self.print_comm
8ad0: 61 6e 64 2c 0a 20 20 20 20 20 20 20 20 20 20 20 and,.
8ae0: 20 20 20 20 20 22 75 6d 6f 75 6e 74 22 3a 20 73 "umount": s
8af0: 65 6c 66 2e 75 6d 6f 75 6e 74 5f 63 6f 6d 6d 61 elf.umount_comma
8b00: 6e 64 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 nd,.
8b10: 20 20 20 20 22 73 69 6d 68 22 3a 20 73 65 6c 66 "simh": self
8b20: 2e 73 69 6d 68 5f 63 6f 6d 6d 61 6e 64 2c 0a 20 .simh_command,.
8b30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 22 "
8b40: 63 6f 6e 66 69 67 75 72 65 22 3a 20 73 65 6c 66 configure": self
8b50: 2e 63 6f 6e 66 69 67 75 72 65 5f 63 6f 6d 6d 61 .configure_comma
8b60: 6e 64 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 nd,.
8b70: 20 20 20 20 22 65 6e 61 62 6c 65 22 3a 20 73 65 "enable": se
8b80: 6c 66 2e 65 6e 61 62 6c 65 5f 6f 70 74 69 6f 6e lf.enable_option
8b90: 5f 63 6f 6d 6d 61 6e 64 2c 0a 20 20 20 20 20 20 _command,.
8ba0: 20 20 20 20 20 20 20 20 20 20 22 64 69 73 61 62 "disab
8bb0: 6c 65 22 3a 20 73 65 6c 66 2e 64 69 73 61 62 6c le": self.disabl
8bc0: 65 5f 6f 70 74 69 6f 6e 5f 63 6f 6d 6d 61 6e 64 e_option_command
8bd0: 2c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ,.
8be0: 20 20 22 63 70 74 6f 22 3a 20 73 65 6c 66 2e 63 "cpto": self.c
8bf0: 70 74 6f 5f 63 6f 6d 6d 61 6e 64 2c 0a 20 20 20 pto_command,.
8c00: 20 20 20 20 20 20 20 20 20 20 20 20 20 22 63 70 "cp
8c10: 66 72 6f 6d 22 3a 20 73 65 6c 66 2e 63 70 66 72 from": self.cpfr
8c20: 6f 6d 5f 63 6f 6d 6d 61 6e 64 2c 0a 20 20 20 20 om_command,.
8c30: 20 20 20 20 20 20 20 20 20 20 20 20 22 63 6f 70 "cop
8c40: 79 22 3a 20 73 65 6c 66 2e 63 6f 70 79 5f 63 6f y": self.copy_co
8c50: 6d 6d 61 6e 64 2c 0a 20 20 20 20 20 20 20 20 20 mmand,.
8c60: 20 20 20 20 20 20 20 22 72 65 73 75 6d 65 22 3a "resume":
8c70: 20 73 65 6c 66 2e 72 65 73 75 6d 65 5f 63 6f 6d self.resume_com
8c80: 6d 61 6e 64 2c 0a 20 20 20 20 20 20 20 20 20 20 mand,.
8c90: 20 20 20 20 20 20 22 72 65 73 74 61 72 74 22 3a "restart":
8ca0: 20 73 65 6c 66 2e 72 65 73 74 61 72 74 5f 63 6f self.restart_co
8cb0: 6d 6d 61 6e 64 2c 0a 20 20 20 20 20 20 20 20 20 mmand,.
8cc0: 20 20 20 20 20 20 20 22 70 61 74 63 68 22 3a 20 "patch":
8cd0: 73 65 6c 66 2e 70 61 74 63 68 5f 63 6f 6d 6d 61 self.patch_comma
8ce0: 6e 64 7d 0a 20 20 0a 20 20 20 20 23 20 45 76 65 nd}. . # Eve
8cf0: 72 79 20 74 69 6d 65 20 77 65 20 73 74 61 72 74 ry time we start
8d00: 20 61 20 6e 65 77 20 73 63 72 69 70 74 0a 20 20 a new script.
8d10: 20 20 23 20 57 65 20 61 70 70 65 6e 64 20 61 20 # We append a
8d20: 6e 65 77 20 6c 69 6e 65 20 6e 75 6d 62 65 72 20 new line number
8d30: 63 6f 75 6e 74 20 6f 66 20 30 0a 20 20 20 20 23 count of 0. #
8d40: 20 6f 6e 74 6f 20 6f 75 72 20 6c 69 6e 65 5f 63 onto our line_c
8d50: 74 5f 73 74 61 63 6b 0a 20 20 20 20 73 65 6c 66 t_stack. self
8d60: 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 2e 69 .line_ct_stack.i
8d70: 6e 73 65 72 74 28 30 2c 20 30 29 0a 20 20 20 20 nsert(0, 0).
8d80: 69 66 20 73 65 6c 66 2e 64 65 62 75 67 3a 0a 20 if self.debug:.
8d90: 20 20 20 20 20 70 72 69 6e 74 28 22 4e 65 77 20 print("New
8da0: 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 3a 20 22 line_ct_stack: "
8db0: 20 2b 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 + str(self.line
8dc0: 5f 63 74 5f 73 74 61 63 6b 29 29 0a 20 20 0a 20 _ct_stack)). .
8dd0: 20 20 20 66 6f 72 20 6c 69 6e 65 20 69 6e 20 73 for line in s
8de0: 63 72 69 70 74 5f 66 69 6c 65 3a 0a 20 20 20 20 cript_file:.
8df0: 20 20 6c 69 6e 65 20 3d 20 73 65 6c 66 2e 62 61 line = self.ba
8e00: 73 69 63 5f 6c 69 6e 65 5f 70 61 72 73 65 20 28 sic_line_parse (
8e10: 6c 69 6e 65 2c 20 73 63 72 69 70 74 5f 66 69 6c line, script_fil
8e20: 65 29 0a 20 20 20 20 20 20 69 66 20 6c 69 6e 65 e). if line
8e30: 20 3d 3d 20 4e 6f 6e 65 3a 20 63 6f 6e 74 69 6e == None: contin
8e40: 75 65 0a 20 20 20 20 20 20 0a 20 20 20 20 20 20 ue. .
8e50: 6d 20 3d 20 72 65 2e 6d 61 74 63 68 28 5f 63 6f m = re.match(_co
8e60: 6d 6d 5f 72 65 2c 20 6c 69 6e 65 29 0a 20 20 20 mm_re, line).
8e70: 20 20 20 69 66 20 6d 20 3d 3d 20 4e 6f 6e 65 3a if m == None:
8e80: 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 . print("
8e90: 49 67 6e 6f 72 69 6e 67 20 63 6f 6d 6d 61 6e 64 Ignoring command
8ea0: 20 6c 69 6e 65 20 61 74 20 6c 69 6e 65 20 22 20 line at line "
8eb0: 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 73 74 + \. st
8ec0: 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 r(self.line_ct_s
8ed0: 74 61 63 6b 5b 30 5d 29 20 2b 20 22 3a 20 22 20 tack[0]) + ": "
8ee0: 2b 20 6c 69 6e 65 29 0a 20 20 20 20 20 20 20 20 + line).
8ef0: 63 6f 6e 74 69 6e 75 65 0a 20 20 0a 20 20 20 20 continue. .
8f00: 20 20 69 66 20 6d 2e 67 72 6f 75 70 28 31 29 20 if m.group(1)
8f10: 6e 6f 74 20 69 6e 20 63 6f 6d 6d 61 6e 64 73 3a not in commands:
8f20: 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 . print("
8f30: 55 6e 72 65 63 6f 67 6e 69 7a 65 64 20 73 63 72 Unrecognized scr
8f40: 69 70 74 20 63 6f 6d 6d 61 6e 64 20 61 74 20 6c ipt command at l
8f50: 69 6e 65 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 ine " + \.
8f60: 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e str(self.lin
8f70: 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b e_ct_stack[0]) +
8f80: 20 22 3a 20 22 20 2b 20 6d 2e 67 72 6f 75 70 28 ": " + m.group(
8f90: 31 29 29 0a 20 20 20 20 20 20 20 20 63 6f 6e 74 1)). cont
8fa0: 69 6e 75 65 0a 20 20 0a 20 20 20 20 20 20 23 20 inue. . #
8fb0: 70 72 69 6e 74 28 22 61 72 67 3a 20 22 20 2b 20 print("arg: " +
8fc0: 6d 2e 67 72 6f 75 70 28 33 29 29 0a 20 20 20 20 m.group(3)).
8fd0: 20 20 69 66 20 6d 2e 67 72 6f 75 70 28 33 29 20 if m.group(3)
8fe0: 3d 3d 20 4e 6f 6e 65 3a 20 72 65 73 74 20 3d 20 == None: rest =
8ff0: 22 22 0a 20 20 20 20 20 20 65 6c 73 65 3a 20 72 "". else: r
9000: 65 73 74 20 3d 20 6d 2e 67 72 6f 75 70 28 33 29 est = m.group(3)
9010: 0a 20 20 20 20 20 20 72 65 74 76 61 6c 20 3d 20 . retval =
9020: 63 6f 6d 6d 61 6e 64 73 5b 6d 2e 67 72 6f 75 70 commands[m.group
9030: 28 31 29 5d 28 72 65 73 74 2c 20 73 63 72 69 70 (1)](rest, scrip
9040: 74 5f 66 69 6c 65 29 0a 20 20 20 20 20 20 69 66 t_file). if
9050: 20 72 65 74 76 61 6c 20 3d 3d 20 22 64 69 65 22 retval == "die"
9060: 3a 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 :. print(
9070: 22 5c 6e 46 61 74 61 6c 20 65 72 72 6f 72 20 65 "\nFatal error e
9080: 6e 63 6f 75 6e 74 65 72 65 64 20 69 6e 20 22 20 ncountered in "
9090: 2b 20 73 63 72 69 70 74 5f 70 61 74 68 20 2b 20 + script_path +
90a0: 5c 0a 20 20 20 20 20 20 20 20 20 20 22 20 61 74 \. " at
90b0: 20 6c 69 6e 65 20 22 20 2b 20 20 73 74 72 28 73 line " + str(s
90c0: 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 elf.line_ct_stac
90d0: 6b 5b 30 5d 29 20 2b 20 22 3a 22 29 0a 20 20 20 k[0]) + ":").
90e0: 20 20 20 20 20 70 72 69 6e 74 28 22 5c 74 22 20 print("\t"
90f0: 2b 20 6c 69 6e 65 29 0a 20 20 20 20 20 20 20 20 + line).
9100: 73 79 73 2e 65 78 69 74 28 2d 31 29 0a 20 20 20 sys.exit(-1).
9110: 20 20 20 65 6c 69 66 20 72 65 74 76 61 6c 20 3d elif retval =
9120: 3d 20 22 66 61 69 6c 22 3a 0a 20 20 20 20 20 20 = "fail":.
9130: 20 20 70 72 69 6e 74 28 22 4e 6f 6e 2d 66 61 74 print("Non-fat
9140: 61 6c 20 65 72 72 6f 72 20 65 6e 63 6f 75 6e 74 al error encount
9150: 65 72 65 64 20 69 6e 20 22 20 2b 20 73 63 72 69 ered in " + scri
9160: 70 74 5f 70 61 74 68 20 2b 20 5c 0a 20 20 20 20 pt_path + \.
9170: 20 20 20 20 20 20 22 20 61 74 20 6c 69 6e 65 20 " at line
9180: 22 20 2b 20 20 73 74 72 28 73 65 6c 66 2e 6c 69 " + str(self.li
9190: 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 ne_ct_stack[0])
91a0: 2b 20 22 3a 22 29 0a 20 20 20 20 20 20 20 20 70 + ":"). p
91b0: 72 69 6e 74 28 22 5c 74 22 20 2b 20 6c 69 6e 65 rint("\t" + line
91c0: 20 2b 20 22 5c 6e 22 29 0a 0a 20 20 20 20 23 20 + "\n").. #
91d0: 44 6f 6e 65 2e 20 20 50 6f 70 20 74 68 65 20 6c Done. Pop the l
91e0: 69 6e 65 20 63 6f 75 6e 74 20 6f 66 66 20 6f 75 ine count off ou
91f0: 72 20 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 0a r line_ct_stack.
9200: 20 20 20 20 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 self.line_ct
9210: 5f 73 74 61 63 6b 2e 70 6f 70 28 30 29 0a 20 20 _stack.pop(0).
9220: 20 20 69 66 20 73 65 6c 66 2e 64 65 62 75 67 3a if self.debug:
9230: 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 70 6f . print("po
9240: 70 70 65 64 20 6c 69 6e 65 5f 63 74 5f 73 74 61 pped line_ct_sta
9250: 63 6b 3a 20 22 20 2b 20 73 74 72 28 73 65 6c 66 ck: " + str(self
9260: 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 29 29 .line_ct_stack))
9270: 0a 20 20 20 20 0a 20 20 20 20 72 65 74 75 72 6e . . return
9280: 20 22 73 75 63 63 65 73 73 22 0a 0a 0a 20 20 23 "success"... #
9290: 23 23 23 20 65 6e 64 5f 63 6f 6d 6d 61 6e 64 20 ### end_command
92a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
92b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
92c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
92d0: 23 23 23 23 23 0a 20 20 0a 20 20 64 65 66 20 65 #####. . def e
92e0: 6e 64 5f 63 6f 6d 6d 61 6e 64 20 28 73 65 6c 66 nd_command (self
92f0: 2c 20 6c 69 6e 65 2c 20 73 63 72 69 70 74 5f 66 , line, script_f
9300: 69 6c 65 29 3a 0a 20 20 20 20 70 72 69 6e 74 28 ile):. print(
9310: 22 55 6e 65 78 70 65 63 74 65 64 6c 79 20 65 6e "Unexpectedly en
9320: 63 6f 75 6e 74 65 72 65 64 20 65 6e 64 20 63 6f countered end co
9330: 6d 6d 61 6e 64 20 61 74 20 6c 69 6e 65 20 22 20 mmand at line "
9340: 2b 20 5c 0a 20 20 20 20 20 20 73 74 72 28 73 65 + \. str(se
9350: 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b lf.line_ct_stack
9360: 5b 30 5d 29 20 2b 20 22 3a 20 22 20 2b 20 6c 69 [0]) + ": " + li
9370: 6e 65 29 0a 20 20 20 20 72 65 74 75 72 6e 20 22 ne). return "
9380: 66 61 69 6c 22 0a 0a 20 20 0a 20 20 23 23 23 23 fail".. . ####
9390: 20 70 61 72 73 65 5f 6f 64 74 20 23 23 23 23 23 parse_odt #####
93a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
93b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
93c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
93d0: 23 23 0a 20 20 0a 20 20 64 65 66 20 70 61 72 73 ##. . def pars
93e0: 65 5f 6f 64 74 20 28 73 65 6c 66 2c 20 6c 69 6e e_odt (self, lin
93f0: 65 29 3a 0a 20 20 20 20 69 66 20 73 65 6c 66 2e e):. if self.
9400: 64 65 62 75 67 3a 20 70 72 69 6e 74 28 6c 69 6e debug: print(lin
9410: 65 29 0a 20 20 20 20 0a 20 20 20 20 69 66 20 6c e). . if l
9420: 69 6e 65 20 3d 3d 20 22 5c 5c 63 22 3a 20 72 65 ine == "\\c": re
9430: 74 75 72 6e 20 22 62 72 65 61 6b 22 0a 20 20 20 turn "break".
9440: 20 6d 61 74 63 68 20 3d 20 5f 6f 64 74 5f 70 61 match = _odt_pa
9450: 72 73 65 2e 6d 61 74 63 68 28 6c 69 6e 65 29 0a rse.match(line).
9460: 20 20 20 20 69 66 20 6d 61 74 63 68 20 3d 3d 20 if match ==
9470: 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 72 69 6e None:. prin
9480: 74 28 22 41 62 6f 72 74 69 6e 67 20 62 65 63 61 t("Aborting beca
9490: 75 73 65 20 6f 66 20 62 61 64 20 4f 44 54 20 6c use of bad ODT l
94a0: 69 6e 65 3a 20 22 20 2b 20 6c 69 6e 65 29 0a 20 ine: " + line).
94b0: 20 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 2e 6f self.simh.o
94c0: 73 38 5f 63 74 72 6c 5f 63 20 28 63 61 6c 6c 65 s8_ctrl_c (calle
94d0: 72 3d 22 70 61 72 73 65 5f 6f 64 74 22 29 0a 20 r="parse_odt").
94e0: 20 20 20 20 20 72 65 74 75 72 6e 20 22 65 72 72 return "err
94f0: 22 0a 20 20 20 20 6c 6f 63 20 3d 20 6d 61 74 63 ". loc = matc
9500: 68 2e 67 72 6f 75 70 28 31 29 0a 20 20 20 20 6f h.group(1). o
9510: 6c 64 5f 76 61 6c 20 3d 20 6d 61 74 63 68 2e 67 ld_val = match.g
9520: 72 6f 75 70 28 32 29 0a 20 20 20 20 6e 65 77 5f roup(2). new_
9530: 76 61 6c 20 3d 20 6d 61 74 63 68 2e 67 72 6f 75 val = match.grou
9540: 70 28 33 29 0a 20 20 20 20 65 78 70 65 63 74 5f p(3). expect_
9550: 76 61 6c 5f 73 74 72 20 3d 20 22 5c 73 2a 5b 30 val_str = "\s*[0
9560: 2d 37 5d 7b 34 7d 20 22 0a 20 20 20 20 0a 20 20 -7]{4} ". .
9570: 20 20 69 66 20 73 65 6c 66 2e 64 65 62 75 67 3a if self.debug:
9580: 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 4c 6f . print("Lo
9590: 63 3a 20 22 20 2b 20 6c 6f 63 20 2b 20 22 2c 20 c: " + loc + ",
95a0: 6f 6c 64 5f 76 61 6c 3a 20 22 20 2b 20 6f 6c 64 old_val: " + old
95b0: 5f 76 61 6c 20 2b 20 22 2c 20 6e 65 77 5f 76 61 _val + ", new_va
95c0: 6c 3a 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 20 l: " + \.
95d0: 20 20 20 6e 65 77 5f 76 61 6c 29 0a 20 20 20 20 new_val).
95e0: 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 73 65 self.simh.os8_se
95f0: 6e 64 5f 73 74 72 20 28 6c 6f 63 20 2b 20 22 2f nd_str (loc + "/
9600: 22 29 0a 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 "). self.simh
9610: 2e 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 28 65 ._child.expect(e
9620: 78 70 65 63 74 5f 76 61 6c 5f 73 74 72 29 0a 20 xpect_val_str).
9630: 20 0a 20 20 20 20 69 66 20 6f 6c 64 5f 76 61 6c . if old_val
9640: 2e 69 73 64 69 67 69 74 28 29 3a 20 20 20 20 20 .isdigit():
9650: 20 20 20 20 20 23 20 57 65 20 6e 65 65 64 20 74 # We need t
9660: 6f 20 63 68 65 63 6b 20 6f 6c 64 20 76 61 6c 75 o check old valu
9670: 65 0a 20 20 20 20 20 20 66 6f 75 6e 64 5f 76 61 e. found_va
9680: 6c 20 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 63 68 l = self.simh.ch
9690: 69 6c 64 5f 61 66 74 65 72 28 29 2e 73 74 72 69 ild_after().stri
96a0: 70 28 29 0a 20 20 20 20 20 20 69 66 20 66 6f 75 p(). if fou
96b0: 6e 64 5f 76 61 6c 20 21 3d 20 6f 6c 64 5f 76 61 nd_val != old_va
96c0: 6c 3a 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 l:. print
96d0: 28 22 5c 74 4f 6c 64 20 76 61 6c 75 65 3a 20 22 ("\tOld value: "
96e0: 20 2b 20 66 6f 75 6e 64 5f 76 61 6c 20 2b 20 22 + found_val + "
96f0: 20 64 6f 65 73 20 6e 6f 74 20 6d 61 74 63 68 20 does not match
9700: 22 20 2b 0a 20 20 20 20 20 20 20 20 20 20 20 20 " +.
9710: 6f 6c 64 5f 76 61 6c 20 2b 20 22 2e 20 41 62 6f old_val + ". Abo
9720: 72 74 69 6e 67 20 70 61 74 63 68 2e 22 29 0a 20 rting patch.").
9730: 20 20 20 20 20 20 20 23 20 41 62 6f 72 74 20 6f # Abort o
9740: 75 74 20 6f 66 20 4f 44 54 20 62 61 63 6b 20 74 ut of ODT back t
9750: 6f 20 74 68 65 20 4f 53 2f 38 20 4d 6f 6e 69 74 o the OS/8 Monit
9760: 6f 72 0a 20 20 20 20 20 20 20 20 73 65 6c 66 2e or. self.
9770: 73 69 6d 68 2e 6f 73 38 5f 63 74 72 6c 5f 63 20 simh.os8_ctrl_c
9780: 28 22 70 61 72 73 65 5f 6f 64 74 20 32 22 29 0a ("parse_odt 2").
9790: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 return "
97a0: 65 72 72 22 0a 20 20 0a 20 20 20 20 73 65 6c 66 err". . self
97b0: 2e 73 69 6d 68 2e 6f 73 38 5f 73 65 6e 64 5f 6c .simh.os8_send_l
97c0: 69 6e 65 20 28 6e 65 77 5f 76 61 6c 29 0a 20 20 ine (new_val).
97d0: 20 20 72 65 74 75 72 6e 20 22 63 6f 6e 74 22 0a return "cont".
97e0: 0a 0a 20 20 23 23 23 23 20 66 75 74 69 6c 5f 65 .. #### futil_e
97f0: 78 69 74 20 23 23 23 23 23 23 23 23 23 23 23 23 xit ############
9800: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9810: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9820: 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 0a ############. .
9830: 20 20 64 65 66 20 66 75 74 69 6c 5f 65 78 69 74 def futil_exit
9840: 20 28 73 65 6c 66 2c 20 6c 69 6e 65 29 3a 0a 20 (self, line):.
9850: 20 20 20 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 self.simh.os8
9860: 5f 73 65 6e 64 5f 6c 69 6e 65 28 6c 69 6e 65 29 _send_line(line)
9870: 0a 20 20 20 20 72 65 74 75 72 6e 20 22 62 72 65 . return "bre
9880: 61 6b 22 0a 0a 0a 20 20 23 23 23 23 20 66 75 74 ak"... #### fut
9890: 69 6c 5f 66 69 6c 65 20 23 23 23 23 23 23 23 23 il_file ########
98a0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
98b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
98c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
98d0: 0a 20 20 0a 20 20 64 65 66 20 66 75 74 69 6c 5f . . def futil_
98e0: 66 69 6c 65 20 28 73 65 6c 66 2c 20 6c 69 6e 65 file (self, line
98f0: 29 3a 0a 20 20 20 20 23 20 52 65 64 75 6e 64 61 ):. # Redunda
9900: 6e 74 20 72 65 2d 70 61 72 73 65 20 6f 66 20 6c nt re-parse of l
9910: 69 6e 65 20 62 75 74 20 6e 6f 62 6f 64 79 20 65 ine but nobody e
9920: 6c 73 65 20 77 61 6e 74 73 20 61 72 67 73 20 72 lse wants args r
9930: 69 67 68 74 20 6e 6f 77 2e 0a 20 20 20 20 6d 61 ight now.. ma
9940: 74 63 68 20 3d 20 5f 63 6f 6d 5f 73 70 6c 69 74 tch = _com_split
9950: 5f 70 61 72 73 65 2e 6d 61 74 63 68 28 6c 69 6e _parse.match(lin
9960: 65 29 0a 20 20 20 20 69 66 20 6d 61 74 63 68 20 e). if match
9970: 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 == None:. p
9980: 72 69 6e 74 28 22 41 62 6f 72 74 69 6e 67 20 62 rint("Aborting b
9990: 65 63 61 75 73 65 20 6f 66 20 6d 61 6c 2d 66 6f ecause of mal-fo
99a0: 72 6d 65 64 20 46 55 54 49 4c 20 46 49 4c 45 20 rmed FUTIL FILE
99b0: 63 6f 6d 6d 61 6e 64 3a 20 22 20 2b 20 6c 69 6e command: " + lin
99c0: 65 29 0a 20 20 20 20 20 20 73 65 6c 66 2e 73 69 e). self.si
99d0: 6d 68 2e 6f 73 38 5f 63 74 72 6c 5f 63 20 28 63 mh.os8_ctrl_c (c
99e0: 61 6c 6c 65 72 3d 22 66 75 74 69 6c 5f 66 69 6c aller="futil_fil
99f0: 65 22 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e e"). return
9a00: 20 22 65 72 72 22 0a 20 20 20 20 66 6e 61 6d 65 "err". fname
9a10: 20 3d 20 6d 61 74 63 68 2e 67 72 6f 75 70 28 32 = match.group(2
9a20: 29 0a 20 20 20 20 65 78 70 65 63 74 5f 66 75 74 ). expect_fut
9a30: 69 6c 5f 66 69 6c 65 5f 73 74 72 20 3d 20 22 5c il_file_str = "\
9a40: 6e 22 20 2b 20 66 6e 61 6d 65 20 2b 20 22 5c 73 n" + fname + "\s
9a50: 2b 28 3f 21 22 20 2b 20 66 6e 61 6d 65 20 20 2b +(?!" + fname +
9a60: 20 22 29 3f 28 5c 53 2b 29 28 2e 2a 29 24 22 0a ")?(\S+)(.*)$".
9a70: 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 self.simh.os
9a80: 38 5f 73 65 6e 64 5f 6c 69 6e 65 20 28 6c 69 6e 8_send_line (lin
9a90: 65 29 0a 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 e). self.simh
9aa0: 2e 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 28 65 ._child.expect(e
9ab0: 78 70 65 63 74 5f 66 75 74 69 6c 5f 66 69 6c 65 xpect_futil_file
9ac0: 5f 73 74 72 29 0a 20 20 20 20 72 65 73 75 6c 74 _str). result
9ad0: 20 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 63 68 69 = self.simh.chi
9ae0: 6c 64 5f 61 66 74 65 72 28 29 2e 73 74 72 69 70 ld_after().strip
9af0: 28 29 0a 20 20 20 20 6d 61 74 63 68 20 3d 20 5f (). match = _
9b00: 63 6f 6d 5f 73 70 6c 69 74 5f 70 61 72 73 65 2e com_split_parse.
9b10: 6d 61 74 63 68 28 72 65 73 75 6c 74 29 0a 20 20 match(result).
9b20: 20 20 69 66 20 6d 61 74 63 68 20 3d 3d 20 4e 6f if match == No
9b30: 6e 65 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 ne:. print(
9b40: 22 41 62 6f 72 74 69 6e 67 20 62 65 63 61 75 73 "Aborting becaus
9b50: 65 20 75 6e 65 78 70 65 63 74 65 64 20 72 65 74 e unexpected ret
9b60: 75 72 6e 20 73 74 61 74 75 73 3a 20 22 20 2b 20 urn status: " +
9b70: 72 65 73 75 6c 74 20 2b 20 5c 0a 20 20 20 20 20 result + \.
9b80: 20 20 20 20 20 22 20 66 72 6f 6d 3a 20 22 20 2b " from: " +
9b90: 20 6c 69 6e 65 29 0a 20 20 20 20 20 20 73 65 6c line). sel
9ba0: 66 2e 73 69 6d 68 2e 6f 73 38 5f 63 74 72 6c 5f f.simh.os8_ctrl_
9bb0: 63 20 28 63 61 6c 6c 65 72 3d 22 66 75 74 69 6c c (caller="futil
9bc0: 5f 66 69 6c 65 20 32 22 29 0a 20 20 20 20 20 20 _file 2").
9bd0: 72 65 74 75 72 6e 20 22 65 72 72 22 0a 20 20 20 return "err".
9be0: 20 69 66 20 6d 61 74 63 68 2e 67 72 6f 75 70 28 if match.group(
9bf0: 32 29 2e 73 74 72 69 70 28 29 20 3d 3d 20 22 4c 2).strip() == "L
9c00: 4f 4f 4b 55 50 20 46 41 49 4c 45 44 22 3a 0a 20 OOKUP FAILED":.
9c10: 20 20 20 20 20 70 72 69 6e 74 28 22 41 62 6f 72 print("Abor
9c20: 74 69 6e 67 20 62 65 63 61 75 73 65 20 6f 66 20 ting because of
9c30: 46 55 54 49 4c 20 6c 6f 6f 6b 75 70 20 66 61 69 FUTIL lookup fai
9c40: 6c 75 72 65 20 6f 6e 3a 20 22 20 2b 20 66 6e 61 lure on: " + fna
9c50: 6d 65 29 0a 20 20 20 20 20 20 73 65 6c 66 2e 73 me). self.s
9c60: 69 6d 68 2e 6f 73 38 5f 63 74 72 6c 5f 63 20 28 imh.os8_ctrl_c (
9c70: 63 61 6c 6c 65 72 3d 22 66 75 74 69 6c 5f 66 69 caller="futil_fi
9c80: 6c 65 20 33 22 29 0a 20 20 20 20 20 20 72 65 74 le 3"). ret
9c90: 75 72 6e 20 22 65 72 72 22 0a 20 20 20 20 65 6c urn "err". el
9ca0: 73 65 3a 0a 20 20 20 20 20 20 72 65 74 75 72 6e se:. return
9cb0: 20 22 63 6f 6e 74 22 0a 20 20 0a 20 20 0a 20 20 "cont". . .
9cc0: 23 23 23 23 20 70 61 72 73 65 5f 66 75 74 69 6c #### parse_futil
9cd0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
9ce0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9cf0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
9d00: 23 23 23 23 23 23 0a 20 20 23 0a 20 20 23 20 56 ######. #. # V
9d10: 65 72 79 20 73 69 6d 70 6c 65 20 6d 69 6e 64 65 ery simple minde
9d20: 64 3a 0a 20 20 23 20 49 66 20 66 69 72 73 74 20 d:. # If first
9d30: 63 68 61 72 20 6f 6e 20 6c 69 6e 65 20 69 73 20 char on line is
9d40: 61 6e 20 61 6c 70 68 61 2c 20 72 75 6e 20 74 68 an alpha, run th
9d50: 65 20 63 6f 6d 6d 61 6e 64 2e 0a 20 20 23 20 49 e command.. # I
9d60: 66 20 74 68 65 20 66 69 72 73 74 20 63 68 61 72 f the first char
9d70: 20 6f 6e 20 6c 69 6e 65 20 69 73 20 6e 75 6d 62 on line is numb
9d80: 65 72 2c 20 64 6f 20 74 68 65 20 73 75 62 73 74 er, do the subst
9d90: 69 74 75 74 65 20 63 6f 6d 6d 61 6e 64 2e 0a 20 itute command..
9da0: 20 23 0a 20 20 23 20 53 75 62 73 74 69 74 75 74 #. # Substitut
9db0: 65 20 63 6f 6d 6d 61 6e 64 20 61 63 74 73 20 6c e command acts l
9dc0: 69 6b 65 20 4f 44 54 2e 0a 20 20 23 20 46 75 74 ike ODT.. # Fut
9dd0: 75 72 65 20 76 65 72 73 69 6f 6e 20 73 68 6f 75 ure version shou
9de0: 6c 64 20 73 75 70 70 6f 72 74 20 74 68 65 20 49 ld support the I
9df0: 46 20 63 6f 6e 73 74 72 75 63 74 2e 0a 20 20 23 F construct.. #
9e00: 0a 20 20 23 20 57 68 65 6e 20 77 65 20 65 6e 63 . # When we enc
9e10: 6f 75 6e 74 65 72 20 74 68 65 20 45 58 49 54 20 ounter the EXIT
9e20: 63 6f 6d 6d 61 6e 64 2c 20 77 65 20 72 65 74 75 command, we retu
9e30: 72 6e 20 73 75 63 63 65 73 73 2e 0a 20 20 0a 20 rn success.. .
9e40: 20 64 65 66 20 70 61 72 73 65 5f 66 75 74 69 6c def parse_futil
9e50: 20 28 73 65 6c 66 2c 20 6c 69 6e 65 29 3a 0a 20 (self, line):.
9e60: 20 20 20 66 75 74 69 6c 5f 73 70 65 63 69 61 6c futil_special
9e70: 73 20 3d 20 7b 0a 20 20 20 20 20 20 22 45 58 49 s = {. "EXI
9e80: 54 22 3a 20 73 65 6c 66 2e 66 75 74 69 6c 5f 65 T": self.futil_e
9e90: 78 69 74 2c 0a 20 20 20 20 20 20 22 46 49 4c 45 xit,. "FILE
9ea0: 22 3a 20 73 65 6c 66 2e 66 75 74 69 6c 5f 66 69 ": self.futil_fi
9eb0: 6c 65 0a 20 20 20 20 7d 0a 20 20 0a 20 20 20 20 le. }. .
9ec0: 69 66 20 6c 69 6e 65 5b 30 5d 2e 69 73 64 69 67 if line[0].isdig
9ed0: 69 74 28 29 3a 0a 20 20 20 20 20 20 23 20 54 72 it():. # Tr
9ee0: 65 61 74 20 74 68 65 20 6c 69 6e 65 20 61 73 20 eat the line as
9ef0: 4f 44 54 0a 20 20 20 20 20 20 72 65 74 75 72 6e ODT. return
9f00: 20 73 65 6c 66 2e 70 61 72 73 65 5f 6f 64 74 28 self.parse_odt(
9f10: 6c 69 6e 65 29 0a 20 20 20 20 65 6c 73 65 3a 0a line). else:.
9f20: 20 20 20 20 20 20 6d 61 74 63 68 20 3d 20 5f 63 match = _c
9f30: 6f 6d 5f 73 70 6c 69 74 5f 70 61 72 73 65 2e 6d om_split_parse.m
9f40: 61 74 63 68 28 6c 69 6e 65 29 0a 20 20 20 20 20 atch(line).
9f50: 20 69 66 20 6d 61 74 63 68 20 3d 3d 20 4e 6f 6e if match == Non
9f60: 65 3a 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 e:. print
9f70: 28 22 49 67 6e 6f 72 69 6e 67 20 66 61 69 6c 65 ("Ignoring faile
9f80: 64 20 46 55 54 49 4c 20 63 6f 6d 6d 61 6e 64 20 d FUTIL command
9f90: 70 61 72 73 65 20 6f 66 3a 20 22 20 2b 20 6c 69 parse of: " + li
9fa0: 6e 65 29 0a 20 20 20 20 20 20 20 20 72 65 74 75 ne). retu
9fb0: 72 6e 20 22 63 6f 6e 74 22 0a 20 20 20 20 20 20 rn "cont".
9fc0: 66 63 6f 6d 20 3d 20 6d 61 74 63 68 2e 67 72 6f fcom = match.gro
9fd0: 75 70 28 31 29 0a 20 20 20 20 20 20 72 65 73 74 up(1). rest
9fe0: 20 3d 20 6d 61 74 63 68 2e 67 72 6f 75 70 28 32 = match.group(2
9ff0: 29 0a 20 20 0a 20 20 20 20 20 20 69 66 20 66 63 ). . if fc
a000: 6f 6d 20 6e 6f 74 20 69 6e 20 66 75 74 69 6c 5f om not in futil_
a010: 73 70 65 63 69 61 6c 73 3a 0a 20 20 20 20 20 20 specials:.
a020: 20 20 23 20 42 6c 69 6e 64 20 66 61 69 74 68 20 # Blind faith
a030: 61 6e 64 20 6e 6f 20 65 72 72 6f 72 20 63 68 65 and no error che
a040: 63 6b 69 6e 67 2e 0a 20 20 20 20 20 20 20 20 73 cking.. s
a050: 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 73 65 6e elf.simh.os8_sen
a060: 64 5f 6c 69 6e 65 28 6c 69 6e 65 29 0a 20 20 20 d_line(line).
a070: 20 20 20 20 20 72 65 74 75 72 6e 20 22 63 6f 6e return "con
a080: 74 22 0a 20 20 20 20 20 20 65 6c 73 65 3a 0a 20 t". else:.
a090: 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 66 75 return fu
a0a0: 74 69 6c 5f 73 70 65 63 69 61 6c 73 5b 66 63 6f til_specials[fco
a0b0: 6d 5d 28 6c 69 6e 65 29 0a 0a 0a 20 20 23 23 23 m](line)... ###
a0c0: 23 20 72 75 6e 5f 70 61 74 63 68 5f 66 69 6c 65 # run_patch_file
a0d0: 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ###############
a0e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
a0f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
a100: 23 23 23 0a 20 20 0a 20 20 64 65 66 20 72 75 6e ###. . def run
a110: 5f 70 61 74 63 68 5f 66 69 6c 65 20 28 73 65 6c _patch_file (sel
a120: 66 2c 20 70 61 74 68 6e 61 6d 65 2c 20 6c 69 6e f, pathname, lin
a130: 65 2c 20 73 63 72 69 70 74 5f 66 69 6c 65 29 3a e, script_file):
a140: 0a 20 20 20 20 73 79 73 2e 73 74 64 6f 75 74 2e . sys.stdout.
a150: 77 72 69 74 65 20 28 22 41 70 70 6c 79 69 6e 67 write ("Applying
a160: 20 70 61 74 63 68 20 22 20 2b 20 6f 73 2e 70 61 patch " + os.pa
a170: 74 68 2e 62 61 73 65 6e 61 6d 65 20 28 70 61 74 th.basename (pat
a180: 68 6e 61 6d 65 29 20 2b 20 22 2e 2e 2e 22 29 0a hname) + "...").
a190: 20 20 20 20 73 79 73 2e 73 74 64 6f 75 74 2e 66 sys.stdout.f
a1a0: 6c 75 73 68 20 28 29 0a 0a 20 20 20 20 74 72 79 lush ().. try
a1b0: 3a 0a 20 20 20 20 20 20 70 61 74 63 68 5f 66 69 :. patch_fi
a1c0: 6c 65 20 3d 20 6f 70 65 6e 28 70 61 74 68 6e 61 le = open(pathna
a1d0: 6d 65 2c 20 22 72 22 29 0a 20 20 20 20 65 78 63 me, "r"). exc
a1e0: 65 70 74 20 49 4f 45 72 72 6f 72 3a 0a 20 20 20 ept IOError:.
a1f0: 20 20 20 70 72 69 6e 74 28 70 61 74 68 6e 61 6d print(pathnam
a200: 65 20 2b 20 22 20 6e 6f 74 20 66 6f 75 6e 64 2e e + " not found.
a210: 20 53 6b 69 70 70 69 6e 67 2e 22 29 0a 20 20 20 Skipping.").
a220: 20 20 20 72 65 74 75 72 6e 20 22 66 61 69 6c 22 return "fail"
a230: 0a 20 20 20 20 0a 20 20 20 20 23 20 53 75 70 70 . . # Supp
a240: 6f 72 74 65 64 20 70 61 72 73 65 72 73 2e 0a 20 orted parsers..
a250: 20 20 20 23 20 4e 6f 74 65 20 74 68 74 20 46 55 # Note tht FU
a260: 54 49 4c 20 68 61 73 20 6e 6f 74 20 62 65 65 6e TIL has not been
a270: 20 74 65 73 74 65 64 20 73 69 6e 63 65 20 77 65 tested since we
a280: 20 66 6c 69 70 70 65 64 20 74 68 65 20 65 78 70 flipped the exp
a290: 65 63 74 20 6f 72 64 65 72 2e 0a 20 20 20 20 70 ect order.. p
a2a0: 61 72 73 65 72 73 20 3d 20 7b 0a 20 20 20 20 20 arsers = {.
a2b0: 20 22 4f 44 54 22 3a 20 73 65 6c 66 2e 70 61 72 "ODT": self.par
a2c0: 73 65 5f 6f 64 74 2c 0a 20 20 20 20 20 20 22 46 se_odt,. "F
a2d0: 55 54 49 4c 22 3a 20 73 65 6c 66 2e 70 61 72 73 UTIL": self.pars
a2e0: 65 5f 66 75 74 69 6c 0a 20 20 20 20 7d 0a 0a 20 e_futil. }..
a2f0: 20 20 20 23 20 57 68 61 74 20 70 72 6f 6d 70 74 # What prompt
a300: 20 64 6f 20 77 65 20 77 61 6e 74 20 77 68 65 6e do we want when
a310: 20 77 65 20 72 75 6e 20 61 6e 20 61 6c 6c 6f 77 we run an allow
a320: 65 64 20 63 6f 6d 6d 61 6e 64 3f 0a 20 20 20 20 ed command?.
a330: 23 20 49 66 20 74 68 65 72 65 20 69 73 20 6e 6f # If there is no
a340: 6e 65 2c 20 77 65 20 64 6f 6e 27 74 20 77 61 69 ne, we don't wai
a350: 74 2e 20 20 42 75 74 20 69 66 20 77 65 20 77 61 t. But if we wa
a360: 6e 74 20 6f 6e 65 2c 0a 20 20 20 20 23 20 57 65 nt one,. # We
a370: 20 42 45 54 54 45 52 20 77 61 69 74 20 66 6f 72 BETTER wait for
a380: 20 69 74 2e 20 20 41 20 72 61 63 65 20 63 6f 6e it. A race con
a390: 64 69 74 69 6f 6e 20 68 61 73 20 62 65 65 6e 20 dition has been
a3a0: 6f 62 73 65 72 76 65 64 0a 20 20 20 20 23 20 77 observed. # w
a3b0: 68 65 72 65 2c 20 69 66 20 77 65 20 64 6f 6e 27 here, if we don'
a3c0: 74 20 77 61 69 74 20 66 6f 72 20 53 41 56 45 2c t wait for SAVE,
a3d0: 20 69 74 20 6d 69 67 68 74 20 6e 6f 74 20 68 61 it might not ha
a3e0: 70 70 65 6e 2e 0a 20 20 20 20 61 6c 6c 6f 77 65 ppen.. allowe
a3f0: 64 5f 63 6f 6d 6d 61 6e 64 73 20 3d 20 5b 22 4f d_commands = ["O
a400: 44 54 22 2c 20 22 52 22 2c 20 22 47 45 54 22 2c DT", "R", "GET",
a410: 20 22 47 45 22 2c 20 20 22 53 41 56 45 22 2c 20 "GE", "SAVE",
a420: 22 53 41 22 5d 0a 20 20 20 20 0a 20 20 20 20 69 "SA"]. . i
a430: 6e 73 69 64 65 5f 61 5f 63 6f 6d 6d 61 6e 64 20 nside_a_command
a440: 3d 20 46 61 6c 73 65 0a 20 20 20 20 74 68 65 5f = False. the_
a450: 63 6f 6d 6d 61 6e 64 20 3d 20 22 22 0a 20 20 20 command = "".
a460: 20 74 68 65 5f 63 6f 6d 6d 61 6e 64 5f 70 61 72 the_command_par
a470: 73 65 72 20 3d 20 4e 6f 6e 65 0a 20 20 20 20 0a ser = None. .
a480: 20 20 20 20 23 20 41 6e 79 20 6f 73 38 2d 72 75 # Any os8-ru
a490: 6e 20 63 6f 6d 6d 61 6e 64 20 6d 61 79 20 62 65 n command may be
a4a0: 20 63 61 6c 6c 65 64 20 61 66 74 65 72 20 61 20 called after a
a4b0: 73 69 6d 68 20 63 6f 6d 6d 61 6e 64 20 74 68 61 simh command tha
a4c0: 74 20 6c 65 66 74 20 75 73 0a 20 20 20 20 23 20 t left us. #
a4d0: 69 6e 20 73 69 6d 68 20 63 6f 6e 74 65 78 74 2e in simh context.
a4e0: 20 43 68 65 63 6b 20 74 6f 20 73 65 65 20 69 66 Check to see if
a4f0: 20 77 65 20 6e 65 65 64 20 74 6f 20 72 65 73 74 we need to rest
a500: 61 72 74 20 4f 53 2f 38 2e 0a 20 20 20 20 23 20 art OS/8.. #
a510: 57 65 20 72 65 73 75 6d 65 20 4f 53 2f 38 2e 20 We resume OS/8.
a520: 49 74 20 73 68 6f 75 6c 64 20 62 65 20 6e 6f 6e It should be non
a530: 2d 64 69 73 72 75 70 74 69 76 65 20 61 6e 64 20 -disruptive and
a540: 77 6f 72 6b 20 77 65 6c 6c 2e 0a 20 20 20 20 69 work well.. i
a550: 66 20 73 65 6c 66 2e 73 69 6d 68 2e 5f 63 6f 6e f self.simh._con
a560: 74 65 78 74 20 3d 3d 20 22 73 69 6d 68 22 3a 0a text == "simh":.
a570: 20 20 20 20 20 20 73 65 6c 66 2e 72 65 73 75 6d self.resum
a580: 65 5f 63 6f 6d 6d 61 6e 64 28 6c 69 6e 65 2c 20 e_command(line,
a590: 73 63 72 69 70 74 5f 66 69 6c 65 29 0a 0a 20 20 script_file)..
a5a0: 20 20 66 6f 72 20 6c 69 6e 65 20 69 6e 20 70 61 for line in pa
a5b0: 74 63 68 5f 66 69 6c 65 3a 0a 20 20 20 20 20 20 tch_file:.
a5c0: 6c 69 6e 65 20 3d 20 6c 69 6e 65 2e 72 73 74 72 line = line.rstr
a5d0: 69 70 28 29 0a 20 20 20 20 20 20 69 66 20 6c 69 ip(). if li
a5e0: 6e 65 20 3d 3d 20 22 22 3a 20 63 6f 6e 74 69 6e ne == "": contin
a5f0: 75 65 0a 20 20 20 20 20 20 65 6c 69 66 20 6c 69 ue. elif li
a600: 6e 65 5b 30 5d 20 3d 3d 20 27 23 27 3a 20 63 6f ne[0] == '#': co
a610: 6e 74 69 6e 75 65 20 20 20 20 20 23 20 49 67 6e ntinue # Ign
a620: 6f 72 65 20 43 6f 6d 6d 65 6e 74 73 0a 20 20 20 ore Comments.
a630: 20 20 20 65 6c 69 66 20 69 6e 73 69 64 65 5f 61 elif inside_a
a640: 5f 63 6f 6d 6d 61 6e 64 3a 0a 20 20 20 20 20 20 _command:.
a650: 20 20 72 65 74 76 61 6c 20 3d 20 74 68 65 5f 63 retval = the_c
a660: 6f 6d 6d 61 6e 64 5f 70 61 72 73 65 72 20 28 6c ommand_parser (l
a670: 69 6e 65 29 0a 20 20 20 20 20 20 20 20 69 66 20 ine). if
a680: 72 65 74 76 61 6c 20 3d 3d 20 22 62 72 65 61 6b retval == "break
a690: 22 3a 0a 20 20 20 20 20 20 20 20 20 20 69 6e 73 ":. ins
a6a0: 69 64 65 5f 61 5f 63 6f 6d 6d 61 6e 64 20 3d 20 ide_a_command =
a6b0: 46 61 6c 73 65 0a 20 20 20 20 20 20 20 20 20 20 False.
a6c0: 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 63 74 self.simh.os8_ct
a6d0: 72 6c 5f 63 20 28 63 61 6c 6c 65 72 3d 22 72 75 rl_c (caller="ru
a6e0: 6e 5f 70 61 74 63 68 5f 66 69 6c 65 22 29 0a 20 n_patch_file").
a6f0: 20 20 20 20 20 20 20 65 6c 69 66 20 72 65 74 76 elif retv
a700: 61 6c 20 3d 3d 20 22 65 72 72 22 3a 0a 20 20 20 al == "err":.
a710: 20 20 20 20 20 20 20 70 61 74 63 68 5f 66 69 6c patch_fil
a720: 65 2e 63 6c 6f 73 65 28 29 0a 20 20 20 20 20 20 e.close().
a730: 20 20 20 20 72 65 74 75 72 6e 20 22 66 61 69 6c return "fail
a740: 22 0a 20 20 20 20 20 20 65 6c 69 66 20 6c 69 6e ". elif lin
a750: 65 5b 30 5d 20 3d 3d 20 27 2e 27 3a 20 20 20 20 e[0] == '.':
a760: 20 20 20 20 23 20 4e 65 77 20 4f 53 2f 38 20 43 # New OS/8 C
a770: 6f 6d 6d 61 6e 64 0a 20 20 20 20 20 20 20 20 6d ommand. m
a780: 61 74 63 68 20 3d 20 5f 63 6f 6d 5f 6f 73 38 5f atch = _com_os8_
a790: 70 61 72 73 65 2e 6d 61 74 63 68 28 6c 69 6e 65 parse.match(line
a7a0: 29 0a 20 20 20 20 20 20 20 20 69 66 20 6d 61 74 ). if mat
a7b0: 63 68 20 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 ch == None:.
a7c0: 20 20 20 20 20 20 70 72 69 6e 74 28 22 41 62 6f print("Abo
a7d0: 72 74 69 6e 67 20 70 61 74 63 68 20 6f 6e 20 66 rting patch on f
a7e0: 61 69 6c 65 64 20 4f 53 2f 38 20 63 6f 6d 6d 61 ailed OS/8 comma
a7f0: 6e 64 20 70 61 72 73 65 20 6f 66 3a 20 22 20 2b nd parse of: " +
a800: 20 6c 69 6e 65 29 0a 20 20 20 20 20 20 20 20 20 line).
a810: 20 72 65 74 75 72 6e 20 22 66 61 69 6c 22 0a 20 return "fail".
a820: 20 20 20 20 20 20 20 63 6f 6d 20 3d 20 6d 61 74 com = mat
a830: 63 68 2e 67 72 6f 75 70 28 31 29 0a 20 20 20 20 ch.group(1).
a840: 20 20 20 20 72 65 73 74 20 3d 20 6d 61 74 63 68 rest = match
a850: 2e 67 72 6f 75 70 28 32 29 0a 20 20 0a 20 20 20 .group(2). .
a860: 20 20 20 20 20 69 66 20 63 6f 6d 20 6e 6f 74 20 if com not
a870: 69 6e 20 61 6c 6c 6f 77 65 64 5f 63 6f 6d 6d 61 in allowed_comma
a880: 6e 64 73 3a 0a 20 20 20 20 20 20 20 20 20 20 70 nds:. p
a890: 72 69 6e 74 20 28 22 43 6f 6d 6d 61 6e 64 20 22 rint ("Command "
a8a0: 20 2b 20 63 6f 6d 20 2b 20 22 20 6e 6f 74 20 61 + com + " not a
a8b0: 6c 6c 6f 77 65 64 20 69 6e 20 70 61 74 63 68 2e llowed in patch.
a8c0: 20 49 67 6e 6f 72 69 6e 67 2e 22 29 0a 20 20 20 Ignoring.").
a8d0: 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 0a continue.
a8e0: 20 20 20 20 20 20 20 20 23 20 46 61 6c 6c 20 74 # Fall t
a8f0: 68 72 6f 75 67 68 20 74 6f 20 73 74 61 72 74 20 hrough to start
a900: 75 70 20 6f 75 72 20 63 6f 6d 6d 61 6e 64 2e 0a up our command..
a910: 20 20 20 20 20 20 20 20 23 20 4d 61 79 62 65 20 # Maybe
a920: 63 6f 6d 6d 61 6e 64 20 69 73 20 22 2e 4f 44 54 command is ".ODT
a930: 22 2c 20 6d 61 79 62 65 20 69 74 27 73 20 22 52 ", maybe it's "R
a940: 20 46 55 54 49 4c 22 0a 20 20 20 20 20 20 20 20 FUTIL".
a950: 69 66 20 63 6f 6d 20 3d 3d 20 22 52 22 3a 0a 20 if com == "R":.
a960: 20 20 20 20 20 20 20 20 20 23 20 43 68 65 63 6b # Check
a970: 20 74 6f 20 73 65 65 20 69 66 20 77 65 20 63 61 to see if we ca
a980: 6e 20 72 75 6e 20 74 68 69 73 2e 0a 20 20 20 20 n run this..
a990: 20 20 20 20 20 20 69 66 20 72 65 73 74 20 6e 6f if rest no
a9a0: 74 20 69 6e 20 70 61 72 73 65 72 73 3a 0a 20 20 t in parsers:.
a9b0: 20 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 20 print
a9c0: 28 22 4e 6f 74 20 61 6c 6c 6f 77 65 64 20 74 6f ("Not allowed to
a9d0: 20 72 75 6e 20 22 20 2b 20 72 65 73 74 20 2b 20 run " + rest +
a9e0: 22 20 69 6e 20 61 20 70 61 74 63 68 20 66 69 6c " in a patch fil
a9f0: 65 2e 20 20 41 62 6f 72 74 69 6e 67 2e 22 29 0a e. Aborting.").
aa00: 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 75 retu
aa10: 72 6e 20 22 66 61 69 6c 22 0a 20 20 20 20 20 20 rn "fail".
aa20: 20 20 20 20 63 6f 6d 20 3d 20 72 65 73 74 20 20 com = rest
aa30: 20 20 20 23 20 4e 6f 77 20 66 61 6c 6c 20 74 68 # Now fall th
aa40: 72 6f 75 67 68 20 61 6e 20 73 65 74 20 74 68 65 rough an set the
aa50: 5f 63 6f 6d 6d 61 6e 64 0a 20 20 20 20 20 20 20 _command.
aa60: 20 74 68 65 5f 63 6f 6d 6d 61 6e 64 20 3d 20 63 the_command = c
aa70: 6f 6d 0a 20 20 20 20 20 20 20 20 0a 20 20 20 20 om. .
aa80: 20 20 20 20 23 20 4e 6f 69 73 79 20 64 65 62 75 # Noisy debu
aa90: 67 20 6f 75 74 70 75 74 2e 20 4f 75 72 20 6c 69 g output. Our li
aaa0: 6e 65 2e 0a 20 20 20 20 20 20 20 20 69 66 20 73 ne.. if s
aab0: 65 6c 66 2e 76 65 72 62 6f 73 65 20 61 6e 64 20 elf.verbose and
aac0: 73 65 6c 66 2e 64 65 62 75 67 3a 20 70 72 69 6e self.debug: prin
aad0: 74 28 6c 69 6e 65 29 0a 0a 20 20 20 20 20 20 20 t(line)..
aae0: 20 23 20 41 72 65 20 77 65 20 67 6f 69 6e 67 20 # Are we going
aaf0: 74 6f 20 62 65 20 69 6e 73 69 64 65 20 61 20 63 to be inside a c
ab00: 6f 6d 6d 61 6e 64 20 61 66 74 65 72 20 77 65 20 ommand after we
ab10: 64 6f 20 74 68 65 20 72 75 6e 3f 0a 20 20 20 20 do the run?.
ab20: 20 20 20 20 69 66 20 63 6f 6d 20 69 6e 20 70 61 if com in pa
ab30: 72 73 65 72 73 3a 0a 20 20 20 20 20 20 20 20 20 rsers:.
ab40: 20 74 68 65 5f 63 6f 6d 6d 61 6e 64 5f 70 61 72 the_command_par
ab50: 73 65 72 20 3d 20 70 61 72 73 65 72 73 5b 63 6f ser = parsers[co
ab60: 6d 5d 0a 20 20 20 20 20 20 20 20 20 20 69 6e 73 m]. ins
ab70: 69 64 65 5f 61 5f 63 6f 6d 6d 61 6e 64 20 3d 20 ide_a_command =
ab80: 54 72 75 65 0a 20 20 20 20 20 20 20 20 20 20 23 True. #
ab90: 20 52 75 6e 20 74 68 65 20 6c 69 6e 65 20 62 6c Run the line bl
aba0: 69 6e 64 2c 20 73 6b 69 70 70 69 6e 67 20 6f 76 ind, skipping ov
abb0: 65 72 20 74 68 65 20 64 6f 74 20 61 74 20 74 68 er the dot at th
abc0: 65 20 62 65 67 69 6e 6e 69 6e 67 2e 0a 20 20 20 e beginning..
abd0: 20 20 20 20 20 20 20 23 20 57 65 20 77 6f 6e 27 # We won'
abe0: 74 20 67 65 74 20 61 20 70 72 6f 6d 70 74 2e 0a t get a prompt..
abf0: 20 20 20 20 20 20 20 20 20 20 73 65 6c 66 2e 73 self.s
ac00: 69 6d 68 2e 6f 73 38 5f 73 65 6e 64 5f 6c 69 6e imh.os8_send_lin
ac10: 65 20 28 6c 69 6e 65 5b 31 3a 5d 29 0a 20 20 20 e (line[1:]).
ac20: 20 20 20 20 20 23 20 49 74 27 73 20 61 6e 20 4f # It's an O
ac30: 53 2f 38 20 63 6f 6d 6d 61 6e 64 0a 20 20 20 20 S/8 command.
ac40: 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 else:.
ac50: 20 20 20 20 23 20 57 65 20 6d 75 73 74 20 74 65 # We must te
ac60: 73 74 20 66 6f 72 20 6d 6f 6e 69 74 6f 72 20 70 st for monitor p
ac70: 72 6f 6d 70 74 20 74 6f 20 73 69 67 6e 69 66 79 rompt to signify
ac80: 20 73 75 63 63 65 73 73 2e 0a 20 20 20 20 20 20 success..
ac90: 20 20 20 20 23 20 4f 74 68 65 72 77 69 73 65 20 # Otherwise
aca0: 61 20 72 61 63 65 20 63 6f 6e 64 69 74 69 6f 6e a race condition
acb0: 20 68 61 73 20 62 65 65 6e 20 73 68 6f 77 6e 20 has been shown
acc0: 74 6f 20 70 72 65 76 65 6e 74 20 73 61 76 65 20 to prevent save
acd0: 6f 66 0a 20 20 20 20 20 20 20 20 20 20 23 20 70 of. # p
ace0: 61 74 63 68 65 64 20 62 69 6e 61 72 79 20 62 65 atched binary be
acf0: 63 61 75 73 65 20 6f 75 72 20 65 78 69 74 20 6f cause our exit o
ad00: 66 20 53 49 4d 48 20 68 61 70 70 65 6e 73 20 74 f SIMH happens t
ad10: 6f 6f 20 71 75 69 63 6b 6c 79 21 0a 20 20 20 20 oo quickly!.
ad20: 20 20 20 20 20 20 72 65 70 6c 79 20 3d 20 73 65 reply = se
ad30: 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 63 6d 64 20 lf.simh.os8_cmd
ad40: 28 6c 69 6e 65 5b 31 3a 5d 29 20 20 23 20 53 6b (line[1:]) # Sk
ad50: 69 70 20 6f 76 65 72 20 50 72 6f 6d 70 74 20 69 ip over Prompt i
ad60: 6e 20 6c 69 6e 65 2e 0a 20 20 20 20 20 20 20 20 n line..
ad70: 20 20 23 20 57 65 20 6e 65 65 64 20 74 6f 20 63 # We need to c
ad80: 6f 6e 66 69 72 6d 20 77 65 20 73 75 63 63 65 65 onfirm we succee
ad90: 64 65 64 2e 0a 20 20 20 20 20 20 20 20 20 20 23 ded.. #
ada0: 20 49 66 20 77 65 20 66 61 69 6c 2c 20 77 65 20 If we fail, we
adb0: 6a 75 73 74 20 63 6f 6d 70 6c 61 69 6e 20 61 6e just complain an
adc0: 64 20 6b 65 65 70 20 67 6f 69 6e 67 2e 0a 20 20 d keep going..
add0: 20 20 20 20 20 20 20 20 73 65 6c 66 2e 73 69 6d self.sim
ade0: 68 2e 6f 73 38 5f 74 65 73 74 5f 72 65 73 75 6c h.os8_test_resul
adf0: 74 20 28 72 65 70 6c 79 2c 20 22 4d 6f 6e 69 74 t (reply, "Monit
ae00: 6f 72 20 50 72 6f 6d 70 74 22 2c 20 22 72 75 6e or Prompt", "run
ae10: 5f 70 61 74 63 68 5f 66 69 6c 65 20 63 6f 6d 6d _patch_file comm
ae20: 61 6e 64 20 22 20 5c 0a 20 20 20 20 20 20 20 20 and " \.
ae30: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
ae40: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 2b 20 +
ae50: 6c 69 6e 65 5b 31 3a 5d 29 0a 20 20 20 20 23 20 line[1:]). #
ae60: 44 6f 6e 65 20 77 69 74 68 20 61 6c 6c 20 70 61 Done with all pa
ae70: 74 63 68 20 66 69 6c 65 20 6c 69 6e 65 73 2e 0a tch file lines..
ae80: 20 20 20 20 70 61 74 63 68 5f 66 69 6c 65 2e 63 patch_file.c
ae90: 6c 6f 73 65 28 29 0a 20 20 0a 20 20 20 20 70 72 lose(). . pr
aea0: 69 6e 74 28 22 53 75 63 63 65 73 73 2e 22 29 0a int("Success.").
aeb0: 20 20 20 20 72 65 74 75 72 6e 20 22 73 75 63 63 return "succ
aec0: 65 73 73 22 0a 0a 0a 20 20 23 23 23 23 20 73 6b ess"... #### sk
aed0: 69 70 5f 70 61 74 63 68 20 23 23 23 23 23 23 23 ip_patch #######
aee0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
aef0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
af00: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a ###############.
af10: 20 20 23 20 52 65 74 75 72 6e 73 20 74 72 75 65 # Returns true
af20: 20 69 66 20 74 68 65 20 67 69 76 65 6e 20 66 69 if the given fi
af30: 6c 65 6e 61 6d 65 20 6d 61 74 63 68 65 73 20 6f lename matches o
af40: 6e 65 20 6f 66 20 74 68 65 20 72 65 67 65 78 20 ne of the regex
af50: 73 74 72 69 6e 67 0a 20 20 23 20 6b 65 79 73 20 string. # keys
af60: 6f 66 20 74 68 65 20 67 69 76 65 6e 20 73 6b 69 of the given ski
af70: 70 73 20 64 69 63 74 20 61 6e 64 20 74 68 65 20 ps dict and the
af80: 66 6c 61 67 20 76 61 6c 75 65 20 66 6f 72 20 74 flag value for t
af90: 68 61 74 20 6b 65 79 20 69 73 20 73 65 74 2e 0a hat key is set..
afa0: 20 20 23 20 53 65 65 20 73 6b 69 70 73 20 64 65 # See skips de
afb0: 66 69 6e 69 74 69 6f 6e 20 69 6e 20 6d 61 6b 65 finition in make
afc0: 5f 70 61 74 63 68 2c 20 77 68 69 63 68 20 63 61 _patch, which ca
afd0: 6c 6c 73 20 74 68 69 73 2e 0a 20 20 0a 20 20 64 lls this.. . d
afe0: 65 66 20 73 6b 69 70 5f 70 61 74 63 68 20 28 66 ef skip_patch (f
aff0: 6e 2c 20 73 6b 69 70 73 29 3a 0a 20 20 20 20 20 n, skips):.
b000: 20 66 6f 72 20 70 20 69 6e 20 73 6b 69 70 73 3a for p in skips:
b010: 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 72 65 . if re
b020: 2e 73 65 61 72 63 68 20 28 70 2c 20 66 6e 29 20 .search (p, fn)
b030: 61 6e 64 20 73 6b 69 70 73 5b 70 5d 3a 20 72 65 and skips[p]: re
b040: 74 75 72 6e 20 54 72 75 65 0a 20 20 20 20 20 20 turn True.
b050: 72 65 74 75 72 6e 20 46 61 6c 73 65 0a 20 20 0a return False. .
b060: 0a 20 20 23 23 23 23 20 73 69 6d 68 5f 63 6f 6d . #### simh_com
b070: 6d 61 6e 64 20 23 23 23 23 23 23 23 23 23 23 23 mand ###########
b080: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
b090: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
b0a0: 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 49 20 #########. # I
b0b0: 74 72 69 65 64 20 74 6f 20 61 76 6f 69 64 20 69 tried to avoid i
b0c0: 6e 63 6c 75 64 69 6e 67 20 74 68 69 73 20 63 6f ncluding this co
b0d0: 6d 6d 61 6e 64 20 62 75 74 20 73 6f 6d 65 74 69 mmand but someti
b0e0: 6d 65 73 20 79 6f 75 20 6a 75 73 74 0a 20 20 23 mes you just. #
b0f0: 20 68 61 76 65 20 74 6f 20 72 65 63 6f 6e 66 69 have to reconfi
b100: 67 75 72 65 20 73 75 62 74 6c 65 20 62 69 74 73 gure subtle bits
b110: 20 6f 66 20 64 65 76 69 63 65 20 64 72 69 76 65 of device drive
b120: 72 73 2e 0a 20 20 23 20 57 65 20 61 73 73 75 6d rs.. # We assum
b130: 65 20 77 65 20 63 61 6e 20 63 61 6c 6c 20 61 20 e we can call a
b140: 73 69 6d 68 20 63 6f 6d 6d 61 6e 64 20 61 74 20 simh command at
b150: 61 6e 79 20 74 69 6d 65 2c 20 62 75 74 0a 20 20 any time, but.
b160: 23 20 64 6f 69 6e 67 20 73 6f 20 70 75 74 73 20 # doing so puts
b170: 75 73 20 69 6e 20 74 68 65 20 73 69 6d 68 20 63 us in the simh c
b180: 6f 6e 74 65 78 74 20 74 68 61 74 20 70 65 72 73 ontext that pers
b190: 69 73 74 73 20 75 6e 74 69 6c 20 77 65 0a 20 20 ists until we.
b1a0: 23 20 69 73 73 75 65 20 61 20 62 6f 6f 74 20 6f # issue a boot o
b1b0: 72 20 67 6f 20 63 6f 6d 6d 61 6e 64 2e 0a 20 20 r go command..
b1c0: 0a 20 20 64 65 66 20 73 69 6d 68 5f 63 6f 6d 6d . def simh_comm
b1d0: 61 6e 64 20 28 73 65 6c 66 2c 20 6c 69 6e 65 2c and (self, line,
b1e0: 20 73 63 72 69 70 74 5f 66 69 6c 65 29 3a 0a 20 script_file):.
b1f0: 20 20 20 70 72 69 6e 74 28 22 73 69 6d 68 20 63 print("simh c
b200: 6f 6d 6d 61 6e 64 20 69 73 20 64 69 73 61 62 6c ommand is disabl
b210: 65 64 2e 20 4c 69 6e 65 20 22 20 2b 20 5c 0a 20 ed. Line " + \.
b220: 20 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c 69 str(self.li
b230: 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 ne_ct_stack[0])
b240: 2b 20 22 20 69 67 6e 6f 72 65 64 2e 22 29 0a 20 + " ignored.").
b250: 20 20 20 72 65 74 75 72 6e 20 22 66 61 69 6c 22 return "fail"
b260: 0a 20 20 20 20 69 66 20 73 65 6c 66 2e 76 65 72 . if self.ver
b270: 62 6f 73 65 3a 20 70 72 69 6e 74 28 6c 69 6e 65 bose: print(line
b280: 29 0a 20 20 20 20 72 65 70 6c 79 20 3d 20 73 65 ). reply = se
b290: 6c 66 2e 73 69 6d 68 2e 73 69 6d 68 5f 63 6d 64 lf.simh.simh_cmd
b2a0: 28 6c 69 6e 65 29 0a 20 20 20 20 73 65 6c 66 2e (line). self.
b2b0: 73 69 6d 68 2e 73 69 6d 68 5f 74 65 73 74 5f 72 simh.simh_test_r
b2c0: 65 73 75 6c 74 28 72 65 70 6c 79 2c 20 22 50 72 esult(reply, "Pr
b2d0: 6f 6d 70 74 22 2c 20 22 73 69 6d 68 5f 63 6f 6d ompt", "simh_com
b2e0: 6d 61 6e 64 22 29 0a 20 20 20 20 72 65 74 75 72 mand"). retur
b2f0: 6e 20 22 73 75 63 63 65 73 73 22 0a 0a 0a 20 20 n "success"...
b300: 23 23 23 23 20 75 6d 6f 75 6e 74 5f 63 6f 6d 6d #### umount_comm
b310: 61 6e 64 20 23 23 23 23 23 23 23 23 23 23 23 23 and ############
b320: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
b330: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
b340: 23 23 23 23 23 23 0a 20 20 64 65 66 20 75 6d 6f ######. def umo
b350: 75 6e 74 5f 63 6f 6d 6d 61 6e 64 20 28 73 65 6c unt_command (sel
b360: 66 2c 20 6c 69 6e 65 2c 20 73 63 72 69 70 74 5f f, line, script_
b370: 66 69 6c 65 29 3a 0a 20 20 20 20 64 65 74 61 63 file):. detac
b380: 68 5f 63 6f 6d 6d 20 3d 20 22 64 65 74 20 22 20 h_comm = "det "
b390: 2b 20 6c 69 6e 65 0a 20 20 20 20 69 66 20 73 65 + line. if se
b3a0: 6c 66 2e 76 65 72 62 6f 73 65 3a 20 70 72 69 6e lf.verbose: prin
b3b0: 74 28 22 6c 69 6e 65 3a 20 22 20 2b 20 5c 0a 20 t("line: " + \.
b3c0: 20 20 20 20 20 20 20 73 74 72 28 73 65 6c 66 2e str(self.
b3d0: 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d line_ct_stack[0]
b3e0: 29 20 2b 20 22 3a 20 22 20 2b 20 64 65 74 61 63 ) + ": " + detac
b3f0: 68 5f 63 6f 6d 6d 29 0a 20 20 20 20 72 65 70 6c h_comm). repl
b400: 79 20 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 73 69 y = self.simh.si
b410: 6d 68 5f 63 6d 64 28 64 65 74 61 63 68 5f 63 6f mh_cmd(detach_co
b420: 6d 6d 2c 20 64 65 62 75 67 3d 73 65 6c 66 2e 64 mm, debug=self.d
b430: 65 62 75 67 29 0a 20 20 20 20 73 65 6c 66 2e 73 ebug). self.s
b440: 69 6d 68 2e 73 69 6d 68 5f 74 65 73 74 5f 72 65 imh.simh_test_re
b450: 73 75 6c 74 28 72 65 70 6c 79 2c 20 22 50 72 6f sult(reply, "Pro
b460: 6d 70 74 22 2c 20 22 75 6d 6f 75 6e 74 5f 63 6f mpt", "umount_co
b470: 6d 6d 61 6e 64 22 29 0a 20 20 20 20 72 65 74 75 mmand"). retu
b480: 72 6e 20 22 73 75 63 63 65 73 73 22 0a 0a 0a 20 rn "success"...
b490: 20 23 23 23 23 20 6d 61 6b 65 5f 73 63 72 61 74 #### make_scrat
b4a0: 63 68 20 23 23 23 23 23 23 23 23 23 23 23 23 23 ch #############
b4b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
b4c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
b4d0: 23 23 23 23 23 23 23 0a 20 20 23 20 43 72 65 61 #######. # Crea
b4e0: 74 65 20 61 20 63 6f 70 79 20 6f 66 20 74 68 65 te a copy of the
b4f0: 20 63 6f 6e 74 65 6e 74 73 20 6f 66 20 69 6d 61 contents of ima
b500: 67 65 20 66 69 6c 65 20 75 73 69 6e 67 20 74 68 ge file using th
b510: 65 20 70 79 74 68 6f 6e 0a 20 20 23 20 6d 65 74 e python. # met
b520: 68 6f 64 20 74 6f 20 63 72 65 61 74 65 20 61 20 hod to create a
b530: 73 65 63 75 72 65 2c 20 6e 61 6d 65 64 20 74 65 secure, named te
b540: 6d 70 20 66 69 6c 65 6e 61 6d 65 2e 0a 20 20 23 mp filename.. #
b550: 20 54 68 65 20 63 61 6c 6c 65 72 20 68 61 73 20 The caller has
b560: 73 70 6c 69 74 20 74 68 65 20 69 6d 61 67 65 20 split the image
b570: 66 69 6c 65 20 6e 61 6d 65 20 69 6e 74 6f 20 61 file name into a
b580: 20 62 61 73 65 20 70 61 74 68 2c 0a 20 20 23 20 base path,. #
b590: 61 6e 64 20 61 6e 20 65 78 74 65 6e 73 69 6f 6e and an extension
b5a0: 20 77 68 69 63 68 20 77 65 20 75 73 65 2e 0a 20 which we use..
b5b0: 20 23 20 41 66 74 65 72 20 63 6f 70 79 69 6e 67 # After copying
b5c0: 20 74 68 65 20 73 6f 75 72 63 65 20 69 6d 61 67 the source imag
b5d0: 65 2c 20 74 68 65 20 66 69 6c 65 20 69 73 20 63 e, the file is c
b5e0: 6c 6f 73 65 64 20 61 6e 64 20 74 68 65 20 6e 61 losed and the na
b5f0: 6d 65 0a 20 20 23 20 6f 66 20 74 68 65 20 73 63 me. # of the sc
b600: 72 61 74 63 68 20 66 69 6c 65 20 69 73 20 72 65 ratch file is re
b610: 74 75 72 6e 65 64 2e 0a 20 20 64 65 66 20 6d 61 turned.. def ma
b620: 6b 65 5f 73 63 72 61 74 63 68 20 28 73 65 6c 66 ke_scratch (self
b630: 2c 20 62 61 73 65 5f 69 6d 61 67 65 6e 61 6d 65 , base_imagename
b640: 2c 20 65 78 74 65 6e 73 69 6f 6e 29 3a 0a 20 20 , extension):.
b650: 20 20 74 72 79 3a 0a 20 20 20 20 20 20 73 72 63 try:. src
b660: 5f 69 6d 61 67 65 20 3d 20 6f 70 65 6e 28 62 61 _image = open(ba
b670: 73 65 5f 69 6d 61 67 65 6e 61 6d 65 2b 65 78 74 se_imagename+ext
b680: 65 6e 73 69 6f 6e 2c 20 22 72 62 22 29 0a 20 20 ension, "rb").
b690: 20 20 65 78 63 65 70 74 20 49 4f 45 72 72 6f 72 except IOError
b6a0: 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 4f :. print("O
b6b0: 70 65 6e 20 6f 66 20 69 6d 61 67 65 66 69 6c 65 pen of imagefile
b6c0: 20 22 20 2b 20 62 61 73 65 5f 69 6d 61 67 65 6e " + base_imagen
b6d0: 61 6d 65 20 2b 20 65 78 74 65 6e 73 69 6f 6e 20 ame + extension
b6e0: 2b 20 22 20 66 61 69 6c 65 64 2e 22 29 0a 20 20 + " failed.").
b6f0: 20 20 20 20 72 65 74 75 72 6e 20 4e 6f 6e 65 0a return None.
b700: 20 20 20 20 20 20 0a 20 20 20 20 64 65 73 74 5f . dest_
b710: 69 6d 61 67 65 20 3d 20 74 65 6d 70 66 69 6c 65 image = tempfile
b720: 2e 4e 61 6d 65 64 54 65 6d 70 6f 72 61 72 79 46 .NamedTemporaryF
b730: 69 6c 65 28 6d 6f 64 65 3d 27 77 2b 62 27 2c 20 ile(mode='w+b',
b740: 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 \.
b750: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b760: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 70 p
b770: 72 65 66 69 78 3d 62 61 73 65 5f 69 6d 61 67 65 refix=base_image
b780: 6e 61 6d 65 2b 27 2d 74 65 6d 70 2d 27 2c 20 5c name+'-temp-', \
b790: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 .
b7a0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b7b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 75 su
b7c0: 66 66 69 78 3d 65 78 74 65 6e 73 69 6f 6e 2c 20 ffix=extension,
b7d0: 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 \.
b7e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
b7f0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 64 d
b800: 65 6c 65 74 65 3d 46 61 6c 73 65 29 0a 20 20 20 elete=False).
b810: 20 64 65 73 74 6e 61 6d 65 20 3d 20 64 65 73 74 destname = dest
b820: 5f 69 6d 61 67 65 2e 6e 61 6d 65 0a 20 20 20 20 _image.name.
b830: 69 66 20 73 65 6c 66 2e 64 65 62 75 67 3a 20 70 if self.debug: p
b840: 72 69 6e 74 28 22 54 65 6d 70 20 66 69 6c 65 20 rint("Temp file
b850: 6e 61 6d 65 20 69 73 3a 20 22 20 2b 20 64 65 73 name is: " + des
b860: 74 6e 61 6d 65 29 0a 0a 20 20 20 20 74 72 79 3a tname).. try:
b870: 0a 20 20 20 20 20 20 73 68 75 74 69 6c 2e 63 6f . shutil.co
b880: 70 79 66 69 6c 65 6f 62 6a 28 73 72 63 5f 69 6d pyfileobj(src_im
b890: 61 67 65 2c 20 64 65 73 74 5f 69 6d 61 67 65 29 age, dest_image)
b8a0: 0a 20 20 20 20 65 78 63 65 70 74 20 73 68 75 74 . except shut
b8b0: 69 6c 2e 45 72 72 6f 72 20 61 73 20 65 3a 0a 20 il.Error as e:.
b8c0: 20 20 20 20 20 70 72 69 6e 74 28 22 43 6f 70 79 print("Copy
b8d0: 20 6f 66 20 69 6d 61 67 65 66 69 6c 65 20 22 20 of imagefile "
b8e0: 2b 20 62 61 73 65 5f 69 6d 61 67 65 6e 61 6d 65 + base_imagename
b8f0: 20 2b 20 65 78 74 65 6e 73 69 6f 6e 20 2b 20 5c + extension + \
b900: 0a 20 20 20 20 20 20 20 20 22 20 74 6f 20 73 63 . " to sc
b910: 72 61 74 63 68 20 66 61 69 6c 65 64 20 77 69 74 ratch failed wit
b920: 68 20 65 72 72 6f 72 3a 20 22 20 2b 20 73 74 72 h error: " + str
b930: 28 65 29 29 0a 20 20 20 20 20 20 72 65 74 75 72 (e)). retur
b940: 6e 20 4e 6f 6e 65 0a 20 20 20 20 65 78 63 65 70 n None. excep
b950: 74 20 49 4f 45 72 72 6f 72 20 61 73 20 65 3a 0a t IOError as e:.
b960: 20 20 20 20 20 20 70 72 69 6e 74 28 22 43 6f 70 print("Cop
b970: 79 20 6f 66 20 69 6d 61 67 65 66 69 6c 65 20 22 y of imagefile "
b980: 20 2b 20 62 61 73 65 5f 69 6d 61 67 65 6e 61 6d + base_imagenam
b990: 65 20 2b 20 65 78 74 65 6e 73 69 6f 6e 20 2b 20 e + extension +
b9a0: 5c 0a 20 20 20 20 20 20 20 20 20 20 22 2c 20 66 \. ", f
b9b0: 61 69 6c 65 64 20 77 69 74 68 20 49 4f 45 72 72 ailed with IOErr
b9c0: 6f 72 3a 20 22 20 2b 20 73 74 72 28 65 29 29 0a or: " + str(e)).
b9d0: 20 20 20 20 20 20 72 65 74 75 72 6e 20 4e 6f 6e return Non
b9e0: 65 0a 20 20 20 20 73 72 63 5f 69 6d 61 67 65 2e e. src_image.
b9f0: 63 6c 6f 73 65 28 29 0a 20 20 20 20 64 65 73 74 close(). dest
ba00: 5f 69 6d 61 67 65 2e 63 6c 6f 73 65 28 29 0a 20 _image.close().
ba10: 20 20 20 73 65 6c 66 2e 73 63 72 61 74 63 68 5f self.scratch_
ba20: 6c 69 73 74 2e 61 70 70 65 6e 64 28 64 65 73 74 list.append(dest
ba30: 6e 61 6d 65 29 0a 20 20 20 20 72 65 74 75 72 6e name). return
ba40: 20 64 65 73 74 6e 61 6d 65 0a 20 20 20 20 0a 0a destname. ..
ba50: 20 20 23 23 23 23 20 6d 6f 75 6e 74 5f 63 6f 6d #### mount_com
ba60: 6d 61 6e 64 20 23 23 23 23 23 23 23 23 23 23 23 mand ###########
ba70: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
ba80: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
ba90: 23 23 23 23 23 23 23 23 0a 20 20 23 20 6d 6f 75 ########. # mou
baa0: 6e 74 20 3c 73 69 6d 68 2d 64 65 76 69 63 65 3e nt <simh-device>
bab0: 20 3c 69 6d 61 67 65 2d 66 69 6c 65 3e 20 5b 6f <image-file> [o
bac0: 70 74 69 6f 6e 20 2e 2e 2e 5d 0a 20 20 23 0a 20 ption ...]. #.
bad0: 20 23 20 49 6e 74 65 72 66 61 63 65 20 74 6f 20 # Interface to
bae0: 53 49 4d 48 20 61 74 74 61 63 68 20 63 6f 6d 6d SIMH attach comm
baf0: 61 6e 64 20 77 69 74 68 20 6f 70 74 69 6f 6e 73 and with options
bb00: 20 74 68 61 74 20 64 6f 20 61 20 62 69 74 20 6d that do a bit m
bb10: 6f 72 65 2e 0a 20 20 23 0a 20 20 23 20 4f 70 74 ore.. #. # Opt
bb20: 69 6f 6e 73 3a 0a 20 20 23 20 72 65 71 75 69 72 ions:. # requir
bb30: 65 64 3a 20 3c 69 6d 61 67 65 2d 66 69 6c 65 3e ed: <image-file>
bb40: 20 69 73 20 72 65 71 75 69 72 65 64 20 74 6f 20 is required to
bb50: 65 78 69 73 74 2c 20 6f 74 68 65 72 77 69 73 65 exist, otherwise
bb60: 20 61 62 6f 72 74 20 74 68 65 20 73 63 72 69 70 abort the scrip
bb70: 74 2e 0a 20 20 23 20 70 72 65 73 65 72 76 65 20 t.. # preserve
bb80: 69 66 20 3c 69 6d 61 67 65 2d 66 69 6c 65 3e 20 if <image-file>
bb90: 61 6c 72 65 61 64 79 20 65 78 69 73 74 73 2c 20 already exists,
bba0: 63 72 65 61 74 65 20 61 20 63 6f 70 79 20 77 69 create a copy wi
bbb0: 74 68 20 61 0a 20 20 23 20 20 20 20 76 65 72 73 th a. # vers
bbc0: 69 6f 6e 20 6e 75 6d 62 65 72 20 73 75 66 66 69 ion number suffi
bbd0: 78 2e 20 54 68 69 73 20 69 73 20 75 73 65 66 75 x. This is usefu
bbe0: 6c 20 77 68 65 6e 20 79 6f 75 20 77 61 6e 74 20 l when you want
bbf0: 74 6f 20 70 72 65 76 65 6e 74 0a 20 20 23 20 20 to prevent. #
bc00: 20 20 6f 76 65 72 77 72 69 74 65 73 20 6f 66 20 overwrites of
bc10: 61 20 67 6f 6f 64 20 69 6d 61 67 65 20 66 69 6c a good image fil
bc20: 65 20 77 69 74 68 20 63 68 61 6e 67 65 73 20 74 e with changes t
bc30: 68 61 74 20 6d 69 67 68 74 20 6e 6f 74 20 77 6f hat might not wo
bc40: 72 6b 2e 0a 20 20 23 20 20 20 20 6f 73 38 2d 72 rk.. # os8-r
bc50: 75 6e 20 70 72 65 73 65 72 76 65 73 20 61 6c 6c un preserves all
bc60: 20 76 65 72 73 69 6f 6e 73 20 73 65 65 6e 20 61 versions seen a
bc70: 6e 64 20 63 72 65 61 74 65 73 20 61 20 6e 65 77 nd creates a new
bc80: 0a 20 20 23 20 20 20 20 76 65 72 73 69 6f 6e 20 . # version
bc90: 74 68 61 74 20 64 6f 65 73 6e 27 74 20 6f 76 65 that doesn't ove
bca0: 72 77 72 69 74 65 20 61 6e 79 20 6f 66 20 74 68 rwrite any of th
bcb0: 65 20 70 72 65 76 69 6f 75 73 20 6f 6e 65 73 2e e previous ones.
bcc0: 0a 20 20 23 20 72 65 61 64 6f 6e 6c 79 3a 20 20 . # readonly:
bcd0: 50 61 73 73 65 73 20 74 68 65 20 60 2d 72 60 20 Passes the `-r`
bce0: 6f 70 74 69 6f 6e 20 74 6f 20 53 49 4d 48 20 61 option to SIMH a
bcf0: 74 74 61 63 68 20 74 6f 20 6d 6f 75 6e 74 20 74 ttach to mount t
bd00: 68 65 0a 20 20 23 20 20 20 20 64 65 76 69 63 65 he. # device
bd10: 20 69 6e 20 72 65 61 64 20 6f 6e 6c 79 20 6d 6f in read only mo
bd20: 64 65 2e 0a 20 20 23 20 72 6f 3a 20 61 62 62 72 de.. # ro: abbr
bd30: 65 76 69 61 74 69 6f 6e 20 66 6f 72 20 20 72 65 eviation for re
bd40: 61 64 6f 6e 6c 79 2e 0a 20 20 23 20 73 63 72 61 adonly.. # scra
bd50: 74 63 68 3a 20 43 72 65 61 74 65 20 61 20 77 72 tch: Create a wr
bd60: 69 74 65 61 62 6c 65 20 73 63 72 61 74 63 68 20 iteable scratch
bd70: 63 6f 70 79 20 6f 66 20 74 68 65 20 6e 61 6d 65 copy of the name
bd80: 64 20 69 6d 61 67 65 0a 20 20 23 20 20 20 20 66 d image. # f
bd90: 69 6c 65 20 61 6e 64 20 6d 6f 75 6e 74 20 69 74 ile and mount it
bda0: 2e 20 20 54 68 69 73 20 69 73 20 68 65 6c 70 66 . This is helpf
bdb0: 75 6c 20 77 68 65 6e 20 79 6f 75 20 61 72 65 20 ul when you are
bdc0: 62 6f 6f 74 69 6e 67 20 61 0a 20 20 23 20 20 20 booting a. #
bdd0: 20 64 69 73 74 72 69 62 75 74 69 6f 6e 20 44 45 distribution DE
bde0: 43 74 61 70 65 2e 20 20 42 6f 6f 74 65 64 20 44 Ctape. Booted D
bdf0: 45 43 74 61 70 65 20 69 6d 61 67 65 73 20 6d 75 ECtape images mu
be00: 73 74 20 62 65 20 77 72 69 74 65 61 62 6c 65 2e st be writeable.
be10: 0a 20 20 23 20 20 20 20 54 6f 20 70 72 6f 74 65 . # To prote
be20: 63 74 20 61 20 64 69 73 74 72 69 62 75 74 69 6f ct a distributio
be30: 6e 20 44 45 43 74 61 70 65 2c 20 75 73 65 20 74 n DECtape, use t
be40: 68 69 73 20 6f 70 74 69 6f 6e 2e 0a 20 20 23 20 his option.. #
be50: 20 20 20 57 68 65 6e 20 61 6c 6c 20 73 63 72 69 When all scri
be60: 70 74 20 72 75 6e 73 20 61 72 65 20 64 6f 6e 65 pt runs are done
be70: 2c 20 74 68 65 20 73 63 72 61 74 63 68 20 76 65 , the scratch ve
be80: 72 73 69 6f 6e 20 69 73 20 64 65 6c 65 74 65 64 rsion is deleted
be90: 2e 0a 20 20 23 20 6e 65 77 3a 20 49 66 20 74 68 .. # new: If th
bea0: 65 72 65 20 69 73 20 61 6e 20 65 78 69 73 74 69 ere is an existi
beb0: 6e 67 20 66 69 6c 65 2c 20 6d 6f 76 65 20 69 74 ng file, move it
bec0: 20 61 73 69 64 65 20 61 73 20 61 20 2e 73 61 76 aside as a .sav
bed0: 65 20 62 65 63 61 75 73 65 0a 20 20 23 20 20 20 e because. #
bee0: 20 77 65 20 77 61 6e 74 20 74 6f 20 63 72 65 61 we want to crea
bef0: 74 65 20 61 20 6e 65 77 20 65 6d 70 74 79 20 69 te a new empty i
bf00: 6d 61 67 65 20 66 69 6c 65 2e 0a 20 20 23 0a 20 mage file.. #.
bf10: 20 23 20 49 66 20 74 68 65 20 6d 6f 75 6e 74 20 # If the mount
bf20: 63 6f 6d 6d 61 6e 64 20 66 61 69 6c 73 20 66 6f command fails fo
bf30: 72 20 61 6e 79 20 72 65 61 73 6f 6e 2c 20 77 65 r any reason, we
bf40: 20 70 72 65 73 75 6d 65 0a 20 20 23 20 69 74 20 presume. # it
bf50: 69 73 20 61 20 66 61 74 61 6c 20 65 72 72 6f 72 is a fatal error
bf60: 20 61 6e 64 20 61 62 6f 72 74 20 74 68 65 20 73 and abort the s
bf70: 63 72 69 70 74 2e 0a 20 20 0a 20 20 64 65 66 20 cript.. . def
bf80: 6d 6f 75 6e 74 5f 63 6f 6d 6d 61 6e 64 20 28 73 mount_command (s
bf90: 65 6c 66 2c 20 6c 69 6e 65 2c 20 73 63 72 69 70 elf, line, scrip
bfa0: 74 5f 66 69 6c 65 29 3a 0a 20 20 20 20 6d 20 3d t_file):. m =
bfb0: 20 72 65 2e 6d 61 74 63 68 28 5f 6d 6f 75 6e 74 re.match(_mount
bfc0: 5f 72 65 2c 20 6c 69 6e 65 29 0a 20 20 20 20 69 _re, line). i
bfd0: 66 20 6d 20 3d 3d 20 4e 6f 6e 65 3a 0a 20 20 20 f m == None:.
bfe0: 20 20 20 70 72 69 6e 74 28 22 41 74 20 6c 69 6e print("At lin
bff0: 65 20 22 20 2b 20 73 74 72 28 73 65 6c 66 2e 6c e " + str(self.l
c000: 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 ine_ct_stack[0])
c010: 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 22 2c 20 + \. ",
c020: 63 6f 75 6c 64 20 6e 6f 74 20 70 61 72 73 65 20 could not parse
c030: 6d 6f 75 6e 74 2e 20 20 49 67 6e 6f 72 69 6e 67 mount. Ignoring
c040: 3a 20 7b 22 20 2b 20 6c 69 6e 65 20 2b 20 22 7d : {" + line + "}
c050: 2e 22 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e ."). return
c060: 20 22 64 69 65 22 0a 20 20 20 20 73 69 6d 68 5f "die". simh_
c070: 64 65 76 20 3d 20 6d 2e 67 72 6f 75 70 28 31 29 dev = m.group(1)
c080: 0a 20 20 20 20 75 6e 69 74 20 3d 20 6d 2e 67 72 . unit = m.gr
c090: 6f 75 70 28 32 29 0a 20 20 20 20 72 65 73 74 20 oup(2). rest
c0a0: 3d 20 6d 2e 67 72 6f 75 70 28 33 29 0a 20 20 20 = m.group(3).
c0b0: 20 70 61 72 74 73 20 3d 20 72 65 73 74 2e 73 70 parts = rest.sp
c0c0: 6c 69 74 28 29 0a 20 20 20 20 69 66 20 6c 65 6e lit(). if len
c0d0: 28 70 61 72 74 73 29 20 3d 3d 20 30 3a 0a 20 20 (parts) == 0:.
c0e0: 20 20 20 20 70 72 69 6e 74 28 22 41 74 20 6c 69 print("At li
c0f0: 6e 65 20 22 20 2b 20 73 74 72 28 73 65 6c 66 2e ne " + str(self.
c100: 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d line_ct_stack[0]
c110: 29 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 22 3a ) + \. ":
c120: 20 4e 6f 20 69 6d 61 67 65 20 6e 61 6d 65 20 73 No image name s
c130: 70 65 63 69 66 69 65 64 20 69 6e 3a 20 7b 22 20 pecified in: {"
c140: 2b 20 6c 69 6e 65 20 2b 20 22 7d 22 29 0a 20 20 + line + "}").
c150: 20 20 20 20 72 65 74 75 72 6e 20 22 64 69 65 22 return "die"
c160: 0a 20 20 20 20 72 6f 5f 61 72 67 20 3d 20 22 22 . ro_arg = ""
c170: 0a 20 20 20 20 69 6d 61 67 65 6e 61 6d 65 20 3d . imagename =
c180: 20 73 65 6c 66 2e 70 61 74 68 5f 65 78 70 61 6e self.path_expan
c190: 64 28 70 61 72 74 73 5b 30 5d 29 0a 20 20 20 20 d(parts[0]).
c1a0: 69 66 20 69 6d 61 67 65 6e 61 6d 65 20 3d 3d 20 if imagename ==
c1b0: 4e 6f 6e 65 3a 20 72 65 74 75 72 6e 20 22 64 69 None: return "di
c1c0: 65 22 0a 20 20 20 20 0a 20 20 20 20 64 6f 74 20 e". . dot
c1d0: 3d 20 69 6d 61 67 65 6e 61 6d 65 2e 72 69 6e 64 = imagename.rind
c1e0: 65 78 28 22 2e 22 29 0a 20 20 20 20 62 61 73 65 ex("."). base
c1f0: 5f 69 6d 61 67 65 6e 61 6d 65 20 3d 20 69 6d 61 _imagename = ima
c200: 67 65 6e 61 6d 65 5b 3a 64 6f 74 5d 0a 20 20 20 gename[:dot].
c210: 20 65 78 74 65 6e 73 69 6f 6e 20 3d 20 69 6d 61 extension = ima
c220: 67 65 6e 61 6d 65 5b 64 6f 74 3a 5d 0a 20 20 20 gename[dot:].
c230: 20 63 6f 70 79 5f 69 6d 61 67 65 6e 61 6d 65 20 copy_imagename
c240: 3d 20 22 22 0a 20 20 20 20 23 20 43 61 73 65 20 = "". # Case
c250: 6f 66 20 61 64 64 69 74 69 6f 6e 61 6c 20 61 72 of additional ar
c260: 67 75 6d 65 6e 74 73 2e 0a 20 20 20 20 69 66 20 guments.. if
c270: 6c 65 6e 20 28 70 61 72 74 73 29 20 3e 20 31 3a len (parts) > 1:
c280: 0a 20 20 20 20 20 20 23 20 50 65 72 66 6f 72 6d . # Perform
c290: 20 6d 75 73 74 5f 65 78 69 73 74 20 62 65 66 6f must_exist befo
c2a0: 72 65 20 73 63 72 61 74 63 68 0a 20 20 20 20 20 re scratch.
c2b0: 20 69 66 20 22 6e 65 77 22 20 69 6e 20 70 61 72 if "new" in par
c2c0: 74 73 5b 31 3a 5d 3a 0a 20 20 20 20 20 20 20 20 ts[1:]:.
c2d0: 73 61 76 65 5f 69 66 5f 6e 65 65 64 65 64 28 69 save_if_needed(i
c2e0: 6d 61 67 65 6e 61 6d 65 29 0a 20 20 20 20 20 20 magename).
c2f0: 69 66 20 22 6d 75 73 74 5f 65 78 69 73 74 22 20 if "must_exist"
c300: 69 6e 20 70 61 72 74 73 5b 31 3a 5d 20 6f 72 20 in parts[1:] or
c310: 22 72 65 71 75 69 72 65 64 22 20 69 6e 20 70 61 "required" in pa
c320: 72 74 73 5b 31 3a 5d 3a 0a 20 20 20 20 20 20 20 rts[1:]:.
c330: 20 20 20 69 66 20 6e 6f 74 20 6f 73 2e 70 61 74 if not os.pat
c340: 68 2e 65 78 69 73 74 73 28 69 6d 61 67 65 6e 61 h.exists(imagena
c350: 6d 65 29 3a 0a 20 20 20 20 20 20 20 20 20 20 20 me):.
c360: 20 70 72 69 6e 74 28 22 41 74 20 6c 69 6e 65 20 print("At line
c370: 22 20 2b 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e " + str(self.lin
c380: 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b e_ct_stack[0]) +
c390: 20 22 2c 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 ", " + \.
c3a0: 20 20 20 20 20 20 20 20 20 20 69 6d 61 67 65 6e imagen
c3b0: 61 6d 65 20 2b 20 22 20 6d 75 73 74 20 65 78 69 ame + " must exi
c3c0: 73 74 20 62 75 74 20 77 61 73 20 6e 6f 74 20 66 st but was not f
c3d0: 6f 75 6e 64 2e 20 4e 6f 74 20 6d 6f 75 6e 74 69 ound. Not mounti
c3e0: 6e 67 2e 22 29 0a 20 20 20 20 20 20 20 20 20 20 ng.").
c3f0: 20 20 72 65 74 75 72 6e 20 22 64 69 65 22 0a 20 return "die".
c400: 20 20 20 20 20 69 66 20 22 73 63 72 61 74 63 68 if "scratch
c410: 22 20 69 6e 20 70 61 72 74 73 5b 31 3a 5d 3a 0a " in parts[1:]:.
c420: 20 20 20 20 20 20 20 20 63 6f 70 79 5f 69 6d 61 copy_ima
c430: 67 65 6e 61 6d 65 20 3d 20 73 65 6c 66 2e 6d 61 gename = self.ma
c440: 6b 65 5f 73 63 72 61 74 63 68 28 62 61 73 65 5f ke_scratch(base_
c450: 69 6d 61 67 65 6e 61 6d 65 2c 20 65 78 74 65 6e imagename, exten
c460: 73 69 6f 6e 29 0a 20 20 20 20 20 20 20 20 69 66 sion). if
c470: 20 63 6f 70 79 5f 69 6d 61 67 65 6e 61 6d 65 20 copy_imagename
c480: 3d 3d 20 4e 6f 6e 65 3a 20 72 65 74 75 72 6e 20 == None: return
c490: 22 64 69 65 22 0a 20 20 20 20 20 20 20 20 69 6d "die". im
c4a0: 61 67 65 6e 61 6d 65 20 3d 20 63 6f 70 79 5f 69 agename = copy_i
c4b0: 6d 61 67 65 6e 61 6d 65 0a 20 20 20 20 20 20 20 magename.
c4c0: 20 0a 20 20 20 20 20 20 69 66 20 22 72 65 61 64 . if "read
c4d0: 6f 6e 6c 79 22 20 69 6e 20 70 61 72 74 73 5b 31 only" in parts[1
c4e0: 3a 5d 20 6f 72 20 22 72 6f 22 20 69 6e 20 70 61 :] or "ro" in pa
c4f0: 72 74 73 5b 31 3a 5d 3a 0a 20 20 20 20 20 20 20 rts[1:]:.
c500: 20 69 66 20 63 6f 70 79 5f 69 6d 61 67 65 6e 61 if copy_imagena
c510: 6d 65 20 21 3d 20 22 22 3a 0a 20 20 20 20 20 20 me != "":.
c520: 20 20 20 20 70 72 69 6e 74 28 22 41 74 20 6c 69 print("At li
c530: 6e 65 20 22 20 2b 20 73 74 72 28 73 65 6c 66 2e ne " + str(self.
c540: 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d line_ct_stack[0]
c550: 29 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 ) + \.
c560: 20 20 22 3a 20 59 6f 75 20 64 6f 6e 27 74 20 72 ": You don't r
c570: 65 61 6c 6c 79 20 6e 65 65 64 20 74 6f 20 73 65 eally need to se
c580: 74 20 72 65 61 64 6f 6e 6c 79 20 6f 6e 20 61 20 t readonly on a
c590: 73 63 72 61 74 63 68 20 63 6f 70 79 2e 22 29 0a scratch copy.").
c5a0: 20 20 20 20 20 20 20 20 72 6f 5f 61 72 67 20 3d ro_arg =
c5b0: 20 22 2d 72 20 22 0a 20 20 20 20 20 20 69 66 20 "-r ". if
c5c0: 22 6e 6f 5f 6f 76 65 72 77 72 69 74 65 22 20 69 "no_overwrite" i
c5d0: 6e 20 70 61 72 74 73 5b 31 3a 5d 20 6f 72 20 22 n parts[1:] or "
c5e0: 70 72 65 73 65 72 76 65 22 20 69 6e 20 70 61 72 preserve" in par
c5f0: 74 73 5b 31 3a 5d 3a 0a 20 20 20 20 20 20 20 20 ts[1:]:.
c600: 69 66 20 63 6f 70 79 5f 69 6d 61 67 65 6e 61 6d if copy_imagenam
c610: 65 20 21 3d 20 22 22 3a 0a 20 20 20 20 20 20 20 e != "":.
c620: 20 20 20 70 72 69 6e 74 28 22 49 67 6e 6f 72 69 print("Ignori
c630: 6e 67 20 70 72 65 73 65 72 76 65 20 6f 70 74 69 ng preserve opti
c640: 6f 6e 20 61 74 20 6c 69 6e 65 20 22 20 2b 20 5c on at line " + \
c650: 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 . s
c660: 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f tr(self.line_ct_
c670: 73 74 61 63 6b 5b 30 5d 29 20 2b 20 5c 0a 20 20 stack[0]) + \.
c680: 20 20 20 20 20 20 20 20 20 20 20 20 22 20 62 65 " be
c690: 63 61 75 73 65 20 73 63 72 61 74 63 68 20 6f 70 cause scratch op
c6a0: 74 69 6f 6e 20 69 73 20 70 72 65 73 65 6e 74 2e tion is present.
c6b0: 22 29 0a 20 20 20 20 20 20 20 20 65 6c 73 65 3a "). else:
c6c0: 0a 20 20 20 20 20 20 20 20 20 20 6e 65 78 74 5f . next_
c6d0: 74 61 70 65 20 3d 20 30 0a 20 20 20 20 20 20 20 tape = 0.
c6e0: 20 20 20 77 68 69 6c 65 20 6f 73 2e 70 61 74 68 while os.path
c6f0: 2e 69 73 66 69 6c 65 28 69 6d 61 67 65 6e 61 6d .isfile(imagenam
c700: 65 29 3a 0a 20 20 20 20 20 20 20 20 20 20 20 20 e):.
c710: 70 72 69 6e 74 28 22 46 6f 75 6e 64 3a 20 22 20 print("Found: "
c720: 2b 20 69 6d 61 67 65 6e 61 6d 65 29 0a 20 20 20 + imagename).
c730: 20 20 20 20 20 20 20 20 20 6e 65 78 74 5f 74 61 next_ta
c740: 70 65 20 2b 3d 20 31 0a 20 20 20 20 20 20 20 20 pe += 1.
c750: 20 20 20 20 69 6d 61 67 65 6e 61 6d 65 20 3d 20 imagename =
c760: 20 62 61 73 65 5f 69 6d 61 67 65 6e 61 6d 65 20 base_imagename
c770: 2b 20 22 2d 22 20 2b 20 73 74 72 28 6e 65 78 74 + "-" + str(next
c780: 5f 74 61 70 65 29 20 2b 20 65 78 74 65 6e 73 69 _tape) + extensi
c790: 6f 6e 0a 20 20 20 20 69 66 20 75 6e 69 74 20 3d on. if unit =
c7a0: 3d 20 4e 6f 6e 65 20 6f 72 20 75 6e 69 74 20 3d = None or unit =
c7b0: 3d 20 22 22 3a 0a 20 20 20 20 20 20 70 72 69 6e = "":. prin
c7c0: 74 28 22 4e 65 65 64 20 75 6e 69 74 20 6e 75 6d t("Need unit num
c7d0: 62 65 72 20 66 6f 72 3a 20 22 20 2b 20 6c 69 6e ber for: " + lin
c7e0: 65 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 e). return
c7f0: 22 64 69 65 22 0a 20 20 0a 20 20 20 20 69 66 20 "die". . if
c800: 73 69 6d 68 5f 64 65 76 20 6e 6f 74 20 69 6e 20 simh_dev not in
c810: 5f 6f 73 38 5f 66 72 6f 6d 5f 73 69 6d 68 5f 64 _os8_from_simh_d
c820: 65 76 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 ev:. print(
c830: 22 41 74 20 6c 69 6e 65 20 22 20 2b 20 73 74 72 "At line " + str
c840: 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 (self.line_ct_st
c850: 61 63 6b 5b 30 5d 29 20 2b 20 5c 0a 20 20 20 20 ack[0]) + \.
c860: 20 20 20 20 20 20 22 3a 20 55 6e 72 65 63 6f 67 ": Unrecog
c870: 6e 69 7a 65 64 20 73 69 6d 68 20 64 65 76 3a 20 nized simh dev:
c880: 22 20 2b 20 73 69 6d 68 5f 64 65 76 29 0a 20 20 " + simh_dev).
c890: 20 20 20 20 72 65 74 75 72 6e 20 22 64 69 65 22 return "die"
c8a0: 0a 20 20 20 20 6f 73 38 64 65 76 20 3d 20 5f 6f . os8dev = _o
c8b0: 73 38 5f 66 72 6f 6d 5f 73 69 6d 68 5f 64 65 76 s8_from_simh_dev
c8c0: 5b 73 69 6d 68 5f 64 65 76 5d 0a 20 20 0a 20 20 [simh_dev]. .
c8d0: 20 20 61 74 74 61 63 68 5f 63 6f 6d 6d 20 3d 20 attach_comm =
c8e0: 22 61 74 74 20 22 20 2b 20 72 6f 5f 61 72 67 20 "att " + ro_arg
c8f0: 2b 20 73 69 6d 68 5f 64 65 76 20 2b 20 75 6e 69 + simh_dev + uni
c900: 74 20 2b 20 22 20 22 20 2b 20 69 6d 61 67 65 6e t + " " + imagen
c910: 61 6d 65 0a 20 20 0a 20 20 20 20 69 66 20 73 65 ame. . if se
c920: 6c 66 2e 76 65 72 62 6f 73 65 3a 0a 20 20 20 20 lf.verbose:.
c930: 20 20 70 72 69 6e 74 28 22 4c 69 6e 65 20 22 20 print("Line "
c940: 2b 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f + str(self.line_
c950: 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 ct_stack[0]) + "
c960: 3a 20 6d 6f 75 6e 74 3a 20 22 20 2b 20 5c 0a 20 : mount: " + \.
c970: 20 20 20 20 20 20 20 20 20 61 74 74 61 63 68 5f attach_
c980: 63 6f 6d 6d 29 0a 20 20 20 20 72 65 70 6c 79 20 comm). reply
c990: 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 73 69 6d 68 = self.simh.simh
c9a0: 5f 63 6d 64 28 61 74 74 61 63 68 5f 63 6f 6d 6d _cmd(attach_comm
c9b0: 29 0a 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 2e ). self.simh.
c9c0: 73 69 6d 68 5f 74 65 73 74 5f 72 65 73 75 6c 74 simh_test_result
c9d0: 28 72 65 70 6c 79 2c 20 22 50 72 6f 6d 70 74 22 (reply, "Prompt"
c9e0: 2c 20 22 6d 6f 75 6e 74 5f 63 6f 6d 6d 61 6e 64 , "mount_command
c9f0: 22 29 0a 20 20 20 20 72 65 74 75 72 6e 20 22 73 "). return "s
ca00: 75 63 63 65 73 73 22 0a 0a 0a 20 20 23 23 23 23 uccess"... ####
ca10: 20 62 6f 6f 74 5f 63 6f 6d 6d 61 6e 64 20 23 23 boot_command ##
ca20: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
ca30: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
ca40: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
ca50: 23 23 0a 20 20 23 0a 20 20 23 20 43 68 65 63 6b ##. #. # Check
ca60: 20 74 6f 20 73 65 65 20 69 66 20 74 68 65 20 64 to see if the d
ca70: 65 76 69 63 65 20 74 6f 20 62 65 20 62 6f 6f 74 evice to be boot
ca80: 65 64 20 68 61 73 20 73 6f 6d 65 74 68 69 6e 67 ed has something
ca90: 20 61 74 74 61 63 68 65 64 2e 0a 20 20 23 20 49 attached.. # I
caa0: 66 20 6e 6f 74 20 64 69 65 2e 0a 20 20 23 20 49 f not die.. # I
cab0: 66 20 73 6f 2c 20 62 6f 6f 74 20 69 74 2c 20 61 f so, boot it, a
cac0: 6e 64 20 73 65 74 20 6f 75 72 20 62 6f 6f 74 65 nd set our boote
cad0: 64 20 73 74 61 74 65 20 74 6f 20 54 72 75 65 2e d state to True.
cae0: 0a 20 20 0a 20 20 64 65 66 20 62 6f 6f 74 5f 63 . . def boot_c
caf0: 6f 6d 6d 61 6e 64 20 28 73 65 6c 66 2c 20 6c 69 ommand (self, li
cb00: 6e 65 2c 20 73 63 72 69 70 74 5f 66 69 6c 65 29 ne, script_file)
cb10: 3a 0a 20 20 20 20 23 20 46 69 72 73 74 20 63 6f :. # First co
cb20: 6e 66 69 72 6d 20 73 6f 6d 65 74 68 69 6e 67 20 nfirm something
cb30: 69 73 20 61 74 74 61 63 68 65 64 20 74 6f 20 62 is attached to b
cb40: 6f 6f 74 20 66 72 6f 6d 2e 0a 20 20 20 20 75 63 oot from.. uc
cb50: 6e 61 6d 65 20 3d 20 6c 69 6e 65 2e 75 70 70 65 name = line.uppe
cb60: 72 28 29 0a 20 20 20 20 62 6f 6f 74 5f 72 65 70 r(). boot_rep
cb70: 6c 69 65 73 20 3d 20 5b 75 63 6e 61 6d 65 20 2b lies = [ucname +
cb80: 20 22 5c 73 2b 28 2e 2b 29 5c 72 22 2c 20 22 4e "\s+(.+)\r", "N
cb90: 6f 6e 2d 65 78 69 73 74 65 6e 74 20 64 65 76 69 on-existent devi
cba0: 63 65 22 5d 0a 20 20 20 20 73 65 6c 66 2e 73 69 ce"]. self.si
cbb0: 6d 68 2e 73 69 6d 68 5f 73 65 6e 64 5f 6c 69 6e mh.simh_send_lin
cbc0: 65 28 22 73 68 6f 77 20 22 20 2b 20 6c 69 6e 65 e("show " + line
cbd0: 29 0a 20 20 20 20 72 65 74 76 61 6c 20 3d 20 73 ). retval = s
cbe0: 65 6c 66 2e 73 69 6d 68 2e 5f 63 68 69 6c 64 2e elf.simh._child.
cbf0: 65 78 70 65 63 74 28 62 6f 6f 74 5f 72 65 70 6c expect(boot_repl
cc00: 69 65 73 29 0a 20 20 20 20 69 66 20 72 65 74 76 ies). if retv
cc10: 61 6c 20 3d 3d 20 31 3a 0a 20 20 20 20 20 20 70 al == 1:. p
cc20: 72 69 6e 74 28 22 41 74 74 65 6d 70 74 20 74 6f rint("Attempt to
cc30: 20 62 6f 6f 74 20 6e 6f 6e 2d 65 78 69 73 74 65 boot non-existe
cc40: 6e 74 20 64 65 76 69 63 65 3a 20 22 20 2b 20 6c nt device: " + l
cc50: 69 6e 65 29 0a 20 20 20 20 20 20 72 65 74 75 72 ine). retur
cc60: 6e 20 22 64 69 65 22 0a 20 20 20 20 72 65 70 6c n "die". repl
cc70: 79 5f 73 74 72 20 3d 20 73 65 6c 66 2e 73 69 6d y_str = self.sim
cc80: 68 2e 63 68 69 6c 64 5f 61 66 74 65 72 28 29 0a h.child_after().
cc90: 20 20 20 20 6d 20 3d 20 72 65 2e 6d 61 74 63 68 m = re.match
cca0: 28 22 5e 28 5c 53 2b 29 5c 73 2b 28 5c 53 2b 29 ("^(\S+)\s+(\S+)
ccb0: 2c 5c 73 2b 28 61 74 74 61 63 68 65 64 20 74 6f ,\s+(attached to
ccc0: 20 7c 6e 6f 74 20 61 74 74 61 63 68 65 64 29 28 |not attached)(
ccd0: 5c 53 2b 29 3f 2c 5c 73 2b 28 2e 2b 29 5c 72 22 \S+)?,\s+(.+)\r"
cce0: 2c 0a 20 20 20 20 20 20 20 20 72 65 70 6c 79 5f ,. reply_
ccf0: 73 74 72 29 0a 20 20 20 20 69 66 20 6d 20 3d 3d str). if m ==
cd00: 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 70 72 69 None:. pri
cd10: 6e 74 28 22 43 6f 75 6c 64 20 6e 6f 74 20 64 65 nt("Could not de
cd20: 74 65 72 6d 69 6e 65 20 69 66 20 64 65 76 69 63 termine if devic
cd30: 65 20 22 20 2b 20 6c 69 6e 65 20 2b 20 22 20 69 e " + line + " i
cd40: 73 20 61 74 74 61 63 68 65 64 3b 20 22 20 2b 0a s attached; " +.
cd50: 20 20 20 20 20 20 20 20 20 20 22 67 6f 74 20 27 "got '
cd60: 22 20 2b 20 72 65 70 6c 79 5f 73 74 72 20 2b 20 " + reply_str +
cd70: 22 27 22 29 0a 20 20 20 20 20 20 72 65 74 75 72 "'"). retur
cd80: 6e 20 22 64 69 65 22 0a 0a 20 20 20 20 23 20 43 n "die".. # C
cd90: 61 75 74 69 6f 6e 20 6d 61 74 63 68 20 67 72 6f aution match gro
cda0: 75 70 20 77 65 20 77 61 6e 74 20 65 6e 64 73 20 up we want ends
cdb0: 77 69 74 68 20 61 20 73 70 61 63 65 2e 0a 20 20 with a space..
cdc0: 20 20 69 66 20 6d 2e 67 72 6f 75 70 28 33 29 20 if m.group(3)
cdd0: 21 3d 20 22 61 74 74 61 63 68 65 64 20 74 6f 20 != "attached to
cde0: 22 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 ":. print("
cdf0: 41 74 74 65 6d 70 74 20 74 6f 20 62 6f 6f 74 20 Attempt to boot
ce00: 6f 6e 20 6e 6f 6e 2d 61 74 74 61 63 68 65 64 20 on non-attached
ce10: 64 65 76 69 63 65 3a 20 22 20 2b 20 6c 69 6e 65 device: " + line
ce20: 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 ). return "
ce30: 64 69 65 22 0a 20 20 20 20 0a 20 20 20 20 62 6f die". . bo
ce40: 6f 74 5f 63 6f 6d 6d 20 3d 20 22 62 6f 6f 74 20 ot_comm = "boot
ce50: 22 20 2b 20 6c 69 6e 65 0a 20 20 20 20 69 66 20 " + line. if
ce60: 73 65 6c 66 2e 76 65 72 62 6f 73 65 3a 0a 20 20 self.verbose:.
ce70: 20 20 20 20 70 72 69 6e 74 28 22 4c 69 6e 65 20 print("Line
ce80: 22 20 2b 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e " + str(self.lin
ce90: 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b e_ct_stack[0]) +
cea0: 20 22 3a 20 22 20 2b 20 62 6f 6f 74 5f 63 6f 6d ": " + boot_com
ceb0: 6d 29 0a 20 20 20 20 72 65 70 6c 79 20 3d 20 73 m). reply = s
cec0: 65 6c 66 2e 73 69 6d 68 2e 73 69 6d 68 5f 63 6d elf.simh.simh_cm
ced0: 64 28 62 6f 6f 74 5f 63 6f 6d 6d 2c 20 73 65 6c d(boot_comm, sel
cee0: 66 2e 73 69 6d 68 2e 5f 6f 73 38 5f 72 65 70 6c f.simh._os8_repl
cef0: 69 65 73 5f 72 65 78 29 0a 20 20 20 20 23 20 57 ies_rex). # W
cf00: 65 27 72 65 20 69 6e 20 4f 53 2f 38 20 6e 6f 77 e're in OS/8 now
cf10: 20 75 73 65 20 74 68 61 74 20 74 65 73 74 65 72 use that tester
cf20: 2e 0a 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 2e .. self.simh.
cf30: 6f 73 38 5f 74 65 73 74 5f 72 65 73 75 6c 74 20 os8_test_result
cf40: 28 72 65 70 6c 79 2c 20 22 4d 6f 6e 69 74 6f 72 (reply, "Monitor
cf50: 20 50 72 6f 6d 70 74 22 2c 20 22 62 6f 6f 74 5f Prompt", "boot_
cf60: 63 6f 6d 6d 61 6e 64 22 29 0a 20 20 20 20 73 65 command"). se
cf70: 6c 66 2e 62 6f 6f 74 65 64 20 3d 20 54 72 75 65 lf.booted = True
cf80: 0a 20 20 20 20 72 65 74 75 72 6e 20 22 73 75 63 . return "suc
cf90: 63 65 73 73 22 0a 0a 0a 20 20 23 23 23 23 20 63 cess"... #### c
cfa0: 68 65 63 6b 5f 61 6e 64 5f 72 75 6e 20 23 23 23 heck_and_run ###
cfb0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
cfc0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
cfd0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a ###############.
cfe0: 20 20 23 20 43 6f 6d 6d 6f 6e 20 72 6f 75 74 69 # Common routi
cff0: 6e 65 20 74 6f 20 63 68 65 63 6b 20 74 68 61 74 ne to check that
d000: 20 77 65 20 61 72 65 20 62 6f 6f 74 61 62 6c 65 we are bootable
d010: 2c 20 69 6e 20 74 68 65 20 72 69 67 68 74 20 63 , in the right c
d020: 6f 6e 74 65 78 74 0a 20 20 23 20 61 72 65 20 61 ontext. # are a
d030: 62 6c 65 20 74 6f 20 72 75 6e 20 61 20 63 6f 6d ble to run a com
d040: 6d 61 6e 64 20 75 6e 64 65 72 20 4f 53 2f 38 2c mand under OS/8,
d050: 20 61 6e 64 20 74 68 61 74 20 77 65 20 73 75 63 and that we suc
d060: 63 65 73 73 66 75 6c 6c 79 20 72 75 6e 20 69 74 cessfully run it
d070: 2e 0a 20 20 23 20 63 61 6c 6c 65 72 20 69 73 20 .. # caller is
d080: 74 68 65 20 6e 61 6d 65 20 77 65 20 67 69 76 65 the name we give
d090: 20 6f 75 74 20 61 73 20 6f 75 72 20 63 61 6c 6c out as our call
d0a0: 65 72 2e 0a 20 20 23 20 52 65 74 75 72 6e 20 2d er.. # Return -
d0b0: 31 20 69 66 20 77 65 20 61 72 65 20 6e 6f 74 20 1 if we are not
d0c0: 62 6f 6f 74 65 64 20 61 6e 64 20 74 68 65 20 63 booted and the c
d0d0: 6f 6d 6d 61 6e 64 20 6e 65 65 64 73 20 74 6f 20 ommand needs to
d0e0: 64 69 65 2e 0a 20 20 23 20 6f 74 68 65 72 77 69 die.. # otherwi
d0f0: 73 65 20 72 65 74 75 72 6e 20 74 68 65 20 72 65 se return the re
d100: 70 6c 79 20 74 6f 20 74 68 65 20 63 6f 6d 6d 61 ply to the comma
d110: 6e 64 2e 0a 20 20 23 20 57 65 20 67 65 6e 65 72 nd.. # We gener
d120: 69 63 61 6c 6c 79 20 73 75 70 70 6f 72 74 20 72 ically support r
d130: 65 70 6f 72 74 69 6e 67 20 6f 75 74 20 69 66 20 eporting out if
d140: 74 72 61 6e 73 63 72 69 70 74 20 69 73 20 65 6e transcript is en
d150: 61 62 6c 65 64 2e 0a 0a 20 20 64 65 66 20 63 68 abled... def ch
d160: 65 63 6b 5f 61 6e 64 5f 72 75 6e 20 28 73 65 6c eck_and_run (sel
d170: 66 2c 20 63 61 6c 6c 65 72 2c 20 6f 73 38 5f 63 f, caller, os8_c
d180: 6f 6d 6d 2c 20 73 63 72 69 70 74 5f 66 69 6c 65 omm, script_file
d190: 2c 20 72 65 70 6c 69 65 73 3d 4e 6f 6e 65 29 3a , replies=None):
d1a0: 0a 20 20 20 20 69 66 20 6e 6f 74 20 73 65 6c 66 . if not self
d1b0: 2e 62 6f 6f 74 65 64 3a 0a 20 20 20 20 20 20 70 .booted:. p
d1c0: 72 69 6e 74 28 22 43 61 6e 6e 6f 74 20 72 75 6e rint("Cannot run
d1d0: 20 22 20 2b 20 63 61 6c 6c 65 72 20 20 2b 20 22 " + caller + "
d1e0: 20 63 6f 6d 6d 61 6e 64 20 61 74 20 6c 69 6e 65 command at line
d1f0: 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 73 " + \. s
d200: 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f tr(self.line_ct_
d210: 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 2e 20 4f stack[0]) + ". O
d220: 53 2f 38 20 68 61 73 20 6e 6f 74 20 62 65 65 6e S/8 has not been
d230: 20 62 6f 6f 74 65 64 2e 22 29 0a 20 20 20 20 20 booted.").
d240: 20 72 65 74 75 72 6e 20 2d 31 0a 0a 20 20 20 20 return -1..
d250: 69 66 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 3a if self.verbose:
d260: 20 70 72 69 6e 74 28 22 4c 69 6e 65 3a 20 22 20 print("Line: "
d270: 2b 20 5c 0a 20 20 20 20 20 20 20 73 74 72 28 73 + \. str(s
d280: 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 elf.line_ct_stac
d290: 6b 5b 30 5d 29 20 2b 20 22 3a 20 22 20 2b 20 63 k[0]) + ": " + c
d2a0: 61 6c 6c 65 72 20 2b 20 22 5f 63 6f 6d 6d 61 6e aller + "_comman
d2b0: 64 3a 20 22 20 2b 20 6f 73 38 5f 63 6f 6d 6d 29 d: " + os8_comm)
d2c0: 0a 0a 20 20 20 20 23 20 41 6e 79 20 6f 73 38 2d .. # Any os8-
d2d0: 72 75 6e 20 63 6f 6d 6d 61 6e 64 20 6d 61 79 20 run command may
d2e0: 62 65 20 63 61 6c 6c 65 64 20 61 66 74 65 72 20 be called after
d2f0: 61 20 73 69 6d 68 20 63 6f 6d 6d 61 6e 64 20 74 a simh command t
d300: 68 61 74 20 6c 65 66 74 20 75 73 0a 20 20 20 20 hat left us.
d310: 23 20 69 6e 20 73 69 6d 68 20 63 6f 6e 74 65 78 # in simh contex
d320: 74 2e 20 43 68 65 63 6b 20 74 6f 20 73 65 65 20 t. Check to see
d330: 69 66 20 77 65 20 6e 65 65 64 20 74 6f 20 72 65 if we need to re
d340: 73 74 61 72 74 20 4f 53 2f 38 2e 0a 20 20 20 20 start OS/8..
d350: 23 20 57 65 20 63 6f 75 6c 64 20 72 65 73 75 6d # We could resum
d360: 65 2c 20 62 75 74 20 72 65 73 74 61 72 74 20 69 e, but restart i
d370: 73 20 73 61 66 65 72 2e 0a 20 20 20 20 69 66 20 s safer.. if
d380: 73 65 6c 66 2e 73 69 6d 68 2e 5f 63 6f 6e 74 65 self.simh._conte
d390: 78 74 20 3d 3d 20 22 73 69 6d 68 22 3a 0a 20 20 xt == "simh":.
d3a0: 20 20 20 20 73 65 6c 66 2e 72 65 73 74 61 72 74 self.restart
d3b0: 5f 63 6f 6d 6d 61 6e 64 28 6f 73 38 5f 63 6f 6d _command(os8_com
d3c0: 6d 2c 20 73 63 72 69 70 74 5f 66 69 6c 65 29 0a m, script_file).
d3d0: 0a 20 20 20 20 72 65 70 6c 79 20 3d 20 73 65 6c . reply = sel
d3e0: 66 2e 73 69 6d 68 2e 6f 73 38 5f 63 6d 64 20 28 f.simh.os8_cmd (
d3f0: 6f 73 38 5f 63 6f 6d 6d 2c 20 72 65 70 6c 69 65 os8_comm, replie
d400: 73 2c 20 64 65 62 75 67 3d 73 65 6c 66 2e 64 65 s, debug=self.de
d410: 62 75 67 29 0a 20 20 20 20 69 66 20 22 74 72 61 bug). if "tra
d420: 6e 73 63 72 69 70 74 22 20 69 6e 20 73 65 6c 66 nscript" in self
d430: 2e 6f 70 74 69 6f 6e 73 5f 65 6e 61 62 6c 65 64 .options_enabled
d440: 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 20 28 73 :. print (s
d450: 65 6c 66 2e 73 69 6d 68 2e 5f 63 68 69 6c 64 2e elf.simh._child.
d460: 62 65 66 6f 72 65 2e 64 65 63 6f 64 65 28 29 2e before.decode().
d470: 73 74 72 69 70 28 29 29 0a 20 20 20 20 72 65 74 strip()). ret
d480: 75 72 6e 20 72 65 70 6c 79 0a 20 20 0a 20 20 0a urn reply. . .
d490: 20 20 23 23 23 23 20 6f 73 38 5f 63 6f 6d 6d 61 #### os8_comma
d4a0: 6e 64 20 23 23 23 23 23 23 23 23 23 23 23 23 23 nd #############
d4b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
d4c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
d4d0: 23 23 23 23 23 23 23 23 0a 20 20 0a 20 20 64 65 ########. . de
d4e0: 66 20 6f 73 38 5f 63 6f 6d 6d 61 6e 64 20 28 73 f os8_command (s
d4f0: 65 6c 66 2c 20 6c 69 6e 65 2c 20 73 63 72 69 70 elf, line, scrip
d500: 74 5f 66 69 6c 65 29 3a 0a 20 20 20 20 72 65 70 t_file):. rep
d510: 6c 79 20 3d 20 73 65 6c 66 2e 63 68 65 63 6b 5f ly = self.check_
d520: 61 6e 64 5f 72 75 6e 28 22 6f 73 38 22 2c 20 6c and_run("os8", l
d530: 69 6e 65 2c 20 73 63 72 69 70 74 5f 66 69 6c 65 ine, script_file
d540: 29 0a 20 20 20 20 69 66 20 72 65 70 6c 79 20 3d ). if reply =
d550: 3d 20 2d 31 3a 20 72 65 74 75 72 6e 20 22 64 69 = -1: return "di
d560: 65 22 0a 0a 20 20 20 20 23 20 57 65 20 65 78 70 e".. # We exp
d570: 65 63 74 20 74 68 61 74 20 74 68 65 20 63 6f 6d ect that the com
d580: 6d 61 6e 64 20 77 69 6c 6c 20 65 78 69 74 20 74 mand will exit t
d590: 6f 20 74 68 65 20 4f 53 2f 38 20 6d 6f 6e 69 74 o the OS/8 monit
d5a0: 6f 72 20 77 68 65 6e 20 64 6f 6e 65 2e 0a 20 20 or when done..
d5b0: 20 20 23 20 57 68 61 74 20 69 66 20 69 74 20 64 # What if it d
d5c0: 6f 65 73 6e 27 74 3f 0a 20 20 20 20 23 20 57 65 oesn't?. # We
d5d0: 20 77 61 6e 74 20 74 6f 20 70 72 69 6e 74 20 65 want to print e
d5e0: 72 72 6f 72 73 0a 20 20 20 20 6d 6f 6e 20 3d 20 rrors. mon =
d5f0: 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 74 65 self.simh.os8_te
d600: 73 74 5f 72 65 73 75 6c 74 20 28 72 65 70 6c 79 st_result (reply
d610: 2c 20 22 4d 6f 6e 69 74 6f 72 20 50 72 6f 6d 70 , "Monitor Promp
d620: 74 22 2c 20 22 22 29 0a 20 20 20 20 69 66 20 6d t", ""). if m
d630: 6f 6e 3a 20 72 65 74 75 72 6e 20 22 73 75 63 63 on: return "succ
d640: 65 73 73 22 0a 20 20 20 20 63 64 20 20 3d 20 73 ess". cd = s
d650: 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 74 65 73 elf.simh.os8_tes
d660: 74 5f 72 65 73 75 6c 74 20 28 72 65 70 6c 79 2c t_result (reply,
d670: 20 22 43 6f 6d 6d 61 6e 64 20 44 65 63 6f 64 65 "Command Decode
d680: 72 20 50 72 6f 6d 70 74 22 2c 20 22 22 29 0a 20 r Prompt", "").
d690: 20 20 20 72 65 74 76 61 6c 20 3d 20 22 66 61 69 retval = "fai
d6a0: 6c 22 0a 20 20 20 20 69 66 20 63 64 3a 0a 20 20 l". if cd:.
d6b0: 20 20 20 20 23 20 4f 53 2f 38 20 63 6f 6d 6d 61 # OS/8 comma
d6c0: 6e 64 20 72 65 74 75 72 6e 65 64 20 74 6f 20 63 nd returned to c
d6d0: 6f 6d 6d 61 6e 64 20 64 65 63 6f 64 65 72 2e 20 ommand decoder.
d6e0: 20 57 65 20 65 73 63 61 70 65 2e 0a 20 20 20 20 We escape..
d6f0: 20 20 6d 6f 6e 20 3d 20 73 65 6c 66 2e 73 69 6d mon = self.sim
d700: 68 2e 6f 73 38 5f 65 73 63 61 70 65 20 28 22 22 h.os8_escape (""
d710: 29 0a 20 20 20 20 20 20 69 66 20 6d 6f 6e 20 3d ). if mon =
d720: 3d 20 66 61 6c 73 65 3a 0a 20 20 20 20 20 20 20 = false:.
d730: 20 70 72 69 6e 74 20 28 22 6f 73 38 5f 63 6f 6d print ("os8_com
d740: 6d 61 6e 64 3a 20 45 73 63 61 70 65 20 66 72 6f mand: Escape fro
d750: 6d 20 63 6f 6d 6d 61 6e 64 20 64 65 63 6f 64 65 m command decode
d760: 72 20 66 61 69 6c 65 64 2e 20 54 72 79 69 6e 67 r failed. Trying
d770: 20 5e 43 2e 22 29 0a 20 20 20 20 20 20 20 20 6d ^C."). m
d780: 6f 6e 20 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 6f on = self.simh.o
d790: 73 38 5f 63 74 72 6c 5f 63 20 28 22 22 29 0a 20 s8_ctrl_c ("").
d7a0: 20 20 20 20 20 20 20 69 66 20 6d 6f 6e 20 3d 3d if mon ==
d7b0: 20 66 61 6c 73 65 3a 0a 20 20 20 20 20 20 20 20 false:.
d7c0: 20 20 70 72 69 6e 74 20 28 22 5e 43 20 66 61 69 print ("^C fai
d7d0: 6c 65 64 20 74 6f 20 72 65 74 75 72 6e 20 74 6f led to return to
d7e0: 20 6d 6f 6e 69 74 6f 72 2e 20 4b 69 6c 6c 69 6e monitor. Killin
d7f0: 67 20 73 63 72 69 70 74 2e 22 29 0a 20 20 20 20 g script.").
d800: 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 64 69 return "di
d810: 65 22 0a 20 20 20 20 70 72 69 6e 74 20 28 22 6f e". print ("o
d820: 73 38 5f 63 6f 6d 6d 61 6e 64 20 45 72 72 6f 72 s8_command Error
d830: 3a 20 5c 6e 5c 74 22 20 2b 20 6c 69 6e 65 29 0a : \n\t" + line).
d840: 20 20 20 20 70 72 69 6e 74 20 28 22 5c 74 22 20 print ("\t"
d850: 2b 20 73 65 6c 66 2e 73 69 6d 68 2e 63 68 69 6c + self.simh.chil
d860: 64 5f 61 66 74 65 72 28 29 2e 73 74 72 69 70 28 d_after().strip(
d870: 29 29 0a 20 20 20 20 23 20 49 66 20 74 68 69 73 )). # If this
d880: 20 77 61 73 20 6e 6f 74 20 61 20 66 61 74 61 6c was not a fatal
d890: 20 65 72 72 6f 72 2c 20 77 65 20 6e 65 65 64 20 error, we need
d8a0: 74 6f 20 5e 43 20 74 6f 20 67 65 74 20 62 61 63 to ^C to get bac
d8b0: 6b 20 74 6f 20 4d 6f 6e 69 74 6f 72 2e 0a 20 20 k to Monitor..
d8c0: 20 20 23 20 42 75 74 20 73 6f 6d 65 74 69 6d 65 # But sometime
d8d0: 73 20 4f 53 2f 38 20 69 73 20 6e 6f 74 20 79 65 s OS/8 is not ye
d8e0: 74 20 72 65 61 64 79 20 66 6f 72 20 5e 43 2c 20 t ready for ^C,
d8f0: 73 6f 20 77 65 20 77 61 69 74 20 68 61 6c 66 20 so we wait half
d900: 61 20 73 65 63 6f 6e 64 2e 0a 20 20 20 20 69 66 a second.. if
d910: 20 73 65 6c 66 2e 73 69 6d 68 2e 5f 6f 73 38 5f self.simh._os8_
d920: 72 65 70 6c 69 65 73 5b 72 65 70 6c 79 5d 5b 32 replies[reply][2
d930: 5d 20 3d 3d 20 46 61 6c 73 65 3a 0a 20 20 20 20 ] == False:.
d940: 20 20 74 69 6d 65 2e 73 6c 65 65 70 20 28 2e 35 time.sleep (.5
d950: 29 0a 20 20 20 20 20 20 70 72 69 6e 74 20 28 22 ). print ("
d960: 53 65 6e 64 69 6e 67 20 5e 43 20 74 6f 20 72 65 Sending ^C to re
d970: 74 75 72 6e 20 74 6f 20 6d 6f 6e 69 74 6f 72 2e turn to monitor.
d980: 22 29 0a 20 20 20 20 20 20 65 73 63 61 70 65 20 "). escape
d990: 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f = self.simh.os8_
d9a0: 63 74 72 6c 5f 63 20 28 22 22 2c 20 64 65 62 75 ctrl_c ("", debu
d9b0: 67 3d 73 65 6c 66 2e 64 65 62 75 67 29 0a 20 20 g=self.debug).
d9c0: 20 20 20 20 69 66 20 65 73 63 61 70 65 3a 20 72 if escape: r
d9d0: 65 74 75 72 6e 20 22 66 61 69 6c 22 0a 20 20 20 eturn "fail".
d9e0: 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 20 else:.
d9f0: 20 70 72 69 6e 74 20 28 22 5e 43 20 66 61 69 6c print ("^C fail
da00: 65 64 20 74 6f 20 72 65 74 75 72 6e 20 74 6f 20 ed to return to
da10: 6d 6f 6e 69 74 6f 72 2e 20 4b 69 6c 6c 69 6e 67 monitor. Killing
da20: 20 73 63 72 69 70 74 2e 22 29 0a 20 20 20 20 20 script.").
da30: 20 20 20 72 65 74 75 72 6e 20 22 64 69 65 22 0a return "die".
da40: 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 else:.
da50: 23 20 47 6f 74 20 66 61 74 61 6c 20 65 72 72 6f # Got fatal erro
da60: 72 2e 20 45 78 70 65 63 74 20 6d 6f 6e 69 74 6f r. Expect monito
da70: 72 20 70 72 6f 6d 70 74 20 73 6f 20 73 74 61 74 r prompt so stat
da80: 65 20 6d 61 63 68 69 6e 65 20 69 73 20 69 6e 20 e machine is in
da90: 74 68 65 20 72 69 67 68 74 20 70 6c 61 63 65 2e the right place.
daa0: 0a 20 20 20 20 20 20 6d 6f 6e 20 3d 20 73 65 6c . mon = sel
dab0: 66 2e 73 69 6d 68 2e 6f 73 38 5f 63 66 6d 5f 6d f.simh.os8_cfm_m
dac0: 6f 6e 69 74 6f 72 28 22 22 29 0a 20 20 20 20 20 onitor("").
dad0: 20 69 66 20 6d 6f 6e 3a 20 72 65 74 75 72 6e 20 if mon: return
dae0: 22 66 61 69 6c 22 0a 20 20 20 20 20 20 65 6c 73 "fail". els
daf0: 65 3a 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 e:. print
db00: 20 28 22 6f 73 38 5f 63 6f 6d 6d 61 6e 64 3a 20 ("os8_command:
db10: 46 61 69 6c 65 64 20 74 6f 20 72 65 74 75 72 6e Failed to return
db20: 20 74 6f 20 6d 6f 6e 69 74 6f 72 20 61 66 74 65 to monitor afte
db30: 72 20 66 61 74 61 6c 20 65 72 72 6f 72 2e 20 4b r fatal error. K
db40: 69 6c 6c 69 6e 20 73 63 72 69 70 74 2e 22 29 0a illin script.").
db50: 20 20 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 return "
db60: 64 69 65 22 0a 0a 0a 20 20 23 23 23 23 20 70 61 die"... #### pa
db70: 6c 38 5f 63 6f 6d 6d 61 6e 64 20 23 23 23 23 23 l8_command #####
db80: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
db90: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
dba0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a ###############.
dbb0: 20 20 23 20 54 68 65 20 22 70 61 6c 38 22 20 73 # The "pal8" s
dbc0: 63 72 69 70 74 20 63 6f 6d 6d 61 6e 64 20 63 6f cript command co
dbd0: 6d 65 73 20 69 6e 20 74 77 6f 20 66 6f 72 6d 73 mes in two forms
dbe0: 3a 0a 20 20 23 20 54 68 65 20 74 77 6f 20 61 72 :. # The two ar
dbf0: 67 75 6d 65 6e 74 20 66 6f 72 6d 20 77 68 65 72 gument form wher
dc00: 65 20 74 68 65 20 50 41 4c 38 20 73 74 61 74 75 e the PAL8 statu
dc10: 73 20 69 73 20 70 72 69 6e 74 65 64 20 6f 6e 20 s is printed on
dc20: 74 68 65 20 66 6c 79 0a 20 20 23 20 61 6e 64 20 the fly. # and
dc30: 74 68 65 20 33 20 61 72 67 75 6d 65 6e 74 20 66 the 3 argument f
dc40: 6f 72 6d 20 77 68 65 72 65 20 61 6c 6c 20 73 74 orm where all st
dc50: 61 74 75 73 20 67 6f 65 73 20 69 6e 74 6f 20 74 atus goes into t
dc60: 68 65 20 6c 69 73 74 69 6e 67 20 66 69 6c 65 2e he listing file.
dc70: 0a 20 20 23 20 57 65 20 64 6f 20 74 68 65 20 33 . # We do the 3
dc80: 20 61 72 67 75 6d 65 6e 74 20 66 6f 72 6d 20 77 argument form w
dc90: 69 74 68 20 61 20 73 69 6d 70 6c 65 20 22 6f 73 ith a simple "os
dca0: 38 22 20 73 63 72 69 70 74 20 63 6f 6d 6d 61 6e 8" script comman
dcb0: 64 2e 0a 20 20 0a 20 20 64 65 66 20 70 61 6c 38 d.. . def pal8
dcc0: 5f 63 6f 6d 6d 61 6e 64 20 28 73 65 6c 66 2c 20 _command (self,
dcd0: 6c 69 6e 65 2c 20 73 63 72 69 70 74 5f 66 69 6c line, script_fil
dce0: 65 29 3a 0a 20 20 20 20 69 66 20 73 65 6c 66 2e e):. if self.
dcf0: 76 65 72 62 6f 73 65 3a 20 70 72 69 6e 74 28 22 verbose: print("
dd00: 52 75 6e 6e 69 6e 67 20 50 41 4c 38 20 6f 6e 3a Running PAL8 on:
dd10: 20 22 20 2b 20 6c 69 6e 65 29 0a 20 20 20 20 72 " + line). r
dd20: 65 70 6c 79 20 3d 20 73 65 6c 66 2e 63 68 65 63 eply = self.chec
dd30: 6b 5f 61 6e 64 5f 72 75 6e 28 22 70 61 6c 38 22 k_and_run("pal8"
dd40: 2c 20 22 52 20 50 41 4c 38 22 2c 20 73 63 72 69 , "R PAL8", scri
dd50: 70 74 5f 66 69 6c 65 29 0a 20 20 20 20 69 66 20 pt_file). if
dd60: 72 65 70 6c 79 20 3d 3d 20 2d 31 3a 20 72 65 74 reply == -1: ret
dd70: 75 72 6e 20 22 64 69 65 22 0a 0a 20 20 20 20 69 urn "die".. i
dd80: 66 20 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f f self.simh.os8_
dd90: 74 65 73 74 5f 72 65 73 75 6c 74 20 28 72 65 70 test_result (rep
dda0: 6c 79 2c 20 22 43 6f 6d 6d 61 6e 64 20 44 65 63 ly, "Command Dec
ddb0: 6f 64 65 72 20 50 72 6f 6d 70 74 22 2c 20 22 63 oder Prompt", "c
ddc0: 61 6c 6c 5f 70 61 6c 38 22 29 20 3d 3d 20 46 61 all_pal8") == Fa
ddd0: 6c 73 65 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 lse:. print
dde0: 28 22 50 41 4c 38 20 66 61 69 6c 65 64 20 74 6f ("PAL8 failed to
ddf0: 20 73 74 61 72 74 20 61 74 20 6c 69 6e 65 20 22 start at line "
de00: 20 2b 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 + str(self.line
de10: 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 29 0a 20 _ct_stack[0])).
de20: 20 20 20 20 20 72 65 74 75 72 6e 20 22 66 61 69 return "fai
de30: 6c 22 0a 0a 20 20 20 20 69 66 20 73 65 6c 66 2e l".. if self.
de40: 76 65 72 62 6f 73 65 3a 20 70 72 69 6e 74 28 22 verbose: print("
de50: 4c 69 6e 65 3a 20 22 20 2b 20 5c 0a 20 20 20 20 Line: " + \.
de60: 20 20 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 str(self.line
de70: 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 _ct_stack[0]) +
de80: 22 3a 20 70 61 6c 38 5f 63 6f 6d 6d 61 6e 64 3a ": pal8_command:
de90: 20 22 20 2b 20 6c 69 6e 65 29 0a 0a 20 20 20 20 " + line)..
dea0: 23 20 53 65 6e 64 20 6f 75 72 20 63 6f 6d 6d 61 # Send our comma
deb0: 6e 64 20 6c 69 6e 65 20 61 72 67 73 20 61 6e 64 nd line args and
dec0: 20 68 61 72 76 65 73 74 20 72 65 73 75 6c 74 73 harvest results
ded0: 2e 0a 20 20 20 20 72 65 70 6c 79 20 3d 20 73 65 .. reply = se
dee0: 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 63 6d 64 20 lf.simh.os8_cmd
def0: 28 6c 69 6e 65 2c 20 73 65 6c 66 2e 72 65 70 6c (line, self.repl
df00: 69 65 73 5f 72 65 78 5b 22 70 61 6c 38 22 5d 29 ies_rex["pal8"])
df10: 0a 0a 20 20 20 20 65 72 72 5f 63 6f 75 6e 74 20 .. err_count
df20: 3d 20 30 0a 20 20 20 20 65 78 65 63 75 74 65 64 = 0. executed
df30: 5f 6c 69 6e 65 20 3d 20 73 65 6c 66 2e 73 69 6d _line = self.sim
df40: 68 2e 5f 63 68 69 6c 64 2e 62 65 66 6f 72 65 2e h._child.before.
df50: 64 65 63 6f 64 65 28 29 2e 73 74 72 69 70 28 29 decode().strip()
df60: 0a 20 20 20 20 6d 6f 6e 20 3d 20 73 65 6c 66 2e . mon = self.
df70: 73 69 6d 68 2e 74 65 73 74 5f 72 65 73 75 6c 74 simh.test_result
df80: 28 72 65 70 6c 79 2c 20 22 4d 6f 6e 69 74 6f 72 (reply, "Monitor
df90: 20 50 72 6f 6d 70 74 22 2c 20 73 65 6c 66 2e 72 Prompt", self.r
dfa0: 65 70 6c 69 65 73 5b 22 70 61 6c 38 22 5d 2c 20 eplies["pal8"],
dfb0: 22 22 29 0a 20 20 20 20 65 72 72 5f 73 74 72 69 ""). err_stri
dfc0: 6e 67 20 3d 20 22 22 0a 20 20 20 20 72 65 74 5f ng = "". ret_
dfd0: 76 61 6c 20 3d 20 22 73 75 63 63 65 73 73 22 0a val = "success".
dfe0: 20 20 20 20 65 78 70 65 63 74 5f 6c 6f 6f 70 20 expect_loop
dff0: 3d 20 31 0a 0a 20 20 20 20 23 20 57 65 27 72 65 = 1.. # We're
e000: 20 67 6f 69 6e 67 20 74 6f 20 70 72 69 6e 74 20 going to print
e010: 61 6c 6c 20 74 68 65 20 65 72 72 6f 72 73 20 77 all the errors w
e020: 65 20 73 65 65 0a 20 20 20 20 23 20 61 6e 64 20 e see. # and
e030: 6b 65 65 70 20 6c 6f 6f 6b 69 6e 67 20 74 69 6c keep looking til
e040: 6c 20 77 65 20 67 65 74 20 65 69 74 68 65 72 20 l we get either
e050: 61 20 6d 6f 6e 69 74 6f 72 20 6f 72 20 63 6f 6d a monitor or com
e060: 6d 61 6e 64 20 64 65 63 6f 64 65 72 20 70 72 6f mand decoder pro
e070: 6d 70 74 2e 0a 20 20 20 20 77 68 69 6c 65 20 6e mpt.. while n
e080: 6f 74 20 6d 6f 6e 3a 0a 20 20 20 20 20 20 69 66 ot mon:. if
e090: 20 73 65 6c 66 2e 64 65 62 75 67 3a 20 70 72 69 self.debug: pri
e0a0: 6e 74 20 28 22 47 6f 74 20 72 65 70 6c 79 20 5b nt ("Got reply [
e0b0: 22 20 2b 20 73 74 72 28 65 78 70 65 63 74 5f 6c " + str(expect_l
e0c0: 6f 6f 70 29 20 2b 22 5d 20 22 20 2b 20 73 74 72 oop) +"] " + str
e0d0: 28 72 65 70 6c 79 29 20 2b 20 22 20 2d 3e 20 22 (reply) + " -> "
e0e0: 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 20 + \.
e0f0: 20 20 20 20 73 65 6c 66 2e 72 65 70 6c 69 65 73 self.replies
e100: 5b 22 70 61 6c 38 22 5d 20 5b 72 65 70 6c 79 5d ["pal8"] [reply]
e110: 5b 30 5d 29 0a 0a 20 20 20 20 20 20 65 64 20 20 [0]).. ed
e120: 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 74 65 73 74 = self.simh.test
e130: 5f 72 65 73 75 6c 74 28 72 65 70 6c 79 2c 20 22 _result(reply, "
e140: 45 52 52 4f 52 53 20 44 45 54 45 43 54 45 44 22 ERRORS DETECTED"
e150: 2c 20 73 65 6c 66 2e 72 65 70 6c 69 65 73 5b 22 , self.replies["
e160: 70 61 6c 38 22 5d 2c 20 22 22 29 0a 20 20 20 20 pal8"], "").
e170: 20 20 63 64 20 20 3d 20 73 65 6c 66 2e 73 69 6d cd = self.sim
e180: 68 2e 74 65 73 74 5f 72 65 73 75 6c 74 28 72 65 h.test_result(re
e190: 70 6c 79 2c 20 22 43 6f 6d 6d 61 6e 64 20 44 65 ply, "Command De
e1a0: 63 6f 64 65 72 20 50 72 6f 6d 70 74 22 2c 20 73 coder Prompt", s
e1b0: 65 6c 66 2e 72 65 70 6c 69 65 73 5b 22 70 61 6c elf.replies["pal
e1c0: 38 22 5d 2c 20 22 22 29 0a 20 20 20 20 20 20 6c 8"], ""). l
e1d0: 67 20 20 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 74 g = self.simh.t
e1e0: 65 73 74 5f 72 65 73 75 6c 74 28 72 65 70 6c 79 est_result(reply
e1f0: 2c 20 22 4c 49 4e 4b 53 20 47 45 4e 45 52 41 54 , "LINKS GENERAT
e200: 45 44 22 2c 20 73 65 6c 66 2e 72 65 70 6c 69 65 ED", self.replie
e210: 73 5b 22 70 61 6c 38 22 5d 2c 20 22 22 29 0a 20 s["pal8"], "").
e220: 0a 20 20 20 20 20 20 69 66 20 65 64 3a 20 20 20 . if ed:
e230: 23 20 47 6f 74 20 45 72 72 6f 72 73 20 44 65 74 # Got Errors Det
e240: 65 63 74 65 64 2e 20 43 6f 75 6e 74 20 74 68 65 ected. Count the
e250: 6d 2e 0a 20 20 20 20 20 20 20 20 73 65 6c 66 2e m.. self.
e260: 73 69 6d 68 2e 5f 63 68 69 6c 64 2e 65 78 70 65 simh._child.expe
e270: 63 74 28 22 5c 64 2b 22 29 0a 20 20 20 20 20 20 ct("\d+").
e280: 20 20 65 72 72 5f 63 6f 75 6e 74 20 3d 20 69 6e err_count = in
e290: 74 28 73 65 6c 66 2e 73 69 6d 68 2e 63 68 69 6c t(self.simh.chil
e2a0: 64 5f 61 66 74 65 72 28 29 2e 73 74 72 69 70 28 d_after().strip(
e2b0: 29 29 0a 20 20 20 20 20 20 65 6c 69 66 20 6c 67 )). elif lg
e2c0: 3a 20 0a 20 20 20 20 20 20 20 20 73 65 6c 66 2e : . self.
e2d0: 73 69 6d 68 2e 5f 63 68 69 6c 64 2e 65 78 70 65 simh._child.expe
e2e0: 63 74 28 22 5c 64 2b 22 29 0a 20 20 20 20 20 20 ct("\d+").
e2f0: 20 20 6c 69 6e 6b 5f 63 6f 75 6e 74 20 3d 20 69 link_count = i
e300: 6e 74 28 73 65 6c 66 2e 73 69 6d 68 2e 63 68 69 nt(self.simh.chi
e310: 6c 64 5f 61 66 74 65 72 28 29 2e 73 74 72 69 70 ld_after().strip
e320: 28 29 29 0a 20 20 20 20 20 20 65 6c 69 66 20 63 ()). elif c
e330: 64 3a 20 23 20 47 6f 74 20 43 6f 6d 6d 61 6e 64 d: # Got Command
e340: 20 44 65 63 6f 64 65 72 2e 20 45 78 69 74 20 77 Decoder. Exit w
e350: 69 74 68 20 66 61 69 6c 75 72 65 2e 0a 20 20 20 ith failure..
e360: 20 20 20 20 20 69 66 20 73 65 6c 66 2e 64 65 62 if self.deb
e370: 75 67 3a 20 70 72 69 6e 74 20 28 22 63 61 6c 6c ug: print ("call
e380: 5f 70 61 6c 38 3a 20 4e 6f 6e 2d 66 61 74 61 6c _pal8: Non-fatal
e390: 20 65 72 72 6f 72 3a 20 53 65 6e 64 69 6e 67 20 error: Sending
e3a0: 5e 43 22 29 0a 20 20 20 20 20 20 20 20 23 20 45 ^C"). # E
e3b0: 78 69 74 20 70 61 6c 38 2e 20 57 65 27 6c 6c 20 xit pal8. We'll
e3c0: 63 6f 6e 66 69 72 6d 20 77 65 20 67 6f 74 20 62 confirm we got b
e3d0: 61 63 6b 20 74 6f 20 4f 53 2f 38 20 6d 6f 6e 69 ack to OS/8 moni
e3e0: 74 6f 72 20 62 65 6c 6f 77 2e 0a 20 20 20 20 20 tor below..
e3f0: 20 20 20 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 self.simh.os8
e400: 5f 73 65 6e 64 5f 63 74 72 6c 20 28 27 63 27 29 _send_ctrl ('c')
e410: 20 20 20 20 20 20 0a 20 20 20 20 20 20 65 6c 73 . els
e420: 65 3a 0a 20 20 20 20 20 20 20 20 65 72 72 5f 73 e:. err_s
e430: 74 72 69 6e 67 20 2b 3d 20 28 22 5c 74 22 20 2b tring += ("\t" +
e440: 20 73 65 6c 66 2e 73 69 6d 68 2e 63 68 69 6c 64 self.simh.child
e450: 5f 61 66 74 65 72 28 29 2e 73 74 72 69 70 28 29 _after().strip()
e460: 20 2b 20 22 5c 6e 22 29 0a 20 20 20 20 20 20 20 + "\n").
e470: 20 0a 20 20 20 20 20 20 65 78 70 65 63 74 5f 6c . expect_l
e480: 6f 6f 70 20 2b 3d 20 31 0a 20 20 20 20 20 20 72 oop += 1. r
e490: 65 70 6c 79 20 3d 20 73 65 6c 66 2e 73 69 6d 68 eply = self.simh
e4a0: 2e 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 28 73 ._child.expect(s
e4b0: 65 6c 66 2e 72 65 70 6c 69 65 73 5f 72 65 78 5b elf.replies_rex[
e4c0: 22 70 61 6c 38 22 5d 29 0a 20 20 20 20 20 20 6d "pal8"]). m
e4d0: 6f 6e 20 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 74 on = self.simh.t
e4e0: 65 73 74 5f 72 65 73 75 6c 74 28 72 65 70 6c 79 est_result(reply
e4f0: 2c 20 22 4d 6f 6e 69 74 6f 72 20 50 72 6f 6d 70 , "Monitor Promp
e500: 74 22 2c 20 73 65 6c 66 2e 72 65 70 6c 69 65 73 t", self.replies
e510: 5b 22 70 61 6c 38 22 5d 2c 20 22 22 29 0a 20 20 ["pal8"], "").
e520: 20 20 69 66 20 65 72 72 5f 63 6f 75 6e 74 20 3e if err_count >
e530: 20 30 20 6f 72 20 65 72 72 5f 73 74 72 69 6e 67 0 or err_string
e540: 20 21 3d 20 22 22 3a 0a 20 20 20 20 20 20 70 72 != "":. pr
e550: 69 6e 74 20 28 22 50 41 4c 38 20 45 72 72 6f 72 int ("PAL8 Error
e560: 3a 20 5c 6e 5c 74 22 20 2b 20 65 78 65 63 75 74 : \n\t" + execut
e570: 65 64 5f 6c 69 6e 65 29 0a 20 20 20 20 20 20 70 ed_line). p
e580: 72 69 6e 74 20 28 65 72 72 5f 73 74 72 69 6e 67 rint (err_string
e590: 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 ). return "
e5a0: 66 61 69 6c 22 0a 20 20 20 20 72 65 74 75 72 6e fail". return
e5b0: 20 22 73 75 63 63 65 73 73 22 0a 0a 0a 20 20 23 "success"... #
e5c0: 23 23 23 20 6f 63 6f 6d 70 5f 63 6f 6d 6d 61 6e ### ocomp_comman
e5d0: 64 20 23 23 23 23 23 23 23 23 23 23 23 23 23 23 d ##############
e5e0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
e5f0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
e600: 23 23 23 23 23 0a 20 20 23 20 54 68 69 73 20 63 #####. # This c
e610: 6f 6d 6d 61 6e 64 20 77 69 6c 6c 20 62 65 20 75 ommand will be u
e620: 73 65 64 20 74 6f 20 63 6f 6d 70 61 72 65 20 66 sed to compare f
e630: 69 6c 65 73 20 69 6e 20 32 20 70 6c 61 63 65 73 iles in 2 places
e640: 20 61 6e 64 0a 20 20 23 20 52 65 74 75 72 6e 20 and. # Return
e650: 73 75 63 63 65 73 73 20 69 66 20 74 68 65 79 20 success if they
e660: 61 72 65 20 74 68 65 20 73 61 6d 65 2c 20 61 6e are the same, an
e670: 64 20 72 65 74 75 72 6e 20 66 61 69 6c 75 72 65 d return failure
e680: 20 69 66 0a 20 20 23 20 6f 6e 65 20 6f 72 20 74 if. # one or t
e690: 68 65 20 6f 74 68 65 72 20 69 73 20 6d 69 73 73 he other is miss
e6a0: 69 6e 67 2c 20 6f 72 20 69 66 20 74 68 65 79 20 ing, or if they
e6b0: 61 72 65 20 64 69 66 66 65 72 65 6e 74 2e 0a 20 are different..
e6c0: 20 23 20 54 68 69 73 20 72 65 71 75 69 72 65 73 # This requires
e6d0: 20 6d 61 6b 69 6e 67 20 61 6e 20 69 6e 74 65 72 making an inter
e6e0: 70 72 65 74 61 74 69 6f 6e 20 6f 66 20 74 68 65 pretation of the
e6f0: 20 6f 75 74 70 75 74 20 74 68 61 74 20 69 73 0a output that is.
e700: 20 20 23 20 64 69 66 66 65 72 65 6e 74 20 66 72 # different fr
e710: 6f 6d 20 74 68 65 20 65 78 70 65 63 74 65 64 20 om the expected
e720: 22 6f 63 74 61 6c 20 64 75 6d 70 20 6f 66 20 64 "octal dump of d
e730: 69 66 66 65 72 65 6e 63 65 73 22 20 75 73 65 20 ifferences" use
e740: 63 61 73 65 2e 0a 20 20 23 20 22 4e 4f 54 48 49 case.. # "NOTHI
e750: 4e 47 20 4f 55 54 50 55 54 22 20 6d 65 61 6e 73 NG OUTPUT" means
e760: 20 73 75 63 63 65 73 73 2e 0a 20 20 23 20 41 6e success.. # An
e770: 79 20 22 55 53 45 52 20 45 52 52 4f 52 22 20 6f y "USER ERROR" o
e780: 75 74 70 75 74 20 6d 65 61 6e 73 20 66 61 69 6c utput means fail
e790: 75 72 65 2e 0a 0a 20 20 64 65 66 20 6f 63 6f 6d ure... def ocom
e7a0: 70 5f 63 6f 6d 6d 61 6e 64 20 28 73 65 6c 66 2c p_command (self,
e7b0: 20 6c 69 6e 65 2c 20 73 63 72 69 70 74 5f 66 69 line, script_fi
e7c0: 6c 65 29 3a 0a 20 20 20 20 69 66 20 73 65 6c 66 le):. if self
e7d0: 2e 76 65 72 62 6f 73 65 3a 20 70 72 69 6e 74 28 .verbose: print(
e7e0: 22 52 75 6e 6e 69 6e 67 20 4f 43 4f 4d 50 20 6f "Running OCOMP o
e7f0: 6e 3a 20 22 20 2b 20 6c 69 6e 65 29 0a 20 20 20 n: " + line).
e800: 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 63 68 reply = self.ch
e810: 65 63 6b 5f 61 6e 64 5f 72 75 6e 28 22 6f 63 6f eck_and_run("oco
e820: 6d 70 22 2c 20 22 52 20 4f 43 4f 4d 50 22 2c 20 mp", "R OCOMP",
e830: 73 63 72 69 70 74 5f 66 69 6c 65 29 0a 20 20 20 script_file).
e840: 20 69 66 20 72 65 70 6c 79 20 3d 3d 20 2d 31 3a if reply == -1:
e850: 20 72 65 74 75 72 6e 20 22 64 69 65 22 0a 0a 20 return "die"..
e860: 20 20 20 69 66 20 73 65 6c 66 2e 73 69 6d 68 2e if self.simh.
e870: 6f 73 38 5f 74 65 73 74 5f 72 65 73 75 6c 74 20 os8_test_result
e880: 28 72 65 70 6c 79 2c 20 22 43 6f 6d 6d 61 6e 64 (reply, "Command
e890: 20 44 65 63 6f 64 65 72 20 50 72 6f 6d 70 74 22 Decoder Prompt"
e8a0: 2c 20 22 63 61 6c 6c 5f 6f 63 6f 6d 70 22 29 20 , "call_ocomp")
e8b0: 3d 3d 20 46 61 6c 73 65 3a 0a 20 20 20 20 20 20 == False:.
e8c0: 70 72 69 6e 74 28 22 4f 43 4f 4d 50 20 66 61 69 print("OCOMP fai
e8d0: 6c 65 64 20 74 6f 20 73 74 61 72 74 20 61 74 20 led to start at
e8e0: 6c 69 6e 65 20 22 20 2b 20 73 74 72 28 73 65 6c line " + str(sel
e8f0: 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b f.line_ct_stack[
e900: 30 5d 29 29 0a 20 20 20 20 20 20 72 65 74 75 72 0])). retur
e910: 6e 20 22 66 61 69 6c 22 0a 0a 20 20 20 20 69 66 n "fail".. if
e920: 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 3a 20 70 self.verbose: p
e930: 72 69 6e 74 28 22 4c 69 6e 65 3a 20 22 20 2b 20 rint("Line: " +
e940: 5c 0a 20 20 20 20 20 20 20 73 74 72 28 73 65 6c \. str(sel
e950: 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b f.line_ct_stack[
e960: 30 5d 29 20 2b 20 22 3a 20 6f 63 6f 6d 70 5f 63 0]) + ": ocomp_c
e970: 6f 6d 6d 61 6e 64 3a 20 22 20 2b 20 6c 69 6e 65 ommand: " + line
e980: 29 0a 0a 20 20 20 20 23 20 53 65 6e 64 20 6f 75 ).. # Send ou
e990: 72 20 63 6f 6d 6d 61 6e 64 20 61 6e 64 20 68 61 r command and ha
e9a0: 72 76 65 73 74 20 72 65 73 75 6c 74 73 2e 0a 20 rvest results..
e9b0: 20 20 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e reply = self.
e9c0: 73 69 6d 68 2e 6f 73 38 5f 63 6d 64 20 28 6c 69 simh.os8_cmd (li
e9d0: 6e 65 2c 20 73 65 6c 66 2e 72 65 70 6c 69 65 73 ne, self.replies
e9e0: 5f 72 65 78 5b 22 6f 63 6f 6d 70 22 5d 29 0a 20 _rex["ocomp"]).
e9f0: 20 20 20 69 66 20 22 74 72 61 6e 73 63 72 69 70 if "transcrip
ea00: 74 22 20 69 6e 20 73 65 6c 66 2e 6f 70 74 69 6f t" in self.optio
ea10: 6e 73 5f 65 6e 61 62 6c 65 64 3a 0a 20 20 20 20 ns_enabled:.
ea20: 20 20 70 72 69 6e 74 20 28 73 65 6c 66 2e 73 69 print (self.si
ea30: 6d 68 2e 5f 63 68 69 6c 64 2e 62 65 66 6f 72 65 mh._child.before
ea40: 2e 64 65 63 6f 64 65 28 29 2e 73 74 72 69 70 28 .decode().strip(
ea50: 29 29 0a 0a 20 20 20 20 72 65 74 5f 76 61 6c 20 )).. ret_val
ea60: 3d 20 22 66 61 69 6c 22 0a 20 20 20 20 65 78 70 = "fail". exp
ea70: 65 63 74 5f 6c 6f 6f 70 20 3d 20 31 0a 0a 20 20 ect_loop = 1..
ea80: 20 20 6d 6f 6e 20 3d 20 73 65 6c 66 2e 73 69 6d mon = self.sim
ea90: 68 2e 74 65 73 74 5f 72 65 73 75 6c 74 28 72 65 h.test_result(re
eaa0: 70 6c 79 2c 20 22 4d 6f 6e 69 74 6f 72 20 50 72 ply, "Monitor Pr
eab0: 6f 6d 70 74 22 2c 20 73 65 6c 66 2e 72 65 70 6c ompt", self.repl
eac0: 69 65 73 5b 22 6f 63 6f 6d 70 22 5d 2c 20 22 22 ies["ocomp"], ""
ead0: 29 0a 20 20 20 20 23 20 57 65 20 67 65 74 20 72 ). # We get r
eae0: 65 74 75 72 6e 20 73 74 61 74 75 73 20 61 6e 64 eturn status and
eaf0: 20 74 68 65 6e 20 63 6c 65 61 6e 20 75 70 20 74 then clean up t
eb00: 68 65 20 73 74 61 74 65 20 6d 61 63 68 69 6e 65 he state machine
eb10: 2e 0a 20 20 20 20 77 68 69 6c 65 20 6e 6f 74 20 .. while not
eb20: 6d 6f 6e 3a 0a 20 20 20 20 20 20 69 66 20 73 65 mon:. if se
eb30: 6c 66 2e 64 65 62 75 67 3a 0a 20 20 20 20 20 20 lf.debug:.
eb40: 20 20 70 72 69 6e 74 20 28 22 6f 63 6f 6d 70 20 print ("ocomp
eb50: 67 61 76 65 20 72 65 70 6c 79 3a 20 5b 22 20 2b gave reply: [" +
eb60: 20 73 74 72 28 65 78 70 65 63 74 5f 6c 6f 6f 70 str(expect_loop
eb70: 29 20 2b 22 5d 20 22 20 2b 20 73 74 72 28 72 65 ) +"] " + str(re
eb80: 70 6c 79 29 20 2b 20 22 20 2d 3e 20 22 20 2b 20 ply) + " -> " +
eb90: 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 73 \. s
eba0: 65 6c 66 2e 72 65 70 6c 69 65 73 5b 22 6f 63 6f elf.replies["oco
ebb0: 6d 70 22 5d 5b 72 65 70 6c 79 5d 5b 30 5d 29 0a mp"][reply][0]).
ebc0: 20 20 20 20 20 20 6f 6b 20 3d 20 73 65 6c 66 2e ok = self.
ebd0: 73 69 6d 68 2e 74 65 73 74 5f 72 65 73 75 6c 74 simh.test_result
ebe0: 28 72 65 70 6c 79 2c 20 22 4e 4f 54 48 49 4e 47 (reply, "NOTHING
ebf0: 20 4f 55 54 50 55 54 22 2c 20 73 65 6c 66 2e 72 OUTPUT", self.r
ec00: 65 70 6c 69 65 73 5b 22 6f 63 6f 6d 70 22 5d 2c eplies["ocomp"],
ec10: 20 22 22 29 0a 20 20 20 20 20 20 63 64 20 20 3d ""). cd =
ec20: 20 73 65 6c 66 2e 73 69 6d 68 2e 74 65 73 74 5f self.simh.test_
ec30: 72 65 73 75 6c 74 28 72 65 70 6c 79 2c 20 22 43 result(reply, "C
ec40: 6f 6d 6d 61 6e 64 20 44 65 63 6f 64 65 72 20 50 ommand Decoder P
ec50: 72 6f 6d 70 74 22 2c 20 73 65 6c 66 2e 72 65 70 rompt", self.rep
ec60: 6c 69 65 73 5b 22 6f 63 6f 6d 70 22 5d 2c 20 22 lies["ocomp"], "
ec70: 22 29 0a 20 20 20 20 20 20 6e 66 20 3d 20 73 65 "). nf = se
ec80: 6c 66 2e 73 69 6d 68 2e 74 65 73 74 5f 72 65 73 lf.simh.test_res
ec90: 75 6c 74 28 72 65 70 6c 79 2c 20 22 46 69 6c 65 ult(reply, "File
eca0: 20 6e 6f 74 20 66 6f 75 6e 64 22 2c 20 73 65 6c not found", sel
ecb0: 66 2e 72 65 70 6c 69 65 73 5b 22 6f 63 6f 6d 70 f.replies["ocomp
ecc0: 22 5d 2c 20 22 22 29 0a 20 20 20 20 20 20 75 65 "], ""). ue
ecd0: 20 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 74 65 73 = self.simh.tes
ece0: 74 5f 72 65 73 75 6c 74 28 72 65 70 6c 79 2c 20 t_result(reply,
ecf0: 22 55 53 45 52 20 45 52 52 4f 52 22 2c 20 73 65 "USER ERROR", se
ed00: 6c 66 2e 72 65 70 6c 69 65 73 5b 22 6f 63 6f 6d lf.replies["ocom
ed10: 70 22 5d 2c 20 22 22 29 0a 0a 20 20 20 20 20 20 p"], "")..
ed20: 69 66 20 6f 6b 3a 0a 20 20 20 20 20 20 20 20 69 if ok:. i
ed30: 66 20 73 65 6c 66 2e 64 65 62 75 67 3a 20 70 72 f self.debug: pr
ed40: 69 6e 74 20 28 22 53 75 63 63 65 73 73 22 29 0a int ("Success").
ed50: 20 20 20 20 20 20 20 20 72 65 74 5f 76 61 6c 20 ret_val
ed60: 3d 20 22 73 75 63 63 65 73 73 22 0a 20 20 20 20 = "success".
ed70: 20 20 65 6c 69 66 20 6e 66 20 6f 72 20 75 65 3a elif nf or ue:
ed80: 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 20 28 . print (
ed90: 22 4f 43 4f 4d 50 3a 22 20 2b 20 73 65 6c 66 2e "OCOMP:" + self.
eda0: 73 69 6d 68 2e 63 68 69 6c 64 5f 61 66 74 65 72 simh.child_after
edb0: 28 29 2e 73 74 72 69 70 28 29 20 2b 20 22 5c 6e ().strip() + "\n
edc0: 22 29 0a 20 20 20 20 20 20 65 6c 69 66 20 63 64 "). elif cd
edd0: 3a 20 23 20 47 6f 74 20 43 6f 6d 6d 61 6e 64 20 : # Got Command
ede0: 44 65 63 6f 64 65 72 2e 20 45 78 69 74 20 77 69 Decoder. Exit wi
edf0: 74 68 20 66 61 69 6c 75 72 65 2e 0a 20 20 20 20 th failure..
ee00: 20 20 20 20 69 66 20 73 65 6c 66 2e 64 65 62 75 if self.debu
ee10: 67 3a 20 70 72 69 6e 74 20 28 22 63 61 6c 6c 5f g: print ("call_
ee20: 6f 63 6f 6d 70 3a 20 4e 6f 6e 2d 66 61 74 61 6c ocomp: Non-fatal
ee30: 20 65 72 72 6f 72 3a 20 53 65 6e 64 69 6e 67 20 error: Sending
ee40: 5e 43 22 29 0a 20 20 20 20 20 20 20 20 23 20 45 ^C"). # E
ee50: 78 69 74 20 4f 43 4f 4d 50 2e 20 57 65 27 6c 6c xit OCOMP. We'll
ee60: 20 63 6f 6e 66 69 72 6d 20 77 65 20 67 6f 74 20 confirm we got
ee70: 62 61 63 6b 20 74 6f 20 4f 53 2f 38 20 6d 6f 6e back to OS/8 mon
ee80: 69 74 6f 72 20 62 65 6c 6f 77 2e 0a 20 20 20 20 itor below..
ee90: 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 self.simh.os
eea0: 38 5f 73 65 6e 64 5f 63 74 72 6c 20 28 27 63 27 8_send_ctrl ('c'
eeb0: 29 20 20 20 20 20 20 0a 0a 20 20 20 20 20 20 72 ) .. r
eec0: 65 70 6c 79 20 3d 20 73 65 6c 66 2e 73 69 6d 68 eply = self.simh
eed0: 2e 5f 63 68 69 6c 64 2e 65 78 70 65 63 74 28 73 ._child.expect(s
eee0: 65 6c 66 2e 72 65 70 6c 69 65 73 5f 72 65 78 5b elf.replies_rex[
eef0: 22 6f 63 6f 6d 70 22 5d 29 0a 0a 20 20 20 20 20 "ocomp"])..
ef00: 20 69 66 20 22 74 72 61 6e 73 63 72 69 70 74 22 if "transcript"
ef10: 20 69 6e 20 73 65 6c 66 2e 6f 70 74 69 6f 6e 73 in self.options
ef20: 5f 65 6e 61 62 6c 65 64 3a 0a 20 20 20 20 20 20 _enabled:.
ef30: 20 20 70 72 69 6e 74 20 28 73 65 6c 66 2e 73 69 print (self.si
ef40: 6d 68 2e 5f 63 68 69 6c 64 2e 62 65 66 6f 72 65 mh._child.before
ef50: 2e 64 65 63 6f 64 65 28 29 2e 73 74 72 69 70 28 .decode().strip(
ef60: 29 29 0a 0a 20 20 20 20 20 20 65 78 70 65 63 74 )).. expect
ef70: 5f 6c 6f 6f 70 20 2b 3d 20 31 0a 0a 20 20 20 20 _loop += 1..
ef80: 20 20 6d 6f 6e 20 3d 20 73 65 6c 66 2e 73 69 6d mon = self.sim
ef90: 68 2e 74 65 73 74 5f 72 65 73 75 6c 74 28 72 65 h.test_result(re
efa0: 70 6c 79 2c 20 22 4d 6f 6e 69 74 6f 72 20 50 72 ply, "Monitor Pr
efb0: 6f 6d 70 74 22 2c 20 73 65 6c 66 2e 72 65 70 6c ompt", self.repl
efc0: 69 65 73 5b 22 6f 63 6f 6d 70 22 5d 2c 20 22 22 ies["ocomp"], ""
efd0: 29 0a 0a 20 20 20 20 72 65 74 75 72 6e 20 72 65 ).. return re
efe0: 74 5f 76 61 6c 0a 0a 20 20 0a 20 20 23 23 23 23 t_val.. . ####
eff0: 20 62 65 67 69 6e 5f 63 6f 6d 6d 61 6e 64 20 23 begin_command #
f000: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
f010: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
f020: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
f030: 23 23 0a 20 20 0a 20 20 64 65 66 20 62 65 67 69 ##. . def begi
f040: 6e 5f 63 6f 6d 6d 61 6e 64 20 28 73 65 6c 66 2c n_command (self,
f050: 20 6c 69 6e 65 2c 20 73 63 72 69 70 74 5f 66 69 line, script_fi
f060: 6c 65 29 3a 0a 20 20 20 20 69 66 20 6e 6f 74 20 le):. if not
f070: 73 65 6c 66 2e 62 6f 6f 74 65 64 3a 0a 20 20 20 self.booted:.
f080: 20 20 20 70 72 69 6e 74 28 22 43 61 6e 6e 6f 74 print("Cannot
f090: 20 65 78 65 63 75 74 65 20 62 65 67 69 6e 20 73 execute begin s
f0a0: 75 62 63 6f 6d 6d 61 6e 64 20 62 6c 6f 63 6b 20 ubcommand block
f0b0: 61 74 20 6c 69 6e 65 20 22 20 2b 20 5c 0a 20 20 at line " + \.
f0c0: 20 20 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c str(self.l
f0d0: 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 ine_ct_stack[0])
f0e0: 20 2b 20 22 2e 20 4f 53 2f 38 20 68 61 73 20 6e + ". OS/8 has n
f0f0: 6f 74 20 62 65 65 6e 20 62 6f 6f 74 65 64 2e 22 ot been booted."
f100: 29 0a 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 ). return "
f110: 64 69 65 22 0a 0a 20 20 20 20 73 75 62 5f 63 6f die".. sub_co
f120: 6d 6d 61 6e 64 73 20 3d 20 7b 22 62 75 69 6c 64 mmands = {"build
f130: 22 3a 20 73 65 6c 66 2e 62 75 69 6c 64 5f 73 75 ": self.build_su
f140: 62 63 6f 6d 6d 2c 0a 20 20 20 20 20 20 20 20 20 bcomm,.
f150: 20 20 20 20 20 20 20 20 20 20 20 22 63 64 70 72 "cdpr
f160: 6f 67 22 3a 20 73 65 6c 66 2e 63 64 70 72 6f 67 og": self.cdprog
f170: 5f 73 75 62 63 6f 6d 6d 7d 0a 20 20 0a 20 20 20 _subcomm}. .
f180: 20 6d 20 3d 20 72 65 2e 6d 61 74 63 68 28 5f 63 m = re.match(_c
f190: 6f 6d 6d 5f 72 65 2c 20 6c 69 6e 65 29 0a 20 20 omm_re, line).
f1a0: 20 20 69 66 20 6d 20 3d 3d 20 4e 6f 6e 65 3a 0a if m == None:.
f1b0: 20 20 20 20 20 20 70 72 69 6e 74 28 22 43 6f 75 print("Cou
f1c0: 6c 64 20 6e 6f 74 20 70 61 72 73 65 20 73 75 62 ld not parse sub
f1d0: 2d 63 6f 6d 6d 61 6e 64 20 61 74 20 6c 69 6e 65 -command at line
f1e0: 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 73 " + \. s
f1f0: 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f tr(self.line_ct_
f200: 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 3a 20 22 stack[0]) + ": "
f210: 20 2b 20 6c 69 6e 65 29 0a 20 20 20 20 69 66 20 + line). if
f220: 6d 2e 67 72 6f 75 70 28 31 29 20 6e 6f 74 20 69 m.group(1) not i
f230: 6e 20 73 75 62 5f 63 6f 6d 6d 61 6e 64 73 3a 0a n sub_commands:.
f240: 20 20 20 20 20 20 70 72 69 6e 74 28 22 49 67 6e print("Ign
f250: 6f 72 69 6e 67 20 75 6e 72 65 63 6f 67 6e 69 7a oring unrecogniz
f260: 65 64 20 73 75 62 2d 63 6f 6d 6d 61 6e 64 20 61 ed sub-command a
f270: 74 20 6c 69 6e 65 20 22 20 2b 20 5c 0a 20 20 20 t line " + \.
f280: 20 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c 69 str(self.li
f290: 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 ne_ct_stack[0])
f2a0: 2b 20 22 3a 20 22 20 2b 20 6d 2e 67 72 6f 75 70 + ": " + m.group
f2b0: 28 31 29 29 0a 20 20 20 20 20 20 70 72 69 6e 74 (1)). print
f2c0: 28 22 49 67 6e 6f 72 69 6e 67 20 65 76 65 72 79 ("Ignoring every
f2d0: 74 68 69 6e 67 20 74 6f 20 6e 65 78 74 20 65 6e thing to next en
f2e0: 64 2e 22 29 0a 20 20 20 20 20 20 73 65 6c 66 2e d."). self.
f2f0: 69 67 6e 6f 72 65 5f 74 6f 5f 73 75 62 63 6f 6d ignore_to_subcom
f300: 6d 5f 65 6e 64 28 6c 69 6e 65 2c 20 73 63 72 69 m_end(line, scri
f310: 70 74 5f 66 69 6c 65 2c 20 22 22 29 0a 20 20 20 pt_file, "").
f320: 20 20 20 72 65 74 75 72 6e 20 22 66 61 69 6c 22 return "fail"
f330: 0a 20 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 . else:.
f340: 20 23 20 41 6e 79 20 6f 73 38 2d 72 75 6e 20 63 # Any os8-run c
f350: 6f 6d 6d 61 6e 64 20 6d 61 79 20 62 65 20 63 61 ommand may be ca
f360: 6c 6c 65 64 20 61 66 74 65 72 20 61 20 73 69 6d lled after a sim
f370: 68 20 63 6f 6d 6d 61 6e 64 20 74 68 61 74 20 6c h command that l
f380: 65 66 74 20 75 73 0a 20 20 20 20 20 20 23 20 69 eft us. # i
f390: 6e 20 73 69 6d 68 20 63 6f 6e 74 65 78 74 2e 20 n simh context.
f3a0: 43 68 65 63 6b 20 74 6f 20 73 65 65 20 69 66 20 Check to see if
f3b0: 77 65 20 6e 65 65 64 20 74 6f 20 72 65 73 74 61 we need to resta
f3c0: 72 74 20 4f 53 2f 38 2e 0a 20 20 20 20 20 20 23 rt OS/8.. #
f3d0: 20 57 65 20 63 6f 75 6c 64 20 72 65 73 75 6d 65 We could resume
f3e0: 2c 20 62 75 74 20 72 65 73 74 61 72 74 20 69 73 , but restart is
f3f0: 20 73 61 66 65 72 2e 0a 20 20 20 20 20 20 69 66 safer.. if
f400: 20 73 65 6c 66 2e 73 69 6d 68 2e 5f 63 6f 6e 74 self.simh._cont
f410: 65 78 74 20 3d 3d 20 22 73 69 6d 68 22 3a 0a 20 ext == "simh":.
f420: 20 20 20 20 20 20 20 73 65 6c 66 2e 72 65 73 74 self.rest
f430: 61 72 74 5f 63 6f 6d 6d 61 6e 64 28 6c 69 6e 65 art_command(line
f440: 2c 20 73 63 72 69 70 74 5f 66 69 6c 65 29 0a 0a , script_file)..
f450: 20 20 20 20 20 20 72 65 74 75 72 6e 20 73 75 62 return sub
f460: 5f 63 6f 6d 6d 61 6e 64 73 5b 6d 2e 67 72 6f 75 _commands[m.grou
f470: 70 28 31 29 5d 28 6d 2e 67 72 6f 75 70 28 33 29 p(1)](m.group(3)
f480: 2c 20 73 63 72 69 70 74 5f 66 69 6c 65 29 0a 20 , script_file).
f490: 20 0a 20 20 0a 20 20 23 23 23 23 20 62 75 69 6c . . #### buil
f4a0: 64 5f 73 75 62 63 6f 6d 6d 20 23 23 23 23 23 23 d_subcomm ######
f4b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
f4c0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
f4d0: 23 23 23 23 23 23 23 23 23 23 23 23 23 0a 20 20 #############.
f4e0: 23 20 52 75 6e 20 73 79 73 74 65 6d 20 42 55 49 # Run system BUI
f4f0: 4c 44 20 63 6f 6d 6d 61 6e 64 2e 0a 20 20 23 20 LD command.. #
f500: 55 73 65 20 52 55 20 6e 6f 74 20 52 20 62 65 63 Use RU not R bec
f510: 61 75 73 65 20 77 65 20 77 69 6c 6c 20 73 61 76 ause we will sav
f520: 65 20 69 74 2e 0a 20 20 23 20 41 6c 6c 6f 77 20 e it.. # Allow
f530: 73 70 65 63 69 66 79 69 6e 67 20 57 48 49 43 48 specifying WHICH
f540: 20 76 65 72 73 69 6f 6e 20 6f 66 20 62 75 69 6c version of buil
f550: 64 20 6f 6e 20 74 68 65 20 63 6f 6d 6d 61 6e 64 d on the command
f560: 20 6c 69 6e 65 2e 0a 20 20 0a 20 20 64 65 66 20 line.. . def
f570: 62 75 69 6c 64 5f 73 75 62 63 6f 6d 6d 20 28 73 build_subcomm (s
f580: 65 6c 66 2c 20 6f 6c 64 5f 6c 69 6e 65 2c 20 73 elf, old_line, s
f590: 63 72 69 70 74 5f 66 69 6c 65 29 3a 0a 20 20 20 cript_file):.
f5a0: 20 6f 73 38 5f 63 6f 6d 6d 20 3d 20 22 52 55 20 os8_comm = "RU
f5b0: 22 20 2b 20 6f 6c 64 5f 6c 69 6e 65 0a 20 20 20 " + old_line.
f5c0: 20 69 66 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 if self.verbose
f5d0: 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 28 22 4c :. print("L
f5e0: 69 6e 65 20 22 20 2b 20 73 74 72 28 73 65 6c 66 ine " + str(self
f5f0: 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 .line_ct_stack[0
f600: 5d 29 20 2b 20 22 3a 20 22 20 2b 20 6f 73 38 5f ]) + ": " + os8_
f610: 63 6f 6d 6d 29 0a 0a 20 20 20 20 23 20 52 75 6e comm).. # Run
f620: 20 42 55 49 4c 44 20 61 6e 64 20 63 6f 6e 66 69 BUILD and confi
f630: 72 6d 20 69 74 20 68 61 73 20 73 74 61 72 74 65 rm it has starte
f640: 64 20 73 75 63 63 65 73 73 66 75 6c 6c 79 2e 0a d successfully..
f650: 20 20 20 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 reply = self
f660: 2e 73 69 6d 68 2e 6f 73 38 5f 63 6d 64 20 28 6f .simh.os8_cmd (o
f670: 73 38 5f 63 6f 6d 6d 2c 20 73 65 6c 66 2e 72 65 s8_comm, self.re
f680: 70 6c 69 65 73 5f 72 65 78 5b 22 62 75 69 6c 64 plies_rex["build
f690: 22 5d 2c 20 64 65 62 75 67 3d 73 65 6c 66 2e 64 "], debug=self.d
f6a0: 65 62 75 67 29 0a 20 20 20 20 69 66 20 73 65 6c ebug). if sel
f6b0: 66 2e 73 69 6d 68 2e 74 65 73 74 5f 72 65 73 75 f.simh.test_resu
f6c0: 6c 74 20 28 72 65 70 6c 79 2c 20 22 42 55 49 4c lt (reply, "BUIL
f6d0: 44 20 50 72 6f 6d 70 74 22 2c 20 73 65 6c 66 2e D Prompt", self.
f6e0: 72 65 70 6c 69 65 73 5b 22 62 75 69 6c 64 22 5d replies["build"]
f6f0: 2c 20 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20 , \.
f700: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
f710: 20 20 22 62 75 69 6c 64 5f 73 75 62 63 6f 6d 6d "build_subcomm
f720: 20 73 74 61 72 74 75 70 20 22 20 2b 20 6f 73 38 startup " + os8
f730: 5f 63 6f 6d 6d 2c 20 64 65 62 75 67 3d 73 65 6c _comm, debug=sel
f740: 66 2e 64 65 62 75 67 29 20 3d 3d 20 46 61 6c 73 f.debug) == Fals
f750: 65 3a 0a 20 20 20 20 20 20 70 72 69 6e 74 20 28 e:. print (
f760: 22 4c 69 6e 65 20 22 20 2b 20 73 74 72 28 73 65 "Line " + str(se
f770: 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b lf.line_ct_stack
f780: 5b 30 5d 29 20 2b 20 22 3a 20 22 20 2b 20 6f 73 [0]) + ": " + os
f790: 38 5f 63 6f 6d 6d 20 2b 20 22 20 66 61 69 6c 65 8_comm + " faile
f7a0: 64 2e 22 29 0a 20 20 20 20 20 20 70 72 69 6e 74 d."). print
f7b0: 20 28 22 49 67 6e 6f 72 69 6e 67 20 74 68 65 20 ("Ignoring the
f7c0: 72 65 73 74 20 6f 66 20 74 68 69 73 20 62 6c 6f rest of this blo
f7d0: 63 6b 2e 22 29 0a 20 20 20 20 20 20 73 65 6c 66 ck."). self
f7e0: 2e 69 67 6e 6f 72 65 5f 74 6f 5f 73 75 62 63 6f .ignore_to_subco
f7f0: 6d 6d 5f 65 6e 64 28 6f 73 38 5f 63 6f 6d 6d 2c mm_end(os8_comm,
f800: 20 73 63 72 69 70 74 5f 66 69 6c 65 2c 20 22 62 script_file, "b
f810: 75 69 6c 64 22 29 0a 20 20 20 20 20 20 23 20 43 uild"). # C
f820: 6f 6e 66 69 72 6d 20 77 65 27 72 65 20 62 61 63 onfirm we're bac
f830: 6b 20 74 6f 20 6d 6f 6e 69 74 6f 72 20 63 6f 6d k to monitor com
f840: 6d 61 6e 64 20 6c 65 76 65 6c 2e 0a 20 20 20 20 mand level..
f850: 20 20 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f self.simh.os8_
f860: 63 66 6d 5f 6d 6f 6e 69 74 6f 72 20 28 22 62 75 cfm_monitor ("bu
f870: 69 6c 64 5f 73 75 62 63 6f 6d 6d 20 31 22 29 0a ild_subcomm 1").
f880: 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 66 61 return "fa
f890: 69 6c 22 0a 0a 20 20 20 20 23 20 53 75 62 6d 69 il".. # Submi
f8a0: 74 20 74 68 65 20 6c 69 6e 65 73 20 66 72 6f 6d t the lines from
f8b0: 20 73 63 72 69 70 74 20 66 69 6c 65 20 74 6f 20 script file to
f8c0: 42 55 49 4c 44 20 73 75 62 2d 63 6f 6d 6d 61 6e BUILD sub-comman
f8d0: 64 2e 0a 20 20 20 20 66 6f 72 20 6c 69 6e 65 20 d.. for line
f8e0: 69 6e 20 73 63 72 69 70 74 5f 66 69 6c 65 3a 0a in script_file:.
f8f0: 20 20 20 20 20 20 6c 69 6e 65 20 3d 20 73 65 6c line = sel
f900: 66 2e 62 61 73 69 63 5f 6c 69 6e 65 5f 70 61 72 f.basic_line_par
f910: 73 65 28 6c 69 6e 65 2c 20 73 63 72 69 70 74 5f se(line, script_
f920: 66 69 6c 65 29 0a 20 20 20 20 20 20 69 66 20 6c file). if l
f930: 69 6e 65 20 3d 3d 20 4e 6f 6e 65 3a 20 63 6f 6e ine == None: con
f940: 74 69 6e 75 65 0a 20 20 0a 20 20 20 20 20 20 6d tinue. . m
f950: 20 3d 20 72 65 2e 6d 61 74 63 68 28 5f 63 6f 6d = re.match(_com
f960: 6d 5f 72 65 2c 20 6c 69 6e 65 29 0a 20 20 20 20 m_re, line).
f970: 20 20 69 66 20 6d 20 3d 3d 20 4e 6f 6e 65 3a 0a if m == None:.
f980: 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 49 print("I
f990: 67 6e 6f 72 69 6e 67 20 6d 61 6c 2d 66 6f 72 6d gnoring mal-form
f9a0: 65 64 20 62 75 69 6c 64 20 73 75 62 2d 63 6f 6d ed build sub-com
f9b0: 6d 61 6e 64 20 61 74 20 6c 69 6e 65 20 22 20 2b mand at line " +
f9c0: 20 5c 0a 20 20 20 20 20 20 20 20 20 20 73 74 72 \. str
f9d0: 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 (self.line_ct_st
f9e0: 61 63 6b 5b 30 5d 29 20 2b 20 22 3a 20 22 20 2b ack[0]) + ": " +
f9f0: 20 6c 69 6e 65 29 0a 20 20 20 20 20 20 20 20 63 line). c
fa00: 6f 6e 74 69 6e 75 65 0a 20 20 0a 20 20 20 20 20 ontinue. .
fa10: 20 62 75 69 6c 64 5f 73 75 62 20 3d 20 6d 2e 67 build_sub = m.g
fa20: 72 6f 75 70 28 31 29 0a 20 20 20 20 20 20 72 65 roup(1). re
fa30: 73 74 20 3d 20 6d 2e 67 72 6f 75 70 28 33 29 0a st = m.group(3).
fa40: 20 20 20 20 20 20 69 66 20 72 65 73 74 20 3d 3d if rest ==
fa50: 20 4e 6f 6e 65 3a 20 72 65 73 74 20 3d 20 22 22 None: rest = ""
fa60: 0a 20 20 20 20 20 20 0a 20 20 20 20 20 20 69 66 . . if
fa70: 20 73 65 6c 66 2e 64 65 62 75 67 3a 20 70 72 69 self.debug: pri
fa80: 6e 74 20 28 22 62 75 69 6c 64 5f 73 75 62 3a 20 nt ("build_sub:
fa90: 22 20 2b 20 62 75 69 6c 64 5f 73 75 62 29 0a 20 " + build_sub).
faa0: 20 20 20 20 20 69 66 20 62 75 69 6c 64 5f 73 75 if build_su
fab0: 62 20 6e 6f 74 20 69 6e 20 5f 62 75 69 6c 64 5f b not in _build_
fac0: 63 6f 6d 6d 5f 72 65 67 73 3a 0a 20 20 20 20 20 comm_regs:.
fad0: 20 20 20 70 72 69 6e 74 28 22 55 6e 72 65 63 6f print("Unreco
fae0: 67 6e 69 7a 65 64 20 42 55 49 4c 44 20 63 6f 6d gnized BUILD com
faf0: 6d 61 6e 64 20 61 74 20 6c 69 6e 65 20 22 20 2b mand at line " +
fb00: 20 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20 73 \. s
fb10: 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f tr(self.line_ct_
fb20: 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 3a 20 22 stack[0]) + ": "
fb30: 20 2b 20 62 75 69 6c 64 5f 73 75 62 29 0a 20 20 + build_sub).
fb40: 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 65 0a 0a continue..
fb50: 20 20 20 20 20 20 23 20 48 61 6e 64 6c 65 20 74 # Handle t
fb60: 68 65 20 65 78 69 74 20 66 72 6f 6d 20 42 55 49 he exit from BUI
fb70: 4c 44 20 77 68 65 6e 20 77 65 20 68 69 74 20 61 LD when we hit a
fb80: 6e 20 22 65 6e 64 22 20 73 74 61 74 65 6d 65 6e n "end" statemen
fb90: 74 2e 0a 20 20 20 20 20 20 69 66 20 62 75 69 6c t.. if buil
fba0: 64 5f 73 75 62 20 3d 3d 20 22 65 6e 64 22 3a 0a d_sub == "end":.
fbb0: 20 20 20 20 20 20 20 20 69 66 20 72 65 73 74 20 if rest
fbc0: 3d 3d 20 22 22 3a 0a 20 20 20 20 20 20 20 20 20 == "":.
fbd0: 20 70 72 69 6e 74 28 22 57 61 72 6e 69 6e 67 21 print("Warning!
fbe0: 20 65 6e 64 20 73 74 61 74 65 6d 65 6e 74 20 65 end statement e
fbf0: 6e 63 6f 75 6e 74 65 72 65 64 20 69 6e 73 69 64 ncountered insid
fc00: 65 20 62 75 69 6c 64 20 77 69 74 68 20 6e 6f 20 e build with no
fc10: 61 72 67 75 6d 65 6e 74 20 61 74 20 6c 69 6e 65 argument at line
fc20: 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 " + \.
fc30: 20 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c 69 str(self.li
fc40: 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 ne_ct_stack[0])
fc50: 2b 20 22 2e 5c 6e 45 78 69 74 69 6e 67 20 62 75 + ".\nExiting bu
fc60: 69 6c 64 2e 22 29 0a 20 20 20 20 20 20 20 20 20 ild.").
fc70: 20 23 20 45 78 69 74 20 42 55 49 4c 44 2e 20 4e # Exit BUILD. N
fc80: 6f 74 65 21 20 55 6e 6c 69 6b 65 20 6d 61 6e 79 ote! Unlike many
fc90: 20 63 6f 6d 6d 61 6e 64 73 20 62 75 69 6c 64 20 commands build
fca0: 64 6f 65 73 20 4e 4f 54 20 65 63 68 6f 20 22 5e does NOT echo "^
fcb0: 43 21 22 0a 20 20 20 20 20 20 20 20 20 20 73 65 C!". se
fcc0: 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 63 74 72 6c lf.simh.os8_ctrl
fcd0: 5f 63 20 28 22 62 75 69 6c 64 5f 73 75 62 63 6f _c ("build_subco
fce0: 6d 6d 20 65 6e 64 20 77 69 74 68 20 6e 6f 20 61 mm end with no a
fcf0: 72 67 75 6d 65 6e 74 22 29 0a 20 20 20 20 20 20 rgument").
fd00: 20 20 20 20 72 65 74 75 72 6e 20 22 66 61 69 6c return "fail
fd10: 22 0a 20 20 20 20 20 20 20 20 65 6c 69 66 20 72 ". elif r
fd20: 65 73 74 20 21 3d 20 22 62 75 69 6c 64 22 3a 20 est != "build":
fd30: 0a 20 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 . print
fd40: 28 22 57 61 72 6e 69 6e 67 21 20 4d 69 73 6d 61 ("Warning! Misma
fd50: 74 63 68 65 64 20 62 65 67 69 6e 2f 65 6e 64 20 tched begin/end
fd60: 62 6c 6f 63 6b 73 20 69 6e 20 42 55 49 4c 44 20 blocks in BUILD
fd70: 61 74 20 6c 69 6e 65 20 22 20 2b 20 5c 0a 20 20 at line " + \.
fd80: 20 20 20 20 20 20 20 20 20 20 20 20 73 74 72 28 str(
fd90: 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 self.line_ct_sta
fda0: 63 6b 5b 30 5d 29 20 2b 20 22 2e 5c 6e 45 6e 63 ck[0]) + ".\nEnc
fdb0: 6f 75 6e 74 65 72 65 64 20 65 6e 64 3a 20 7b 22 ountered end: {"
fdc0: 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 20 + \.
fdd0: 20 20 20 72 65 73 74 20 2b 20 22 7d 2e 20 45 78 rest + "}. Ex
fde0: 69 74 69 6e 67 20 42 55 49 4c 44 2e 22 29 0a 20 iting BUILD.").
fdf0: 20 20 20 20 20 20 20 20 20 23 20 45 78 69 74 20 # Exit
fe00: 42 55 49 4c 44 2e 20 4e 6f 74 65 21 20 55 6e 6c BUILD. Note! Unl
fe10: 69 6b 65 20 6d 61 6e 79 20 63 6f 6d 6d 61 6e 64 ike many command
fe20: 73 20 62 75 69 6c 64 20 64 6f 65 73 20 4e 4f 54 s build does NOT
fe30: 20 65 63 68 6f 20 22 5e 43 21 22 0a 20 20 20 20 echo "^C!".
fe40: 20 20 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 2e self.simh.
fe50: 6f 73 38 5f 63 74 72 6c 5f 63 20 28 22 62 75 69 os8_ctrl_c ("bui
fe60: 6c 64 5f 73 75 62 63 6f 6d 6d 20 6d 69 73 6d 61 ld_subcomm misma
fe70: 74 63 68 65 64 20 62 65 67 69 6e 2f 65 6e 64 22 tched begin/end"
fe80: 29 0a 20 20 20 20 20 20 20 20 20 20 72 65 74 75 ). retu
fe90: 72 6e 20 22 66 61 69 6c 22 0a 20 20 20 20 20 20 rn "fail".
fea0: 20 20 0a 20 20 20 20 20 20 20 20 23 20 57 65 27 . # We'
feb0: 72 65 20 64 6f 6e 65 2e 20 20 50 72 69 6e 74 20 re done. Print
fec0: 61 6e 79 20 64 65 73 69 72 65 64 20 76 65 72 62 any desired verb
fed0: 6f 73 65 20 6f 72 20 64 65 62 75 67 20 73 74 61 ose or debug sta
fee0: 74 75 73 0a 20 20 20 20 20 20 20 20 23 20 74 68 tus. # th
fef0: 65 6e 20 5e 43 20 74 6f 20 65 78 69 74 20 61 6e en ^C to exit an
ff00: 64 20 63 6f 6e 66 69 72 6d 20 77 65 27 72 65 20 d confirm we're
ff10: 61 74 20 6d 6f 6e 69 74 6f 72 20 6c 65 76 65 6c at monitor level
ff20: 2e 0a 20 20 20 20 20 20 20 20 69 66 20 73 65 6c .. if sel
ff30: 66 2e 76 65 72 62 6f 73 65 3a 0a 20 20 20 20 20 f.verbose:.
ff40: 20 20 20 20 20 70 72 69 6e 74 28 22 4c 69 6e 65 print("Line
ff50: 20 22 20 2b 20 73 74 72 28 73 65 6c 66 2e 6c 69 " + str(self.li
ff60: 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 ne_ct_stack[0])
ff70: 2b 20 22 3a 20 65 6e 64 20 42 55 49 4c 44 22 29 + ": end BUILD")
ff80: 0a 20 20 20 20 20 20 20 20 69 66 20 73 65 6c 66 . if self
ff90: 2e 64 65 62 75 67 3a 0a 20 20 20 20 20 20 20 20 .debug:.
ffa0: 20 20 70 72 69 6e 74 28 22 62 65 66 6f 72 65 3a print("before:
ffb0: 20 22 20 2b 20 73 65 6c 66 2e 73 69 6d 68 2e 5f " + self.simh._
ffc0: 63 68 69 6c 64 2e 62 65 66 6f 72 65 2e 64 65 63 child.before.dec
ffd0: 6f 64 65 28 29 2e 73 74 72 69 70 28 29 29 0a 20 ode().strip()).
ffe0: 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 print("
fff0: 61 66 74 65 72 3a 20 22 20 2b 20 73 65 6c 66 2e after: " + self.
10000 73 69 6d 68 2e 63 68 69 6c 64 5f 61 66 74 65 72 simh.child_after
10010 28 29 2e 73 74 72 69 70 28 29 29 0a 20 20 20 20 ().strip()).
10020 20 20 20 20 23 20 52 65 74 75 72 6e 20 74 6f 20 # Return to
10030 6d 6f 6e 69 74 6f 72 2e 0a 20 20 20 20 20 20 20 monitor..
10040 20 23 20 4e 6f 74 65 21 20 55 6e 6c 69 6b 65 20 # Note! Unlike
10050 6d 61 6e 79 20 63 6f 6d 6d 61 6e 64 73 20 62 75 many commands bu
10060 69 6c 64 20 64 6f 65 73 20 4e 4f 54 20 65 63 68 ild does NOT ech
10070 6f 20 22 5e 43 21 22 0a 20 20 20 20 20 20 20 20 o "^C!".
10080 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 63 74 self.simh.os8_ct
10090 72 6c 5f 63 20 28 22 62 75 69 6c 64 5f 73 75 62 rl_c ("build_sub
100a0 63 6f 6d 6d 20 65 6e 64 20 77 69 74 68 20 6e 6f comm end with no
100b0 20 61 72 67 75 6d 65 6e 74 2e 22 29 0a 20 20 20 argument.").
100c0 20 20 20 20 20 72 65 74 75 72 6e 20 22 73 75 63 return "suc
100d0 63 65 73 73 22 0a 20 20 20 20 20 20 20 20 0a 20 cess". .
100e0 20 20 20 20 20 23 20 4e 6f 77 20 70 65 72 66 6f # Now perfo
100f0 72 6d 20 73 75 62 2d 63 6f 6d 6d 61 6e 64 73 20 rm sub-commands
10100 77 69 74 68 69 6e 20 42 55 49 4c 44 2e 20 54 68 within BUILD. Th
10110 65 79 20 68 61 76 65 20 61 20 64 69 73 63 65 72 ey have a discer
10120 6e 61 62 6c 65 20 66 6f 72 6d 61 74 2e 0a 20 20 nable format..
10130 20 20 20 20 62 75 69 6c 64 5f 72 65 20 3d 20 5f build_re = _
10140 62 75 69 6c 64 5f 63 6f 6d 6d 5f 72 65 67 73 5b build_comm_regs[
10150 62 75 69 6c 64 5f 73 75 62 5d 0a 20 20 0a 20 20 build_sub]. .
10160 20 20 20 20 69 66 20 62 75 69 6c 64 5f 72 65 20 if build_re
10170 21 3d 20 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 20 != None:.
10180 20 6d 32 20 3d 20 72 65 2e 6d 61 74 63 68 28 62 m2 = re.match(b
10190 75 69 6c 64 5f 72 65 2c 20 72 65 73 74 29 0a 20 uild_re, rest).
101a0 20 20 20 20 20 20 20 69 66 20 6d 32 20 3d 3d 20 if m2 ==
101b0 4e 6f 6e 65 3a 0a 20 20 20 20 20 20 20 20 20 20 None:.
101c0 70 72 69 6e 74 28 22 49 67 6e 6f 72 69 6e 67 20 print("Ignoring
101d0 6d 61 6c 2d 66 6f 72 6d 65 64 20 42 55 49 4c 44 mal-formed BUILD
101e0 20 61 74 20 6c 69 6e 65 20 22 20 2b 20 5c 0a 20 at line " + \.
101f0 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 72 str
10200 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 (self.line_ct_st
10210 61 63 6b 5b 30 5d 29 20 2b 20 22 3a 20 22 20 2b ack[0]) + ": " +
10220 20 62 75 69 6c 64 5f 73 75 62 20 2b 20 5c 0a 20 build_sub + \.
10230 20 20 20 20 20 20 20 20 20 20 20 20 20 22 20 63 " c
10240 6f 6d 6d 61 6e 64 3a 20 22 20 2b 20 72 65 73 74 ommand: " + rest
10250 29 0a 20 20 20 20 20 20 20 20 20 20 63 6f 6e 74 ). cont
10260 69 6e 75 65 0a 20 20 20 20 20 20 0a 20 20 20 20 inue. .
10270 20 20 20 20 69 66 20 62 75 69 6c 64 5f 73 75 62 if build_sub
10280 20 3d 3d 20 22 42 55 49 4c 44 22 3a 0a 20 20 20 == "BUILD":.
10290 20 20 20 20 20 20 20 69 66 20 6d 32 2e 67 72 6f if m2.gro
102a0 75 70 28 31 29 20 3d 3d 20 4e 6f 6e 65 20 6f 72 up(1) == None or
102b0 20 6d 32 2e 67 72 6f 75 70 28 31 29 20 3d 3d 20 m2.group(1) ==
102c0 22 22 3a 0a 20 20 20 20 20 20 20 20 20 20 20 20 "":.
102d0 70 72 69 6e 74 28 22 4d 69 73 73 69 6e 67 20 73 print("Missing s
102e0 6f 75 72 63 65 20 6f 66 20 4f 53 38 2e 42 4e 2e ource of OS8.BN.
102f0 20 49 67 6e 6f 72 69 6e 67 20 42 55 49 4c 44 20 Ignoring BUILD
10300 63 6f 6d 6d 61 6e 64 20 61 74 20 6c 69 6e 65 20 command at line
10310 22 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 " + \.
10320 20 20 20 20 20 20 73 74 72 28 73 65 6c 66 2e 6c str(self.l
10330 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 ine_ct_stack[0])
10340 20 2b 20 22 2e 22 29 0a 20 20 20 20 20 20 20 20 + ".").
10350 20 20 20 20 63 6f 6e 74 69 6e 75 65 0a 20 20 20 continue.
10360 20 20 20 20 20 20 20 65 6c 73 65 3a 20 6b 62 6d else: kbm
10370 5f 61 72 67 20 3d 20 6d 32 2e 67 72 6f 75 70 28 _arg = m2.group(
10380 31 29 0a 0a 20 20 20 20 20 20 20 20 20 20 69 66 1).. if
10390 20 6d 32 2e 67 72 6f 75 70 28 33 29 20 3d 3d 20 m2.group(3) ==
103a0 4e 6f 6e 65 20 6f 72 20 6d 32 2e 67 72 6f 75 70 None or m2.group
103b0 28 33 29 20 3d 3d 20 22 22 3a 0a 20 20 20 20 20 (3) == "":.
103c0 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 4d 69 print("Mi
103d0 73 73 69 6e 67 20 73 6f 72 63 65 20 6f 66 20 43 ssing sorce of C
103e0 44 2e 42 4e 2e 20 49 67 6e 6f 72 69 6e 67 20 42 D.BN. Ignoring B
103f0 55 49 4c 44 20 63 6f 6d 6d 61 6e 64 20 61 74 20 UILD command at
10400 6c 69 6e 65 20 22 20 2b 20 5c 0a 20 20 20 20 20 line " + \.
10410 20 20 20 20 20 20 20 20 20 20 20 73 74 72 28 73 str(s
10420 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 elf.line_ct_stac
10430 6b 5b 30 5d 29 20 2b 20 22 2e 22 29 0a 20 20 20 k[0]) + ".").
10440 20 20 20 20 20 20 20 20 20 63 6f 6e 74 69 6e 75 continu
10450 65 0a 20 20 20 20 20 20 20 20 20 20 65 6c 73 65 e. else
10460 3a 20 63 64 5f 61 72 67 20 3d 20 6d 32 2e 67 72 : cd_arg = m2.gr
10470 6f 75 70 28 33 29 0a 20 20 20 20 20 20 20 20 20 oup(3).
10480 20 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 73 . if s
10490 65 6c 66 2e 76 65 72 62 6f 73 65 3a 0a 20 20 20 elf.verbose:.
104a0 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 print("
104b0 4c 69 6e 65 20 22 20 2b 20 73 74 72 28 73 65 6c Line " + str(sel
104c0 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b f.line_ct_stack[
104d0 30 5d 29 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 0]) + \.
104e0 20 20 20 20 20 20 20 20 20 22 3a 20 42 55 49 4c ": BUIL
104f0 44 20 4b 42 4d 3a 20 22 20 2b 20 6b 62 6d 5f 61 D KBM: " + kbm_a
10500 72 67 20 2b 20 22 2c 20 43 44 3a 20 22 20 2b 20 rg + ", CD: " +
10510 63 64 5f 61 72 67 29 0a 0a 20 20 20 20 20 20 20 cd_arg)..
10520 20 20 20 23 20 43 6f 6e 66 69 72 6d 20 70 72 6f # Confirm pro
10530 6d 70 74 65 64 20 66 6f 72 20 4f 53 38 20 62 69 mpted for OS8 bi
10540 6e 61 72 79 2e 0a 20 20 20 20 20 20 20 20 20 20 nary..
10550 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 73 69 6d reply = self.sim
10560 68 2e 6f 73 38 5f 63 6d 64 20 28 22 42 55 49 4c h.os8_cmd ("BUIL
10570 44 22 2c 20 73 65 6c 66 2e 72 65 70 6c 69 65 73 D", self.replies
10580 5f 72 65 78 5b 22 62 75 69 6c 64 22 5d 2c 20 64 _rex["build"], d
10590 65 62 75 67 3d 73 65 6c 66 2e 64 65 62 75 67 29 ebug=self.debug)
105a0 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 73 65 . if se
105b0 6c 66 2e 73 69 6d 68 2e 74 65 73 74 5f 72 65 73 lf.simh.test_res
105c0 75 6c 74 28 72 65 70 6c 79 2c 20 22 4c 4f 41 44 ult(reply, "LOAD
105d0 20 4f 53 38 22 2c 20 73 65 6c 66 2e 72 65 70 6c OS8", self.repl
105e0 69 65 73 5b 22 62 75 69 6c 64 22 5d 2c 20 22 62 ies["build"], "b
105f0 75 69 6c 64 5f 73 75 62 63 6f 6d 6d 20 35 22 29 uild_subcomm 5")
10600 20 3d 3d 20 46 61 6c 73 65 3a 0a 20 20 20 20 20 == False:.
10610 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 4e 6f print("No
10620 20 70 72 6f 6d 70 74 20 66 6f 72 20 4c 4f 41 44 prompt for LOAD
10630 20 4f 53 2f 38 20 69 6e 20 42 55 49 4c 44 20 63 OS/8 in BUILD c
10640 6f 6d 6d 61 6e 64 20 77 69 74 68 69 6e 20 42 55 ommand within BU
10650 49 4c 44 20 61 74 20 6c 69 6e 65 20 22 20 2b 20 ILD at line " +
10660 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 \.
10670 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 str(self.line_ct
10680 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 2e 22 _stack[0]) + "."
10690 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 72 ). pr
106a0 69 6e 74 28 22 46 61 74 61 6c 20 65 72 72 6f 72 int("Fatal error
106b0 2e 20 41 62 6f 72 74 69 6e 67 20 73 63 72 69 70 . Aborting scrip
106c0 74 2e 22 29 0a 20 20 20 20 20 20 20 20 20 20 20 t.").
106d0 20 72 65 74 75 72 6e 20 22 64 69 65 22 0a 0a 20 return "die"..
106e0 20 20 20 20 20 20 20 20 20 23 20 53 65 6e 64 20 # Send
106f0 69 74 20 61 6e 64 20 63 6f 6e 66 69 72 6d 20 70 it and confirm p
10700 72 6f 6d 70 74 65 64 20 66 6f 72 20 43 44 20 62 rompted for CD b
10710 69 6e 61 72 79 2e 0a 20 20 20 20 20 20 20 20 20 inary..
10720 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 73 69 reply = self.si
10730 6d 68 2e 6f 73 38 5f 63 6d 64 20 28 6b 62 6d 5f mh.os8_cmd (kbm_
10740 61 72 67 2c 20 73 65 6c 66 2e 72 65 70 6c 69 65 arg, self.replie
10750 73 5f 72 65 78 5b 22 62 75 69 6c 64 22 5d 2c 20 s_rex["build"],
10760 64 65 62 75 67 3d 73 65 6c 66 2e 64 65 62 75 67 debug=self.debug
10770 29 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 73 ). if s
10780 65 6c 66 2e 73 69 6d 68 2e 74 65 73 74 5f 72 65 elf.simh.test_re
10790 73 75 6c 74 28 72 65 70 6c 79 2c 20 22 4c 4f 41 sult(reply, "LOA
107a0 44 20 43 44 22 2c 20 73 65 6c 66 2e 72 65 70 6c D CD", self.repl
107b0 69 65 73 5b 22 62 75 69 6c 64 22 5d 2c 20 22 62 ies["build"], "b
107c0 75 69 6c 64 5f 73 75 62 63 6f 6d 6d 20 36 22 29 uild_subcomm 6")
107d0 20 3d 3d 20 46 61 6c 73 65 3a 0a 20 20 20 20 20 == False:.
107e0 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 4e 6f print("No
107f0 20 70 72 6f 6d 70 74 20 66 6f 72 20 4c 4f 41 44 prompt for LOAD
10800 20 43 44 20 69 6e 20 42 55 49 4c 44 20 63 6f 6d CD in BUILD com
10810 6d 61 6e 64 20 77 69 74 68 69 6e 20 42 55 49 4c mand within BUIL
10820 44 20 61 74 20 6c 69 6e 65 20 22 20 2b 20 5c 0a D at line " + \.
10830 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 74 st
10840 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 r(self.line_ct_s
10850 74 61 63 6b 5b 30 5d 29 20 2b 20 22 2e 22 29 0a tack[0]) + ".").
10860 20 20 20 20 20 20 20 20 20 20 20 20 70 72 69 6e prin
10870 74 28 22 46 61 74 61 6c 20 65 72 72 6f 72 2e 20 t("Fatal error.
10880 41 62 6f 72 74 69 6e 67 20 73 63 72 69 70 74 2e Aborting script.
10890 22 29 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 "). r
108a0 65 74 75 72 6e 20 22 64 69 65 22 0a 20 20 20 20 eturn "die".
108b0 20 20 20 20 20 20 23 20 53 65 6e 64 20 69 74 20 # Send it
108c0 61 6e 64 20 63 6f 6e 66 69 72 6d 20 77 65 27 72 and confirm we'r
108d0 65 20 62 61 63 6b 20 69 6e 20 42 55 49 4c 44 20 e back in BUILD
108e0 63 6f 6d 6d 61 6e 64 20 6d 6f 64 65 2e 0a 20 20 command mode..
108f0 20 20 20 20 20 20 20 20 72 65 70 6c 79 20 3d 20 reply =
10900 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 63 6d self.simh.os8_cm
10910 64 20 28 63 64 5f 61 72 67 2c 20 73 65 6c 66 2e d (cd_arg, self.
10920 72 65 70 6c 69 65 73 5f 72 65 78 5b 22 62 75 69 replies_rex["bui
10930 6c 64 22 5d 2c 20 64 65 62 75 67 3d 73 65 6c 66 ld"], debug=self
10940 2e 64 65 62 75 67 29 0a 20 20 20 20 20 20 20 20 .debug).
10950 20 20 69 66 20 73 65 6c 66 2e 73 69 6d 68 2e 74 if self.simh.t
10960 65 73 74 5f 72 65 73 75 6c 74 28 72 65 70 6c 79 est_result(reply
10970 2c 20 22 42 55 49 4c 44 20 50 72 6f 6d 70 74 22 , "BUILD Prompt"
10980 2c 20 73 65 6c 66 2e 72 65 70 6c 69 65 73 5b 22 , self.replies["
10990 62 75 69 6c 64 22 5d 2c 20 22 62 75 69 6c 64 5f build"], "build_
109a0 73 75 62 63 6f 6d 6d 20 37 22 29 20 3d 3d 20 46 subcomm 7") == F
109b0 61 6c 73 65 3a 0a 20 20 20 20 20 20 20 20 20 20 alse:.
109c0 20 20 70 72 69 6e 74 20 28 22 42 55 49 4c 44 20 print ("BUILD
109d0 63 6f 6d 6d 61 6e 64 20 77 69 74 68 69 6e 20 62 command within b
109e0 75 69 6c 64 20 66 61 69 6c 65 64 2e 20 20 41 62 uild failed. Ab
109f0 6f 72 74 69 6e 67 20 73 63 72 69 70 74 2e 22 29 orting script.")
10a00 0a 20 20 20 20 20 20 20 20 20 20 20 20 72 65 74 . ret
10a10 75 72 6e 20 22 64 69 65 22 0a 20 20 20 20 20 20 urn "die".
10a20 20 20 20 20 69 66 20 73 65 6c 66 2e 64 65 62 75 if self.debu
10a30 67 3a 0a 20 20 20 20 20 20 20 20 20 20 20 20 70 g:. p
10a40 72 69 6e 74 28 22 52 65 73 75 6d 65 20 42 55 49 rint("Resume BUI
10a50 4c 44 2e 53 56 20 63 6f 6d 6d 61 6e 64 20 6c 6f LD.SV command lo
10a60 6f 70 2e 22 29 0a 20 20 20 20 20 20 20 20 20 20 op.").
10a70 63 6f 6e 74 69 6e 75 65 0a 0a 20 20 20 20 20 20 continue..
10a80 23 20 4e 6f 72 6d 61 6c 20 63 61 73 65 3a 20 63 # Normal case: c
10a90 6f 6d 6d 61 6e 64 73 20 77 69 74 68 69 6e 20 42 ommands within B
10aa0 55 49 4c 44 2e 0a 20 20 20 20 20 20 63 6f 6d 6d UILD.. comm
10ab0 20 3d 20 62 75 69 6c 64 5f 73 75 62 20 2b 20 22 = build_sub + "
10ac0 20 22 20 2b 20 72 65 73 74 0a 20 20 20 20 20 20 " + rest.
10ad0 69 66 20 73 65 6c 66 2e 76 65 72 62 6f 73 65 3a if self.verbose:
10ae0 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 . print("
10af0 4c 69 6e 65 20 22 20 2b 20 73 74 72 28 73 65 6c Line " + str(sel
10b00 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b f.line_ct_stack[
10b10 30 5d 29 20 2b 20 22 3a 20 42 55 49 4c 44 2d 3e 0]) + ": BUILD->
10b20 20 22 20 2b 20 63 6f 6d 6d 29 0a 20 20 20 20 20 " + comm).
10b30 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 73 69 reply = self.si
10b40 6d 68 2e 6f 73 38 5f 63 6d 64 20 28 63 6f 6d 6d mh.os8_cmd (comm
10b50 2c 20 73 65 6c 66 2e 72 65 70 6c 69 65 73 5f 72 , self.replies_r
10b60 65 78 5b 22 62 75 69 6c 64 22 5d 2c 20 64 65 62 ex["build"], deb
10b70 75 67 3d 73 65 6c 66 2e 64 65 62 75 67 29 0a 0a ug=self.debug)..
10b80 20 20 20 20 20 20 23 20 53 70 65 63 69 61 6c 20 # Special
10b90 63 61 73 65 20 22 42 4f 4f 54 22 20 73 75 62 2d case "BOOT" sub-
10ba0 63 6f 6d 6d 61 6e 64 3a 20 4d 61 79 20 61 73 6b command: May ask
10bb0 2c 20 22 57 52 49 54 45 20 5a 45 52 4f 20 44 49 , "WRITE ZERO DI
10bc0 52 45 43 54 3f 22 0a 20 20 20 20 20 20 23 20 57 RECT?". # W
10bd0 69 6c 6c 20 67 69 76 65 20 61 20 6d 6f 6e 69 74 ill give a monit
10be0 6f 72 20 70 72 6f 6d 70 74 20 77 68 65 6e 20 64 or prompt when d
10bf0 6f 6e 65 2e 0a 20 20 20 20 20 20 69 66 20 62 75 one.. if bu
10c00 69 6c 64 5f 73 75 62 20 3d 3d 20 22 42 4f 4f 54 ild_sub == "BOOT
10c10 22 3a 0a 20 20 20 20 20 20 20 20 69 66 20 73 65 ":. if se
10c20 6c 66 2e 73 69 6d 68 2e 74 65 73 74 5f 72 65 73 lf.simh.test_res
10c30 75 6c 74 28 72 65 70 6c 79 2c 20 22 57 52 49 54 ult(reply, "WRIT
10c40 45 20 5a 45 52 4f 20 44 49 52 45 43 54 3f 22 2c E ZERO DIRECT?",
10c50 20 73 65 6c 66 2e 72 65 70 6c 69 65 73 5b 22 62 self.replies["b
10c60 75 69 6c 64 22 5d 2c 20 5c 0a 20 20 20 20 20 20 uild"], \.
10c70 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
10c80 20 20 20 20 20 20 20 20 20 20 20 22 22 2c 20 64 "", d
10c90 65 62 75 67 3d 73 65 6c 66 2e 64 65 62 75 67 29 ebug=self.debug)
10ca0 3a 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 73 :. if s
10cb0 65 6c 66 2e 64 65 62 75 67 3a 0a 20 20 20 20 20 elf.debug:.
10cc0 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 47 6f print("Go
10cd0 74 2c 20 5c 22 57 52 49 54 45 20 5a 45 52 4f 20 t, \"WRITE ZERO
10ce0 44 49 52 45 43 54 3f 5c 22 2e 20 53 65 6e 64 69 DIRECT?\". Sendi
10cf0 6e 67 20 5c 22 59 5c 22 2e 22 29 0a 20 20 20 20 ng \"Y\".").
10d00 20 20 20 20 20 20 72 65 70 6c 79 20 3d 20 73 65 reply = se
10d10 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 63 6d 64 28 lf.simh.os8_cmd(
10d20 22 59 22 2c 20 73 65 6c 66 2e 72 65 70 6c 69 65 "Y", self.replie
10d30 73 5f 72 65 78 5b 22 62 75 69 6c 64 22 5d 2c 20 s_rex["build"],
10d40 64 65 62 75 67 3d 73 65 6c 66 2e 64 65 62 75 67 debug=self.debug
10d50 29 0a 0a 20 20 20 20 20 20 20 20 69 66 20 73 65 ).. if se
10d60 6c 66 2e 73 69 6d 68 2e 74 65 73 74 5f 72 65 73 lf.simh.test_res
10d70 75 6c 74 28 72 65 70 6c 79 2c 20 22 53 59 53 20 ult(reply, "SYS
10d80 42 55 49 4c 54 22 2c 20 73 65 6c 66 2e 72 65 70 BUILT", self.rep
10d90 6c 69 65 73 5b 22 62 75 69 6c 64 22 5d 2c 20 22 lies["build"], "
10da0 22 2c 20 64 65 62 75 67 3d 73 65 6c 66 2e 64 65 ", debug=self.de
10db0 62 75 67 29 3a 0a 20 20 20 20 20 20 20 20 20 20 bug):.
10dc0 23 20 53 75 63 63 65 73 73 66 75 6c 20 62 6f 6f # Successful boo
10dd0 74 2e 20 20 57 65 27 72 65 20 6e 6f 77 20 61 74 t. We're now at
10de0 20 6d 6f 6e 69 74 6f 72 20 6c 65 76 65 6c 2e 0a monitor level..
10df0 20 20 20 20 20 20 20 20 20 20 23 20 53 69 6d 70 # Simp
10e00 6c 65 73 74 20 74 6f 20 69 67 6e 6f 72 65 20 61 lest to ignore a
10e10 6e 79 74 68 69 6e 67 20 65 6c 73 65 20 69 6e 20 nything else in
10e20 74 68 65 20 73 63 72 69 70 74 20 75 70 20 74 6f the script up to
10e30 20 22 65 6e 64 20 62 75 69 6c 64 22 0a 20 20 20 "end build".
10e40 20 20 20 20 20 20 20 23 20 52 65 74 75 72 6e 20 # Return
10e50 73 75 63 63 65 73 73 20 6f 72 20 66 61 69 6c 75 success or failu
10e60 72 65 20 62 61 73 65 64 20 6f 6e 20 66 69 6e 64 re based on find
10e70 69 6e 67 20 74 68 61 74 20 6d 6f 6e 69 74 6f 72 ing that monitor
10e80 20 70 72 6f 6d 70 74 2e 0a 20 20 20 20 20 20 20 prompt..
10e90 20 20 20 73 65 6c 66 2e 69 67 6e 6f 72 65 5f 74 self.ignore_t
10ea0 6f 5f 73 75 62 63 6f 6d 6d 5f 65 6e 64 28 6f 73 o_subcomm_end(os
10eb0 38 5f 63 6f 6d 6d 2c 20 73 63 72 69 70 74 5f 66 8_comm, script_f
10ec0 69 6c 65 2c 20 22 62 75 69 6c 64 22 29 0a 20 20 ile, "build").
10ed0 20 20 20 20 20 20 20 20 69 66 20 73 65 6c 66 2e if self.
10ee0 73 69 6d 68 2e 6f 73 38 5f 63 66 6d 5f 6d 6f 6e simh.os8_cfm_mon
10ef0 69 74 6f 72 20 28 22 62 75 69 6c 64 5f 73 75 62 itor ("build_sub
10f00 63 6f 6d 6d 20 38 22 29 3a 0a 20 20 20 20 20 20 comm 8"):.
10f10 20 20 20 20 20 20 72 65 74 75 72 6e 20 22 73 75 return "su
10f20 63 63 65 73 73 22 0a 20 20 20 20 20 20 20 20 20 ccess".
10f30 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 20 20 20 else:.
10f40 20 20 20 72 65 74 75 72 6e 20 22 66 61 69 6c 22 return "fail"
10f50 0a 0a 20 20 20 20 20 20 23 20 41 74 20 74 68 69 .. # At thi
10f60 73 20 70 6f 69 6e 74 20 77 65 20 65 69 74 68 65 s point we eithe
10f70 72 20 68 61 76 65 20 61 20 42 55 49 4c 44 20 70 r have a BUILD p
10f80 72 6f 6d 70 74 20 6f 72 20 61 6e 20 65 72 72 6f rompt or an erro
10f90 72 20 6d 65 73 73 61 67 65 2e 0a 20 20 20 20 20 r message..
10fa0 20 23 20 49 66 20 69 74 27 73 20 6e 6f 74 20 74 # If it's not t
10fb0 68 65 20 42 55 49 4c 44 20 70 72 6f 6d 70 74 2c he BUILD prompt,
10fc0 20 77 65 20 70 72 69 6e 74 20 61 6e 20 65 72 72 we print an err
10fd0 6f 72 2e 0a 20 20 20 20 20 20 23 20 49 66 20 74 or.. # If t
10fe0 68 65 20 65 72 72 6f 72 20 69 73 20 66 61 74 61 he error is fata
10ff0 6c 2c 20 69 67 6e 6f 72 65 20 72 65 73 74 20 6f l, ignore rest o
11000 66 20 62 75 69 6c 64 20 62 6c 6f 63 6b 2c 0a 20 f build block,.
11010 20 20 20 20 20 23 20 65 78 69 74 20 62 61 63 6b # exit back
11020 20 74 6f 20 4f 53 2f 38 20 69 66 20 6e 65 63 65 to OS/8 if nece
11030 73 73 61 72 79 20 61 6e 64 20 72 65 74 75 72 6e ssary and return
11040 20 66 61 69 6c 2e 0a 20 20 20 20 20 20 23 20 49 fail.. # I
11050 66 20 69 74 27 73 20 6e 6f 74 20 66 61 74 61 6c f it's not fatal
11060 2c 20 63 6f 6e 74 69 6e 75 65 20 72 75 6e 6e 69 , continue runni
11070 6e 67 20 42 55 49 4c 44 2e 0a 20 20 20 20 20 20 ng BUILD..
11080 69 66 20 73 65 6c 66 2e 73 69 6d 68 2e 74 65 73 if self.simh.tes
11090 74 5f 72 65 73 75 6c 74 28 72 65 70 6c 79 2c 20 t_result(reply,
110a0 22 42 55 49 4c 44 20 50 72 6f 6d 70 74 22 2c 20 "BUILD Prompt",
110b0 73 65 6c 66 2e 72 65 70 6c 69 65 73 5b 22 62 75 self.replies["bu
110c0 69 6c 64 22 5d 2c 20 5c 0a 20 20 20 20 20 20 20 ild"], \.
110d0 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
110e0 20 20 20 20 20 20 20 20 22 62 75 69 6c 64 5f 73 "build_s
110f0 75 62 63 6f 6d 6d 20 39 22 2c 20 64 65 62 75 67 ubcomm 9", debug
11100 3d 73 65 6c 66 2e 64 65 62 75 67 29 20 3d 3d 20 =self.debug) ==
11110 46 61 6c 73 65 3a 0a 20 20 20 20 20 20 20 20 70 False:. p
11120 72 69 6e 74 28 22 42 55 49 4c 44 20 65 72 72 6f rint("BUILD erro
11130 72 20 61 74 20 6c 69 6e 65 20 22 20 2b 20 73 74 r at line " + st
11140 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 r(self.line_ct_s
11150 74 61 63 6b 5b 30 5d 29 20 2b 20 5c 0a 20 20 20 tack[0]) + \.
11160 20 20 20 20 20 20 20 22 20 77 69 74 68 20 63 6f " with co
11170 6d 6d 61 6e 64 20 22 20 2b 20 73 65 6c 66 2e 73 mmand " + self.s
11180 69 6d 68 2e 5f 63 68 69 6c 64 2e 62 65 66 6f 72 imh._child.befor
11190 65 2e 64 65 63 6f 64 65 28 29 2e 73 74 72 69 70 e.decode().strip
111a0 28 29 29 0a 20 20 20 20 20 20 20 20 69 66 20 73 ()). if s
111b0 65 6c 66 2e 72 65 70 6c 69 65 73 5b 22 62 75 69 elf.replies["bui
111c0 6c 64 22 5d 5b 72 65 70 6c 79 5d 5b 32 5d 20 3d ld"][reply][2] =
111d0 3d 20 54 72 75 65 3a 0a 20 20 20 20 20 20 20 20 = True:.
111e0 20 20 70 72 69 6e 74 20 28 22 46 61 74 61 6c 20 print ("Fatal
111f0 65 72 72 6f 72 2e 20 20 49 67 6e 6f 72 69 6e 67 error. Ignoring
11200 20 72 65 73 74 20 6f 66 20 74 68 69 73 20 62 6c rest of this bl
11210 6f 63 6b 2e 22 29 0a 20 20 20 20 20 20 20 20 20 ock.").
11220 20 73 65 6c 66 2e 69 67 6e 6f 72 65 5f 74 6f 5f self.ignore_to_
11230 73 75 62 63 6f 6d 6d 5f 65 6e 64 28 6f 73 38 5f subcomm_end(os8_
11240 63 6f 6d 6d 2c 20 73 63 72 69 70 74 5f 66 69 6c comm, script_fil
11250 65 2c 20 22 62 75 69 6c 64 22 29 0a 20 20 20 20 e, "build").
11260 20 20 20 20 20 20 23 20 43 6f 6e 66 69 72 6d 20 # Confirm
11270 77 65 27 72 65 20 62 61 63 6b 20 61 74 20 74 68 we're back at th
11280 65 20 6d 6f 6e 69 74 6f 72 20 61 73 20 65 78 70 e monitor as exp
11290 65 63 74 65 64 2e 0a 20 20 20 20 20 20 20 20 20 ected..
112a0 20 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 63 self.simh.os8_c
112b0 66 6d 5f 6d 6f 6e 69 74 6f 72 20 28 22 62 75 69 fm_monitor ("bui
112c0 6c 64 5f 73 75 62 63 6f 6d 6d 20 31 30 22 29 0a ld_subcomm 10").
112d0 20 20 20 20 20 20 20 20 20 20 72 65 74 75 72 6e return
112e0 20 22 66 61 69 6c 22 0a 20 20 20 20 20 20 20 20 "fail".
112f0 23 20 54 6f 20 63 6f 6e 74 69 6e 75 65 2c 20 77 # To continue, w
11300 65 20 6e 65 65 64 20 74 6f 20 61 73 6b 20 70 65 e need to ask pe
11310 78 70 65 63 74 20 74 6f 20 67 65 74 20 74 68 61 xpect to get tha
11320 74 20 42 55 49 4c 44 20 70 72 6f 6d 70 74 20 62 t BUILD prompt b
11330 65 66 6f 72 65 0a 20 20 20 20 20 20 20 20 23 20 efore. #
11340 72 65 73 75 6d 69 6e 67 20 61 66 74 65 72 20 61 resuming after a
11350 6e 20 65 72 72 6f 72 2e 20 49 67 6e 6f 72 65 20 n error. Ignore
11360 65 76 65 72 79 74 68 69 6e 67 20 75 6e 74 69 6c everything until
11370 20 77 65 20 67 65 74 20 69 74 2e 0a 20 20 20 20 we get it..
11380 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 2e 5f 63 self.simh._c
11390 68 69 6c 64 2e 65 78 70 65 63 74 28 22 5c 6e 5c hild.expect("\n\
113a0 5c 24 24 22 29 0a 20 20 20 20 20 20 20 20 0a 20 \$$"). .
113b0 20 20 20 70 72 69 6e 74 28 22 57 61 72 6e 69 6e print("Warnin
113c0 67 20 65 6e 64 20 6f 66 20 66 69 6c 65 20 65 6e g end of file en
113d0 63 6f 75 6e 74 65 72 65 64 20 77 69 74 68 20 6e countered with n
113e0 6f 20 65 6e 64 20 6f 66 20 42 55 49 4c 44 20 63 o end of BUILD c
113f0 6f 6d 6d 61 6e 64 20 62 6c 6f 63 6b 20 61 74 20 ommand block at
11400 6c 69 6e 65 20 22 20 2b 20 5c 0a 20 20 20 20 20 line " + \.
11410 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 str(self.line_c
11420 74 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 2e t_stack[0]) + ".
11430 22 29 0a 20 20 20 20 72 65 74 75 72 6e 20 22 66 "). return "f
11440 61 69 6c 22 0a 0a 0a 20 20 23 23 23 23 20 63 64 ail"... #### cd
11450 70 72 6f 67 5f 73 75 62 63 6f 6d 6d 20 23 23 23 prog_subcomm ###
11460 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
11470 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
11480 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a ###############.
11490 20 20 23 20 43 79 63 6c 65 20 74 68 72 6f 75 67 # Cycle throug
114a0 68 20 4f 53 2f 38 20 63 6f 6d 6d 61 6e 64 20 64 h OS/8 command d
114b0 65 63 6f 64 65 72 20 77 69 74 68 20 74 68 65 20 ecoder with the
114c0 63 6f 6d 6d 61 6e 64 20 73 70 65 63 69 66 69 65 command specifie
114d0 64 0a 20 20 23 20 69 6e 20 74 68 65 20 61 72 67 d. # in the arg
114e0 75 6d 65 6e 74 2e 0a 20 20 0a 20 20 64 65 66 20 ument.. . def
114f0 63 64 70 72 6f 67 5f 73 75 62 63 6f 6d 6d 20 28 cdprog_subcomm (
11500 73 65 6c 66 2c 20 6f 6c 64 5f 6c 69 6e 65 2c 20 self, old_line,
11510 73 63 72 69 70 74 5f 66 69 6c 65 29 3a 0a 20 20 script_file):.
11520 20 20 6f 73 38 5f 63 6f 6d 6d 20 3d 20 22 52 55 os8_comm = "RU
11530 20 22 20 2b 20 6f 6c 64 5f 6c 69 6e 65 0a 20 20 " + old_line.
11540 20 20 65 6e 64 5f 73 74 72 20 3d 20 22 63 64 70 end_str = "cdp
11550 72 6f 67 20 22 20 2b 20 6f 6c 64 5f 6c 69 6e 65 rog " + old_line
11560 0a 20 20 20 20 69 66 20 73 65 6c 66 2e 76 65 72 . if self.ver
11570 62 6f 73 65 3a 0a 20 20 20 20 20 20 70 72 69 6e bose:. prin
11580 74 28 22 4c 69 6e 65 3a 20 22 20 2b 20 73 74 72 t("Line: " + str
11590 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 (self.line_ct_st
115a0 61 63 6b 5b 30 5d 29 20 2b 20 22 3a 20 22 20 2b ack[0]) + ": " +
115b0 20 6f 73 38 5f 63 6f 6d 6d 29 0a 0a 20 20 20 20 os8_comm)..
115c0 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e 73 69 6d reply = self.sim
115d0 68 2e 6f 73 38 5f 63 6d 64 20 28 6f 73 38 5f 63 h.os8_cmd (os8_c
115e0 6f 6d 6d 2c 20 64 65 62 75 67 3d 73 65 6c 66 2e omm, debug=self.
115f0 64 65 62 75 67 29 0a 20 20 20 20 69 66 20 73 65 debug). if se
11600 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 74 65 73 74 lf.simh.os8_test
11610 5f 72 65 73 75 6c 74 20 28 72 65 70 6c 79 2c 20 _result (reply,
11620 22 43 6f 6d 6d 61 6e 64 20 44 65 63 6f 64 65 72 "Command Decoder
11630 20 50 72 6f 6d 70 74 22 2c 20 22 63 64 70 72 6f Prompt", "cdpro
11640 67 3a 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 20 g: " + \.
11650 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
11660 20 20 20 20 20 20 20 20 20 20 20 6f 73 38 5f 63 os8_c
11670 6f 6d 6d 2c 20 64 65 62 75 67 3d 73 65 6c 66 2e omm, debug=self.
11680 64 65 62 75 67 29 20 3d 3d 20 46 61 6c 73 65 3a debug) == False:
11690 0a 20 20 20 20 20 20 70 72 69 6e 74 20 28 22 20 . print ("
116a0 66 61 69 6c 65 64 20 61 74 20 4c 69 6e 65 20 22 failed at Line "
116b0 20 2b 20 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 + str(self.line
116c0 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 29 0a 20 _ct_stack[0])).
116d0 20 20 20 20 20 70 72 69 6e 74 20 28 22 49 67 6e print ("Ign
116e0 6f 72 69 6e 67 20 74 68 65 20 72 65 73 74 20 6f oring the rest o
116f0 66 20 74 68 69 73 20 62 6c 6f 63 6b 2e 22 29 0a f this block.").
11700 20 20 20 20 20 20 73 65 6c 66 2e 69 67 6e 6f 72 self.ignor
11710 65 5f 74 6f 5f 73 75 62 63 6f 6d 6d 5f 65 6e 64 e_to_subcomm_end
11720 28 6f 73 38 5f 63 6f 6d 6d 2c 20 73 63 72 69 70 (os8_comm, scrip
11730 74 5f 66 69 6c 65 2c 20 65 6e 64 5f 73 74 72 29 t_file, end_str)
11740 0a 20 20 20 20 20 20 23 20 43 6f 6e 66 69 72 6d . # Confirm
11750 20 77 65 27 72 65 20 62 61 63 6b 20 74 6f 20 6d we're back to m
11760 6f 6e 69 74 6f 72 20 63 6f 6d 6d 61 6e 64 20 6c onitor command l
11770 65 76 65 6c 2e 0a 20 20 20 20 20 20 73 65 6c 66 evel.. self
11780 2e 73 69 6d 68 2e 6f 73 38 5f 63 66 6d 5f 6d 6f .simh.os8_cfm_mo
11790 6e 69 74 6f 72 20 28 22 63 64 70 72 6f 67 20 4f nitor ("cdprog O
117a0 53 2f 38 20 72 65 73 74 61 72 74 20 61 66 74 65 S/8 restart afte
117b0 72 20 66 61 69 6c 65 64 20 52 55 20 63 6f 6d 6d r failed RU comm
117c0 61 6e 64 22 29 0a 20 20 20 20 20 20 72 65 74 75 and"). retu
117d0 72 6e 20 22 66 61 69 6c 22 0a 0a 20 20 20 20 23 rn "fail".. #
117e0 20 53 75 62 6d 69 74 20 74 68 65 20 6c 69 6e 65 Submit the line
117f0 73 20 66 72 6f 6d 20 73 63 72 69 70 74 20 66 69 s from script fi
11800 6c 65 20 74 6f 20 74 68 65 20 72 75 6e 6e 69 6e le to the runnin
11810 67 20 63 6f 6d 6d 61 6e 64 2e 0a 20 20 20 20 23 g command.. #
11820 20 54 72 61 63 6b 20 77 68 65 74 68 65 72 20 77 Track whether w
11830 65 20 72 65 74 75 72 6e 20 74 6f 20 74 68 65 20 e return to the
11840 43 6f 6d 6e 61 6e 64 20 44 65 63 6f 64 65 72 20 Comnand Decoder
11850 66 6f 72 20 6d 6f 72 65 20 6f 72 20 65 78 69 74 for more or exit
11860 2e 0a 20 20 20 20 23 20 54 72 61 63 6b 20 77 68 .. # Track wh
11870 65 74 68 65 72 20 77 65 20 6e 65 65 64 20 74 6f ether we need to
11880 20 65 78 69 74 20 61 6e 64 20 69 67 6e 6f 72 65 exit and ignore
11890 20 74 68 65 20 72 65 73 74 20 6f 66 20 74 68 65 the rest of the
118a0 20 62 6c 6f 63 6b 2e 0a 20 20 20 20 66 6f 72 20 block.. for
118b0 6c 69 6e 65 20 69 6e 20 73 63 72 69 70 74 5f 66 line in script_f
118c0 69 6c 65 3a 0a 20 20 20 20 20 20 6c 69 6e 65 20 ile:. line
118d0 3d 20 73 65 6c 66 2e 62 61 73 69 63 5f 6c 69 6e = self.basic_lin
118e0 65 5f 70 61 72 73 65 28 6c 69 6e 65 2c 20 73 63 e_parse(line, sc
118f0 72 69 70 74 5f 66 69 6c 65 29 0a 20 20 20 20 20 ript_file).
11900 20 69 66 20 6c 69 6e 65 20 3d 3d 20 4e 6f 6e 65 if line == None
11910 3a 20 63 6f 6e 74 69 6e 75 65 0a 20 20 0a 20 20 : continue. .
11920 20 20 20 20 23 20 54 65 73 74 20 66 6f 72 20 73 # Test for s
11930 70 65 63 69 61 6c 20 63 61 73 65 2c 20 22 65 6e pecial case, "en
11940 64 22 20 61 6e 64 20 61 63 74 20 6f 6e 20 69 74 d" and act on it
11950 20 69 66 20 70 72 65 73 65 6e 74 2e 0a 20 20 20 if present..
11960 20 20 20 6d 20 3d 20 72 65 2e 6d 61 74 63 68 28 m = re.match(
11970 5f 63 6f 6d 6d 5f 72 65 2c 20 6c 69 6e 65 29 0a _comm_re, line).
11980 20 20 20 20 20 20 69 66 20 6d 20 21 3d 20 4e 6f if m != No
11990 6e 65 20 61 6e 64 20 6d 2e 67 72 6f 75 70 28 31 ne and m.group(1
119a0 29 20 21 3d 20 4e 6f 6e 65 20 61 6e 64 20 6d 2e ) != None and m.
119b0 67 72 6f 75 70 28 31 29 20 21 3d 20 22 22 20 61 group(1) != "" a
119c0 6e 64 20 6d 2e 67 72 6f 75 70 28 31 29 20 20 3d nd m.group(1) =
119d0 3d 20 22 65 6e 64 22 3a 0a 20 20 20 20 20 20 20 = "end":.
119e0 20 72 65 73 74 20 3d 20 6d 2e 67 72 6f 75 70 28 rest = m.group(
119f0 33 29 0a 20 20 20 20 20 20 20 20 72 65 74 76 61 3). retva
11a00 6c 20 3d 20 22 66 61 69 6c 22 20 20 23 20 52 65 l = "fail" # Re
11a10 74 75 72 6e 20 66 61 69 6c 20 75 6e 6c 65 73 73 turn fail unless
11a20 20 70 72 6f 76 65 6e 20 73 75 63 63 65 73 73 66 proven successf
11a30 75 6c 2e 0a 20 20 20 20 20 20 20 20 69 66 20 72 ul.. if r
11a40 65 73 74 20 3d 3d 20 4e 6f 6e 65 20 6f 72 20 72 est == None or r
11a50 65 73 74 20 3d 3d 20 22 22 3a 0a 20 20 20 20 20 est == "":.
11a60 20 20 20 20 20 70 72 69 6e 74 28 22 57 61 72 6e print("Warn
11a70 69 6e 67 21 20 65 6e 64 20 73 74 61 74 65 6d 65 ing! end stateme
11a80 6e 74 20 65 6e 63 6f 75 6e 74 65 72 65 64 20 69 nt encountered i
11a90 6e 73 69 64 65 20 63 64 70 72 6f 67 20 22 20 2b nside cdprog " +
11aa0 20 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 \.
11ab0 20 22 77 69 74 68 20 6e 6f 20 61 72 67 75 6d 65 "with no argume
11ac0 6e 74 20 61 74 20 6c 69 6e 65 20 22 20 2b 20 5c nt at line " + \
11ad0 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 73 . s
11ae0 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 5f tr(self.line_ct_
11af0 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 2e 22 29 stack[0]) + ".")
11b00 0a 20 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 . print
11b10 28 22 45 78 70 65 63 74 69 6e 67 3a 20 7b 22 20 ("Expecting: {"
11b20 2b 20 65 6e 64 5f 73 74 72 20 2b 20 22 7d 2e 22 + end_str + "}."
11b30 29 0a 20 20 20 20 20 20 20 20 65 6c 69 66 20 72 ). elif r
11b40 65 73 74 20 21 3d 20 65 6e 64 5f 73 74 72 3a 0a est != end_str:.
11b50 20 20 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 print(
11b60 22 57 61 72 6e 69 6e 67 21 20 4d 69 73 6d 61 74 "Warning! Mismat
11b70 63 68 65 64 20 62 65 67 69 6e 2f 65 6e 64 20 62 ched begin/end b
11b80 6c 6f 63 6b 73 20 69 6e 20 63 64 70 72 6f 67 20 locks in cdprog
11b90 61 74 20 6c 69 6e 65 20 22 20 2b 20 5c 0a 20 20 at line " + \.
11ba0 20 20 20 20 20 20 20 20 20 20 73 74 72 28 73 65 str(se
11bb0 6c 66 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b lf.line_ct_stack
11bc0 5b 30 5d 29 20 2b 20 22 2e 5c 6e 22 29 0a 20 20 [0]) + ".\n").
11bd0 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 45 print("E
11be0 78 70 65 63 74 69 6e 67 3a 20 7b 22 20 2b 20 65 xpecting: {" + e
11bf0 6e 64 5f 73 74 72 20 2b 20 22 7d 2e 20 47 6f 74 nd_str + "}. Got
11c00 3a 20 7b 22 20 2b 20 72 65 73 74 20 2b 20 22 7d : {" + rest + "}
11c10 2e 5c 6e 22 29 0a 20 20 20 20 20 20 20 20 65 6c .\n"). el
11c20 73 65 3a 0a 20 20 20 20 20 20 20 20 20 20 72 65 se:. re
11c30 74 76 61 6c 20 3d 20 22 73 75 63 63 65 73 73 22 tval = "success"
11c40 0a 20 20 20 20 20 20 20 20 20 20 69 66 20 73 65 . if se
11c50 6c 66 2e 76 65 72 62 6f 73 65 3a 0a 20 20 20 20 lf.verbose:.
11c60 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 4c print("L
11c70 69 6e 65 20 22 20 2b 20 73 74 72 28 73 65 6c 66 ine " + str(self
11c80 2e 6c 69 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 .line_ct_stack[0
11c90 5d 29 20 2b 20 22 3a 20 65 6e 64 20 22 20 2b 20 ]) + ": end " +
11ca0 65 6e 64 5f 73 74 72 29 0a 20 20 20 20 20 20 20 end_str).
11cb0 20 69 66 20 72 65 74 76 61 6c 20 3d 3d 20 22 66 if retval == "f
11cc0 61 69 6c 22 3a 0a 20 20 20 20 20 20 20 20 20 20 ail":.
11cd0 70 72 69 6e 74 28 22 45 78 69 74 69 6e 67 20 63 print("Exiting c
11ce0 64 70 72 6f 67 2c 20 70 6f 73 73 69 62 6c 79 20 dprog, possibly
11cf0 65 61 72 6c 69 65 72 20 74 68 61 6e 20 65 78 70 earlier than exp
11d00 65 63 74 65 64 20 61 74 20 6c 69 6e 65 20 22 20 ected at line "
11d10 2b 20 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20 + \.
11d20 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 str(self.line_ct
11d30 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 22 2e 22 _stack[0]) + "."
11d40 29 0a 20 20 20 20 20 20 20 20 23 20 52 65 74 75 ). # Retu
11d50 72 6e 20 74 6f 20 4d 6f 6e 69 74 6f 72 0a 20 20 rn to Monitor.
11d60 20 20 20 20 20 20 72 65 70 6c 79 20 3d 20 73 65 reply = se
11d70 6c 66 2e 73 69 6d 68 2e 6f 73 38 5f 65 73 63 61 lf.simh.os8_esca
11d80 70 65 20 28 63 61 6c 6c 65 72 3d 22 53 65 6e 64 pe (caller="Send
11d90 69 6e 67 20 65 73 63 61 70 65 20 66 61 69 6c 65 ing escape faile
11da0 64 2e 20 54 72 79 69 6e 67 20 5e 63 22 29 0a 20 d. Trying ^c").
11db0 20 20 20 20 20 20 20 73 65 6c 66 2e 73 69 6d 68 self.simh
11dc0 2e 6f 73 38 5f 63 74 72 6c 5f 63 20 28 22 63 64 .os8_ctrl_c ("cd
11dd0 70 72 6f 67 3a 20 5e 63 20 66 61 69 6c 65 64 2e prog: ^c failed.
11de0 20 53 74 61 74 65 20 6d 61 63 68 69 6e 65 20 77 State machine w
11df0 69 6c 6c 20 62 65 20 63 6f 6e 66 75 73 65 64 2e ill be confused.
11e00 22 29 0a 20 20 20 20 20 20 20 20 72 65 74 75 72 "). retur
11e10 6e 20 72 65 74 76 61 6c 0a 20 20 0a 20 20 20 20 n retval. .
11e20 20 20 23 20 57 65 20 63 6f 75 6c 64 20 64 6f 20 # We could do
11e30 73 6f 6d 65 20 62 61 73 69 63 20 4f 53 2f 38 20 some basic OS/8
11e40 63 6f 6d 6d 61 6e 64 20 64 65 63 6f 64 65 72 20 command decoder
11e50 73 79 6e 61 78 20 63 68 65 63 6b 69 6e 67 20 68 synax checking h
11e60 65 72 65 2e 0a 20 20 20 20 20 20 69 66 20 73 65 ere.. if se
11e70 6c 66 2e 76 65 72 62 6f 73 65 3a 0a 20 20 20 20 lf.verbose:.
11e80 20 20 20 20 70 72 69 6e 74 28 22 4c 69 6e 65 3a print("Line:
11e90 20 22 20 2b 20 73 74 72 28 73 65 6c 66 2e 6c 69 " + str(self.li
11ea0 6e 65 5f 63 74 5f 73 74 61 63 6b 5b 30 5d 29 20 ne_ct_stack[0])
11eb0 2b 20 22 3a 20 2a 20 22 20 2b 20 6c 69 6e 65 29 + ": * " + line)
11ec0 0a 20 20 20 20 20 20 20 20 70 72 69 6e 74 28 22 . print("
11ed0 53 65 6e 64 69 6e 67 2e 2e 2e 22 29 0a 20 20 20 Sending...").
11ee0 20 20 20 72 65 70 6c 79 20 3d 20 73 65 6c 66 2e reply = self.
11ef0 73 69 6d 68 2e 6f 73 38 5f 63 6d 64 20 28 6c 69 simh.os8_cmd (li
11f00 6e 65 29 0a 20 20 20 20 20 20 69 66 20 73 65 6c ne). if sel
11f10 66 2e 64 65 62 75 67 3a 0a 20 20 20 20 20 20 20 f.debug:.
11f20 20 70 72 69 6e 74 20 28 22 63 64 70 72 6f 67 20 print ("cdprog
11f30 73 65 6e 74 20 6c 69 6e 65 2e 20 47 6f 74 20 72 sent line. Got r
11f40 65 70 6c 79 3a 20 22 20 2b 20 73 74 72 28 72 65 eply: " + str(re
11f50 70 6c 79 29 20 2b 20 22 20 2d 3e 20 22 20 2b 20 ply) + " -> " +
11f60 5c 0a 20 20 20 20 20 20 20 20 20 20 20 20 20 20 \.
11f70 20 73 65 6c 66 2e 73 69 6d 68 2e 5f 6f 73 38 5f self.simh._os8_
11f80 72 65 70 6c 69 65 73 20 5b 72 65 70 6c 79 5d 5b replies [reply][
11f90 30 5d 29 0a 0a 20 20 20 20 20 20 23 20 54 72 61 0]).. # Tra
11fa0 6e 73 63 72 69 62 65 20 6f 75 72 20 6f 75 74 70 nscribe our outp
11fb0 75 74 20 69 66 20 64 65 73 69 72 65 64 2e 0a 20 ut if desired..
11fc0 20 20 20 20 20 69 66 20 22 74 72 61 6e 73 63 72 if "transcr
11fd0 69 70 74 22 20 69 6e 20 73 65 6c 66 2e 6f 70 74 ipt" in self.opt
11fe0 69 6f 6e 73 5f 65 6e 61 62 6c 65 64 3a 0a 20 20 ions_enabled:.
11ff0 20 20 20 20 20 20 70 72 69 6e 74 20 28 73 65 6c print (sel
12000 66 2e 73 69 6d 68 2e 5f 63 68 69 6c 64 2e 62 65 f.simh._child.be
12010 66 6f 72 65 2e 64 65 63 6f 64 65 28 29 2e 73 74 fore.decode().st
12020 72 69 70 28 29 29 0a 0a 20 20 20 20 20 20 6d 6f rip()).. mo
12030 6e 20 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 n = self.simh.os
12040 38 5f 74 65 73 74 5f 72 65 73 75 6c 74 28 72 65 8_test_result(re
12050 70 6c 79 2c 20 22 4d 6f 6e 69 74 6f 72 20 50 72 ply, "Monitor Pr
12060 6f 6d 70 74 22 2c 20 22 22 29 0a 20 20 20 20 20 ompt", "").
12070 20 63 64 20 20 3d 20 73 65 6c 66 2e 73 69 6d 68 cd = self.simh
12080 2e 6f 73 38 5f 74 65 73 74 5f 72 65 73 75 6c 74 .os8_test_result
12090 28 72 65 70 6c 79 2c 20 22 43 6f 6d 6d 61 6e 64 (reply, "Command
120a0 20 44 65 63 6f 64 65 72 20 50 72 6f 6d 70 74 22 Decoder Prompt"
120b0 2c 20 22 22 29 0a 20 20 20 20 20 20 69 66 20 6d , ""). if m
120c0 6f 6e 3a 0a 20 20 20 20 20 20 20 20 23 20 43 61 on:. # Ca
120d0 73 65 20 6f 66 20 63 6f 6d 6d 61 6e 64 20 72 75 se of command ru
120e0 6e 6e 69 6e 67 20 74 6f 20 63 6f 6d 70 6c 65 74 nning to complet
120f0 69 6f 6e 20 61 6e 64 20 72 65 74 75 72 6e 69 6e ion and returnin
12100 67 20 74 6f 20 4f 53 2f 38 0a 20 20 20 20 20 20 g to OS/8.
12110 20 20 23 20 43 6c 65 61 6e 20 75 70 20 74 68 65 # Clean up the
12120 20 70 61 72 73 65 20 74 6f 20 74 68 65 20 65 6e parse to the en
12130 64 20 6f 66 20 74 68 65 20 62 6c 6f 63 6b 20 61 d of the block a
12140 6e 64 20 72 65 74 75 72 6e 20 73 75 63 63 65 73 nd return succes
12150 73 2e 0a 20 20 20 20 20 20 20 20 73 65 6c 66 2e s.. self.
12160 69 67 6e 6f 72 65 5f 74 6f 5f 73 75 62 63 6f 6d ignore_to_subcom
12170 6d 5f 65 6e 64 28 6f 73 38 5f 63 6f 6d 6d 2c 20 m_end(os8_comm,
12180 73 63 72 69 70 74 5f 66 69 6c 65 2c 20 65 6e 64 script_file, end
12190 5f 73 74 72 29 0a 20 20 20 20 20 20 20 20 72 65 _str). re
121a0 74 75 72 6e 20 22 73 75 63 63 65 73 73 22 0a 20 turn "success".
121b0 20 20 20 20 20 65 6c 69 66 20 6e 6f 74 20 63 64 elif not cd
121c0 3a 0a 20 20 20 20 20 20 20 20 23 20 57 65 20 64 :. # We d
121d0 69 64 6e 27 74 20 72 65 74 75 72 6e 20 74 6f 20 idn't return to
121e0 63 6f 6d 6d 61 6e 64 20 64 65 63 6f 64 65 72 2e command decoder.
121f0 20 20 54 68 61 74 20 6d 65 61 6e 73 20 77 65 20 That means we
12200 68 61 76 65 20 61 6e 20 65 72 72 6f 72 2e 0a 20 have an error..
12210 20 20 20 20 20 20 20 23 20 54 65 73 74 20 74 68 # Test th
12220 65 20 66 61 74 61 6c 20 62 69 74 20 69 6e 20 74 e fatal bit in t
12230 68 65 20 65 72 72 6f 72 20 73 74 72 75 63 74 75 he error structu
12240 72 65 2e 0a 20 20 20 20 20 20 20 20 23 20 49 46 re.. # IF
12250 20 54 72 75 65 3a 20 77 65 20 72 65 74 75 72 6e True: we return
12260 65 64 20 74 6f 20 4f 53 2f 38 2e 20 53 61 79 20 ed to OS/8. Say
12270 77 65 27 72 65 20 69 67 6e 6f 72 69 6e 67 20 74 we're ignoring t
12280 68 65 20 62 6c 6f 63 6b 20 61 6e 64 20 72 65 74 he block and ret
12290 75 72 6e 20 66 61 69 6c 75 72 65 2e 0a 20 20 20 urn failure..
122a0 20 20 20 20 20 23 20 4f 74 68 65 72 77 69 73 65 # Otherwise
122b0 20 77 65 20 73 68 6f 75 6c 64 20 63 6f 6e 74 69 we should conti
122c0 6e 75 65 2e 0a 20 20 20 20 20 20 20 20 69 66 20 nue.. if
122d0 73 65 6c 66 2e 73 69 6d 68 2e 5f 6f 73 38 5f 72 self.simh._os8_r
122e0 65 70 6c 69 65 73 5b 72 65 70 6c 79 5d 5b 32 5d eplies[reply][2]
122f0 20 3d 3d 20 54 72 75 65 3a 0a 20 20 20 20 20 20 == True:.
12300 20 20 20 20 70 72 69 6e 74 20 28 22 46 61 74 61 print ("Fata
12310 6c 20 65 72 72 6f 72 2e 20 49 67 6e 6f 72 69 6e l error. Ignorin
12320 67 20 72 65 73 74 20 6f 66 20 74 68 69 73 20 62 g rest of this b
12330 6c 6f 63 6b 2e 22 29 0a 20 20 20 20 20 20 20 20 lock.").
12340 20 20 73 65 6c 66 2e 69 67 6e 6f 72 65 5f 74 6f self.ignore_to
12350 5f 73 75 62 63 6f 6d 6d 5f 65 6e 64 28 6f 73 38 _subcomm_end(os8
12360 5f 63 6f 6d 6d 2c 20 73 63 72 69 70 74 5f 66 69 _comm, script_fi
12370 6c 65 2c 20 65 6e 64 5f 73 74 72 29 0a 20 20 20 le, end_str).
12380 20 20 20 20 20 20 20 23 20 50 72 69 6e 74 20 65 # Print e
12390 72 72 6f 72 20 6d 65 73 73 61 67 65 2e 0a 20 20 rror message..
123a0 20 20 20 20 20 20 20 20 73 65 6c 66 2e 73 69 6d self.sim
123b0 68 2e 6f 73 38 5f 74 65 73 74 5f 72 65 73 75 6c h.os8_test_resul
123c0 74 28 72 65 70 6c 79 2c 20 22 43 6f 6d 6d 61 6e t(reply, "Comman
123d0 64 20 44 65 63 6f 64 65 72 20 50 72 6f 6d 70 74 d Decoder Prompt
123e0 22 2c 20 22 63 64 70 72 6f 67 20 66 61 69 6c 75 ", "cdprog failu
123f0 72 65 22 29 0a 20 20 20 20 20 20 20 20 20 20 23 re"). #
12400 20 43 6f 6e 66 69 72 6d 20 77 65 27 72 65 20 62 Confirm we're b
12410 61 63 6b 20 61 74 20 4d 6f 6e 69 74 6f 72 0a 20 ack at Monitor.
12420 20 20 20 20 20 20 20 20 20 73 65 6c 66 2e 73 69 self.si
12430 6d 68 2e 6f 73 38 5f 63 66 6d 5f 6d 6f 6e 69 74 mh.os8_cfm_monit
12440 6f 72 20 28 22 63 64 70 72 6f 67 20 65 72 72 6f or ("cdprog erro
12450 72 20 68 61 6e 64 6c 65 72 20 72 65 74 75 72 6e r handler return
12460 20 74 6f 20 6d 6f 6e 69 74 6f 72 20 66 61 69 6c to monitor fail
12470 22 29 0a 20 20 20 20 20 20 20 20 20 20 72 65 74 "). ret
12480 75 72 6e 20 22 66 61 69 6c 22 0a 20 20 20 20 20 urn "fail".
12490 20 20 20 65 6c 73 65 3a 0a 20 20 20 20 20 20 20 else:.
124a0 20 20 20 70 72 69 6e 74 20 28 22 4e 6f 6e 2d 66 print ("Non-f
124b0 61 74 61 6c 20 65 72 72 6f 72 20 65 6e 63 6f 75 atal error encou
124c0 6e 74 65 72 65 64 20 77 69 74 68 3a 20 22 20 2b ntered with: " +
124d0 20 6c 69 6e 65 29 0a 20 20 20 20 20 20 20 20 20 line).
124e0 20 70 72 69 6e 74 20 28 22 5c 74 22 20 2b 20 73 print ("\t" + s
124f0 65 6c 66 2e 73 69 6d 68 2e 5f 6f 73 38 5f 72 65 elf.simh._os8_re
12500 70 6c 69 65 73 5b 72 65 70 6c 79 5d 5b 30 5d 29 plies[reply][0])
12510 0a 20 20 20 20 20 20 20 20 20 20 23 20 54 6f 20 . # To
12520 63 6f 6e 74 69 6e 75 65 2c 20 77 65 20 6e 65 65 continue, we nee
12530 64 20 74 6f 20 61 73 6b 20 70 65 78 70 65 63 74 d to ask pexpect
12540 20 74 6f 20 67 65 74 20 74 68 61 74 20 43 6f 6d to get that Com
12550 6d 61 6e 64 20 44 65 63 6f 64 65 72 0a 20 20 20 mand Decoder.
12560 20 20 20 20 20 20 20 23 20 70 72 6f 6d 70 74 20 # prompt
12570 62 65 66 6f 72 65 20 72 65 73 75 6d 69 6e 67 20 before resuming
12580 61 66 74 65 72 20 61 6e 20 65 72 72 6f 72 2e 20 after an error.
12590 49 67 6e 6f 72 65 20 65 76 65 72 79 74 68 69 6e Ignore everythin
125a0 67 20 75 6e 74 69 6c 20 77 65 20 67 65 74 20 69 g until we get i
125b0 74 2e 0a 20 20 20 20 20 20 20 20 20 20 73 65 6c t.. sel
125c0 66 2e 73 69 6d 68 2e 5f 63 68 69 6c 64 2e 65 78 f.simh._child.ex
125d0 70 65 63 74 28 22 5c 6e 5c 5c 2a 24 22 29 0a 20 pect("\n\\*$").
125e0 20 20 20 70 72 69 6e 74 28 22 57 61 72 6e 69 6e print("Warnin
125f0 67 20 65 6e 64 20 6f 66 20 66 69 6c 65 20 65 6e g end of file en
12600 63 6f 75 6e 74 65 72 65 64 20 61 74 20 6c 69 6e countered at lin
12610 65 20 22 20 2b 20 5c 0a 20 20 20 20 20 20 20 20 e " + \.
12620 73 74 72 28 73 65 6c 66 2e 6c 69 6e 65 5f 63 74 str(self.line_ct
12630 5f 73 74 61 63 6b 5b 30 5d 29 20 2b 20 5c 0a 20 _stack[0]) + \.
12640 20 20 20 20 20 20 20 22 20 77 69 74 68 20 6e 6f " with no
12650 20 65 6e 64 20 6f 66 20 63 64 70 72 6f 67 20 63 end of cdprog c
12660 6f 6d 6d 61 6e 64 20 62 6c 6f 63 6b 2e 22 29 0a ommand block.").
12670 20 20 20 20 23 20 45 78 69 74 20 63 6f 6d 6d 61 # Exit comma
12680 6e 64 20 62 61 63 6b 20 74 6f 20 4f 53 2f 38 20 nd back to OS/8
12690 6d 6f 6e 69 74 6f 72 2e 0a 20 20 20 20 6d 6f 6e monitor.. mon
126a0 20 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 38 = self.simh.os8
126b0 5f 65 73 63 61 70 65 20 28 22 22 29 0a 20 20 20 _escape ("").
126c0 20 69 66 20 6d 6f 6e 3a 20 72 65 74 75 72 6e 20 if mon: return
126d0 22 66 61 69 6c 22 0a 20 20 20 20 65 6c 73 65 3a "fail". else:
126e0 0a 20 20 20 20 20 20 70 72 69 6e 74 20 28 22 63 . print ("c
126f0 64 70 72 6f 67 3a 20 45 73 63 61 70 65 20 66 72 dprog: Escape fr
12700 6f 6d 20 43 6f 6d 6d 61 6e 64 20 44 65 63 6f 64 om Command Decod
12710 65 72 20 66 61 69 6c 65 64 2e 20 53 65 6e 64 69 er failed. Sendi
12720 6e 67 20 5e 63 22 29 0a 20 20 20 20 20 20 6d 6f ng ^c"). mo
12730 6e 20 3d 20 73 65 6c 66 2e 73 69 6d 68 2e 6f 73 n = self.simh.os
12740 38 5f 63 74 72 6c 5f 63 20 28 22 22 29 0a 20 20 8_ctrl_c ("").
12750 20 20 20 20 69 66 20 6d 6f 6e 3a 20 72 65 74 75 if mon: retu
12760 72 6e 20 22 66 61 69 6c 22 0a 20 20 20 20 20 20 rn "fail".
12770 65 6c 73 65 3a 0a 20 20 20 20 20 20 20 20 70 72 else:. pr
12780 69 6e 74 20 28 22 46 61 69 6c 65 64 20 74 6f 20 int ("Failed to
12790 67 65 74 20 74 6f 20 6d 6f 6e 69 74 6f 72 20 77 get to monitor w
127a0 69 74 68 20 5e 63 2e 20 4b 69 6c 6c 69 6e 67 20 ith ^c. Killing
127b0 73 63 72 69 70 74 2e 22 29 0a 20 20 20 20 20 20 script.").
127c0 20 20 72 65 74 75 72 6e 20 22 64 69 65 22 0a 0a return "die"..
127d0 0a 20 20 23 23 23 23 20 63 68 65 63 6b 5f 65 78 . #### check_ex
127e0 69 73 74 73 20 23 23 23 23 23 23 23 23 23 23 23 ists ###########
127f0 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
12800 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
12810 23 23 23 23 23 23 23 23 23 0a 20 20 23 20 43 68 #########. # Ch
12820 65 63 6b 20 65 78 69 73 74 65 6e 63 65 20 6f 66 eck existence of
12830 20 61 6c 6c 20 66 69 6c 65 73 20 6e 65 65 64 65 all files neede
12840 64 0a 20 20 0a 20 20 64 65 66 20 63 68 65 63 6b d. . def check
12850 5f 65 78 69 73 74 73 20 28 73 2c 20 69 6d 61 67 _exists (s, imag
12860 65 5f 63 6f 70 79 69 6e 73 29 3a 0a 20 20 20 20 e_copyins):.
12870 66 6f 72 20 63 6f 70 79 69 6e 20 69 6e 20 69 6d for copyin in im
12880 61 67 65 5f 63 6f 70 79 69 6e 73 3a 0a 20 20 20 age_copyins:.
12890 20 20 20 69 6d 61 67 65 20 3d 20 63 6f 70 79 69 image = copyi
128a0 6e 5b 31 5d 0a 20 20 20 20 20 20 69 6d 61 67 65 n[1]. image
128b0 5f 70 61 74 68 20 3d 20 64 69 72 73 2e 6f 73 38 _path = dirs.os8
128c0 6d 69 20 2b 20 69 6d 61 67 65 0a 20 20 20 20 20 mi + image.
128d0 20 69 66 20 28 6e 6f 74 20 6f 73 2e 70 61 74 68 if (not os.path
128e0 2e 69 73 66 69 6c 65 28 69 6d 61 67 65 5f 70 61 .isfile(image_pa
128f0 74 68 29 29 3a 0a 20 20 20 20 20 20 20 20 20 20 th)):.
12900 70 72 69 6e 74 28 22 52 65 71 75 69 72 65 64 20 print("Required
12910 66 69 6c 65 3a 20 22 20 2b 20 69 6d 61 67 65 5f file: " + image_
12920 70 61 74 68 20 2b 20 22 20 6e 6f 74 20 66 6f 75 path + " not fou
12930 6e 64 2e 22 29 0a 20 20 20 20 20 20 20 20 20 20 nd.").
12940 6d 6b 6f 73 38 5f 61 62 6f 72 74 28 73 29 0a 20 mkos8_abort(s).
12950 20 20 20 20 20 23 20 65 6c 73 65 3a 20 70 72 69 # else: pri
12960 6e 74 28 22 46 6f 75 6e 64 20 22 20 2b 20 69 6d nt("Found " + im
12970 61 67 65 5f 70 61 74 68 29 0a age_path).