Improve debug for the switch drivers

When running the built-in test code, turn on debug to stdout by
default

Change-Id: Iefcba473a0cbfc99ab9bd8b3a878a8f0713989ad
diff --git a/drivers/CiscoSX300.py b/drivers/CiscoSX300.py
index bb43de0..d551bbb 100644
--- a/drivers/CiscoSX300.py
+++ b/drivers/CiscoSX300.py
@@ -36,10 +36,11 @@
     # this
     _expected_descr_re = re.compile('S.300-\d+')
 
-    logfile = sys.stderr
     logfile = None
 
-    def __init__(self, switch_hostname, switch_telnetport=23):
+    def __init__(self, switch_hostname, switch_telnetport=23, debug = False):
+        if debug:
+            logfile = sys.stderr
         self.exec_string = "/usr/bin/telnet %s %d" % (switch_hostname, switch_telnetport)
 
     ################################
@@ -424,7 +425,23 @@
 
 if __name__ == "__main__":
 #    p = CiscoSX300('10.172.2.52', 23)
-    p = CiscoSX300('vlandswitch02', 23)
+
+    import optparse
+
+    switch = 'vlandswitch02'
+    parser = optparse.OptionParser()
+    parser.add_option("--switch",
+                      dest = "switch",
+                      action = "store",
+                      nargs = 1,
+                      type = "string",
+                      help = "specify switch to connect to for testing",
+                      metavar = "<switch>")
+    (opts, args) = parser.parse_args()
+    if opts.switch:
+        switch = opts.switch
+
+    p = CiscoSX300(switch, 23, debug = True)
     p.switch_connect('cisco', 'cisco', None)
     #buf = p._show_clock()
     #print "%s" % buf