#!/usr/bin/python # # Block header comment # # import sys, imp, atexit sys.path.append("/home/courses/cs3214/software/pexpect-dpty/"); import pexpect, shellio, signal, time, os, re, proc_check #Ensure the shell process is terminated def force_shell_termination(shell_process): c.close(force=True) #pulling in the regular expression and other definitions definitions_scriptname = sys.argv[1] plugin_dir = sys.argv[2] def_module = imp.load_source('', definitions_scriptname) logfile = None if hasattr(def_module, 'logfile'): logfile = def_module.logfile #spawn an instance of the shell c = pexpect.spawn(def_module.shell + plugin_dir, drainpty=True, logfile=logfile) atexit.register(force_shell_termination, shell_process=c) #test all the colors c.sendline("color red"); c.expect("setting color to red"); c.sendline("color green"); c.expect("setting color to green"); c.sendline("color yellow"); c.expect("setting color to yellow"); c.sendline("color blue"); c.expect("setting color to blue"); c.sendline("color magenta"); c.expect("setting color to magenta"); c.sendline("color cyan"); c.expect("setting color to cyan"); c.sendline("color white"); c.expect("setting color to white"); c.sendline("color normal"); c.expect("setting color to normal"); #test invalid arguments c.sendline("color thisisntacolor"); c.expect("Error: unknown color. this isn't a color"); c.sendline("color"); c.expect("Error: color requires exactly one argument."); c.sendline("color blue magenta foo"); c.expect("Error: color requires exactly one argument."); shellio.success()