/usr/lib/python2.7/dist-packages/SimPy/stepping.py is in python-simpy 2.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | # coding=utf-8
"""
This is a small utility for interactively stepping through a simulation.
Usage:
import stepping
(simulation model)
stepping.stepping(Globals) # instead of 'simulate(until = endtime)
"""
import sys
def stepping(glob):
asim = glob.sim
help = {'s':"next event",'r':"run to end",'e':"end run",
'<time>':"skip to event at <time>",'l':"show eventlist",
'p<name>':"skip to event for <name>",'h':"help"}
evlist = asim._timestamps
while True:
if not evlist:
print("No more events at t=%s"%asim.now())
break
tEvt = evlist[0][0]
who = evlist[0][2]
while evlist[0][3]: #skip cancelled event notices
step()
print("\nTime now: %s, next event at: t=%s for process: %s "\
%(asim.now(),tEvt,who.name))
while True:
if sys.version_info.major == 2:
input = raw_input
cmd = input("Command ('h' for help): ")
if cmd == "h":
for i in help:
print(i, ":", help[i])
else:
break
try:
nexttime = float(cmd)
while asim.peek() < nexttime:
asim.step()
except:
if cmd == 's':
asim.step()
elif cmd == 'r':
while evlist:
asim.step()
print("Run ended at t=%s"%asim.now())
break
elif cmd == 'e':
asim.stopSimulation()
break
elif cmd == 'l':
print("Events scheduled: \n%s"%asim.allEventNotices())
elif cmd[0] == 'p':
while evlist and evlist[0][2].name != cmd[1:]:
asim.step()
else:
print("%s not a valid command" % cmd)
|