119 lines
4.6 KiB
Python
Executable file
119 lines
4.6 KiB
Python
Executable file
#!/usr/bin/python3
|
|
# -*- coding: utf-8 -*-
|
|
#
|
|
# Script use to simulate opennel program (input/output terminal)
|
|
# Copyright (C) 2017 AleaJactaEst
|
|
#
|
|
# This program is free software: you can redistribute it and/or modify
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU Affero General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
import argparse
|
|
import sys
|
|
import time
|
|
import signal
|
|
|
|
|
|
class ManageSignal:
|
|
|
|
def __init__(self):
|
|
self.kill_now = False
|
|
|
|
def activate(self):
|
|
signal.signal(signal.SIGINT, self.exit_gracefully)
|
|
signal.signal(signal.SIGTERM, self.exit_gracefully)
|
|
|
|
def exit_gracefully(self,signum, frame):
|
|
self.kill_now = True
|
|
|
|
|
|
class SimulateProgram():
|
|
def __init__(self):
|
|
self.line = 0
|
|
|
|
def print_output(self, message):
|
|
self.line += 1
|
|
print(self.line, message)
|
|
|
|
def main(self, noloop, timeout, refuse_kill, pos):
|
|
self.print_output("Initializing")
|
|
manageSignal = ManageSignal()
|
|
if refuse_kill:
|
|
manageSignal.activate()
|
|
loop = not noloop
|
|
self.print_output("Initializing")
|
|
self.print_output("Starting")
|
|
self.print_output("Started")
|
|
self.print_output("pos: %d" % pos)
|
|
n = 0
|
|
if pos > n:
|
|
self.print_output("alpha egs_plinfo EGS-132 : LOADED User '2' Character 'Kezxaa(Lirria)' from BS stream file 'characters/002/account_2_0_pdr.bin'")
|
|
n = n + 1
|
|
if pos > n:
|
|
self.print_output("alpha egs_plinfo EGS-132 : LOADED User '2' Character 'Puskle(Lirria)' from BS stream file 'characters/002/account_2_1_pdr.bin'")
|
|
n = n + 1
|
|
if pos > n:
|
|
self.print_output("alpha egs_ecinfo EGS-132 : setActiveCharForPlayer EGS-132 : set active char 1 for player 2")
|
|
n = n + 1
|
|
if pos > n:
|
|
self.print_output("alpha egs_ecinfo EGS-132 : Mapping UID 2 => Sid (0x0000000021:00:00:81) ")
|
|
n = n + 1
|
|
if pos > n:
|
|
self.print_output("alpha egs_ecinfo EGS-132 : Client ready (entity (0x0000000021:00:00:81) (Row 90501) added to mirror)")
|
|
n = n + 1
|
|
if pos > n:
|
|
self.print_output("alpha finalizeClientReady EGS-132 : Updating IS_NEWBIE flag for character: (0x0000000021:00:00:81)")
|
|
n = n + 1
|
|
if pos > n:
|
|
self.print_output("cbClientAdmin EGS-136 : ADMIN: Player (0x0000000021:00:00:81) doesn't have privilege to execute the client admin command 'infos'")
|
|
n = n + 1
|
|
if pos > n:
|
|
self.print_output("cbClientAdmin EGS-136 : ADMIN: Player (0x0000000021:00:00:81) tried to execute a no valid client admin command 'INFO'")
|
|
n = n + 1
|
|
if pos > n:
|
|
self.print_output("alpha 1383 disconnectPlayer EGS-132 : (EGS) player 2 (Row 90501) removed")
|
|
n = n + 1
|
|
if pos > n:
|
|
self.print_output("alpha egs_plinfo EGS-132 : Player with userId = 2 removed")
|
|
n = n + 1
|
|
if pos > n:
|
|
self.print_output("alpha disconnectPlayer EGS-132 : player 2 is disconnected")
|
|
while loop is True:
|
|
try:
|
|
msg = input()
|
|
self.print_output(msg)
|
|
except (KeyboardInterrupt, EOFError):
|
|
loop = refuse_kill
|
|
time.sleep(timeout)
|
|
self.print_output("End")
|
|
|
|
def main(args=sys.argv[1:]):
|
|
""" Main function
|
|
|
|
:param list args: root password
|
|
"""
|
|
parser = argparse.ArgumentParser(description='Simulate program')
|
|
|
|
parser.add_argument('--no-loop', action='store_true',
|
|
help='disable loop', default=False)
|
|
parser.add_argument('--timeout', type=int,
|
|
default=10, help='timeout')
|
|
parser.add_argument('--disable-kill', action='store_true',
|
|
help='disable loop', default=False)
|
|
parser.add_argument('--message', type=int,
|
|
default=0, help='message')
|
|
args = parser.parse_args()
|
|
simulate = SimulateProgram()
|
|
simulate.main(args.no_loop, args.timeout, args.disable_kill, args.message)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|