jedelman8/cpal — pull request #12 by IPyandy (2014-04-01 21:34:13+00:00)
Title: Initial Command parsing take 2

restructured code per comments, kept tab formatting so it doesn't look like I'm changing the entire code base here. Moved argparse to it's own initArgs method and initDevice. Structure a bit to enable the creation of -f to run the function via a command-line switch.

still works as expected

```bash
$ python main.py -i 192.168.31.21 -m arista -n 'SW1'
{ 'connect_ip': '192.168.31.21',
'free_system_memory': 33852,
'hostname': u'leaf-1a',
'platform': u'vEOS',
'serial_number': '12345',
'system_uptime': u' 17:31:22',
'total_sytem_memory': 1000444,
'var_name': 'SW1',
'vendor': 'arista'}
```

I just don't have the onePK stuff so it errors out, but at least you can see it tries to switch manufacturers.

```bash
$ python main.py -i 192.168.31.21 -m cisco -n 'SW1'
Traceback (most recent call last):
File "main.py", line 194, in
sw1 = device('sw1', 'cisco', '10.1.1.110')
File "main.py", line 44, in __init__
self.initDevice()
File "main.py", line 92, in initDevice
self._thisdevice = cisco(self.address, self.obj)
NameError: global name 'cisco' is not defined
```

let me know if this is 'better' more what you were expecting.

Thanks