def testbed(argv): """testbed [-s <script>] <testbed> Interact with testbed and its devices. Options: -s <script> Run a CLI script from the given file instead of entering interactive mode. """ import sys, os import slstorage import nmsgetopt script = None try: optlist, longopts, args = nmsgetopt.getopt(argv[1:], "s:?g") except GetoptError: print testbed.__doc__ return for opt, val in optlist: if opt == "-?": print testbed.__doc__ return elif opt == "-s": script = val if len(args) >= 1: tbname = args[0] else: print testbed.__doc__ return cf = slstorage.get_config(initdict=longopts) # fake test module attributes cf.reportfile = "testbed_cli" cf.logbasename = "testbed_cli.log" cf.arguments = argv tb = cf.testbeds.get(tbname) if tb is None: print "Testbed not found." return tbr = strataobjects.TestBedRuntime(tb, cf.devices, cf.logfile) io = CLI.ConsoleIO() theme = TestBedTheme() ui = CLI.UserInterface(io, cf, theme) cmd = TestBedRuntimeEditor(ui) cmd._setup(tbr, "TestBed:%s" % (tbname,))
def storagecli(argv): """storagecli [-?rg] [<scriptfile>...] Provides an interactive session to the configuration server. This allows you to interactively view and change the persistent database. Options: -? = This help text. -g = used paged output (like 'more'). """ import nmsgetopt paged = False try: optlist, longopts, args = nmsgetopt.getopt(argv[1:], "?g") except GetoptError: print storagecli.__doc__ return for opt, val in optlist: if opt == "-?": print storagecli.__doc__ return elif opt == "-g": paged = True if paged: import termtools io = termtools.PagedIO() else: io = CLI.ConsoleIO() ui = CLI.UserInterface(io) cf = slstorage.get_config(initdict=longopts) cf.reportfile = __name__.replace(".", "_") cf.logbasename = "%s.log" % (__name__.replace(".", "_"),) cf.arguments = argv cmd = RootContainerEditor(ui) cmd._setup(cf, "root") parser = CLI.CommandParser(cmd, historyfile=os.path.expandvars("$HOME/.hist_storagecli")) if args: for arg in args: try: parser.parse(arg) except KeyboardInterrupt: break else: parser.interact()
def stratatest(argv): """stratatest """ import stratatestrunner import slstorage cf = slstorage.get_config() cf.userinterfacetype = "stream" testrunner = stratatestrunner.TestRunner(cf) io = CLI.ConsoleIO() ui = CLI.UserInterface(io) cmd = MainCLI(ui) cmd._setup(testrunner, "Stratatest> ") parser = CLI.CommandParser(cmd, historyfile="$HOME/.hist_stratalight") parser.interact()
def runtest(argv): import slstorage cf = slstorage.get_config() tr = TestRunner(cf) tr(argv)
#!/usr/bin/python2.4 # -*- coding: ascii -*- # vim:ts=4:sw=4:softtabstop=4:smarttab:expandtab # # $Id: //Branches/Stratatest/NextGen/Titan-1.0.0/sbin/update_instruments.py#2 $ # # Copyright (C) 1999-2005 Stratalight Communications. # """ Add instruments found in the VISA system to the persistent storage. """ import instruments import slstorage import sys try: gpib_name = sys.argv[1].upper() except: gpib_name = None cf = slstorage.get_config() instruments.update_instruments(cf.devices, gpib_name) cf.commit() del cf
def configurator_cli(argv): """configurator_cli [-s <script>] [-g] [<device>] Interact with a device configurator. Options: -g Use paged output (like 'more') -s <script> Run a CLI script from the given file instead of entering interactive mode. """ import os import configurator import stratatestrunner import slstorage as Storage import nmsgetopt paged = False script = None try: optlist, longopts, args = nmsgetopt.getopt(argv[1:], "s:?g") except GetoptError: print configurator_cli.__doc__ return for opt, val in optlist: if opt == "-?": print configurator_cli.__doc__ return elif opt == "-g": paged = True elif opt == "-s": script = val if len(args) >= 1: devname = args[0] else: print configurator_cli.__doc__ return if paged: import termtools io = termtools.PagedIO() else: io = CLI.ConsoleIO() cf = Storage.get_config(initdict=longopts) stratatestrunner.runtime_config(cf) # fake test module attributes cf.reportfile = "configurator_cli" cf.logbasename = "configurator_cli.log" cf.arguments = argv dev = cf.devices.getpath(devname) if dev is None: print "Could not find that device." return ctor = dev.get_configurator(cf.logfile) # construct the CLI theme = ConfiguratorTheme("Configurator> ") ui = CLI.UserInterface(io, cf, theme) cmd = CLI.get_generic_cmd(ctor, ui, ConfiguratorCLI) parser = CLI.CommandParser(cmd, historyfile=os.path.expandvars("$HOME/.hist_configurator")) try: if script: try: parser.parse(script) except KeyboardInterrupt: pass else: parser.interact() finally: ctor.close() del cf.logfile