Tuning EnableCmds, Bug fix in  turnOffInterface

1) added "if x.values()" to ensure that the x.values()[0] is always valid
2) turnOffInterface: bug was crashing upon calling EnableCmds from turnOffInterface (passing "self" instead of cmd). Details:

I think you might have overused "self" here, isn't there one to remove ? I think the result is self.self (you are calling a pointer to a function it seems, rather than the instance).


    
    def turnOffInterface( self, interface ):
        self.runEnableCmds( self, [ 'configure',
                                    'interface %s' % interface,
                                    'shutdown' ] )


Code tuned for debug outputs:

def runEnableCmds( self, cmds, mode='json' ):
        print "------------------------"
        print cmds
        print mode
        print "------------------------"        
        result = self.client.runCmds( 
            1, [ { 'cmd': 'enable', 
                   'input': EAPI_ENABLE_PASSWORD } ] +
            cmds, mode)[ 1: ]


Crash log:

------------------------
['show interfaces counters errors']
text
------------------------
Counters: {'Et2': {'symbol': 0, 'fcs': 0}, 'Et3': {'symbol': 0, 'fcs': 0}, 'Et1': {'symbol': 0, 'fcs': 0}, 'Ma1': {'symbol': 0, 'fcs': 0}, 'Et49/1': {'symbol': 0, 'fcs': 6150}}
FCS counters for Et2 OK
SYMBOL counters for Et2 OK
FCS counters for Et3 OK
SYMBOL counters for Et3 OK
FCS counters for Et1 OK
SYMBOL counters for Et1 OK
FCS counters for Ma1 OK
SYMBOL counters for Ma1 OK
%INTERFSCE-4-FCS_ERRORS_WARNING: FCS errors detected on Et49/1 - error count increased from 5150 to 6150
%INTERFSCE-4-FCS_FAILURE_WARNING: Interface Et49/1 was turned off because a constant increase in the number of FCS errors was detected
------------------------
<__main__.EApiClient object at 0xf6d2ea0c>
['configure', 'interface Et49/1', 'shutdown']
------------------------
Traceback (most recent call last):
  File "./phm_ad_v2", line 370, in <module>
    main()
  File "./phm_ad_v2", line 367, in main
    checkInterfaces()
  File "./phm_ad_v2", line 317, in checkInterfaces
    eapi.turnOffInterface( intf )
  File "./phm_ad_v2", line 279, in turnOffInterface
    'shutdown' ] )
  File "./phm_ad_v2", line 245, in runEnableCmds
    cmds, mode)[ 1: ]
TypeError: can only concatenate list (not "EApiClient") to list
[admin@s7056 flash]#
space formatting (aesthetically)
Merge pull request #3 from alexisdacquay/master

P1 Bug fix in turnOffInterface