Skip to content
This repository has been archived by the owner on Mar 7, 2018. It is now read-only.

Commit

Permalink
Return unicode, not strings
Browse files Browse the repository at this point in the history
  • Loading branch information
dbarrosop committed Nov 1, 2016
1 parent 48ac159 commit ae03c9d
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions napalm_eos/eos.py
Expand Up @@ -1128,10 +1128,10 @@ def get_users(self):

def _sshkey_type(sshkey):
if sshkey.startswith('ssh-rsa'):
return 'ssh_rsa', sshkey
return u'ssh_rsa', unicode(sshkey)
elif sshkey.startswith('ssh-dss'):
return 'ssh_dsa', sshkey
return 'ssh_rsa', ''
return u'ssh_dsa', unicode(sshkey)
return u'ssh_rsa', u''

users = dict()

Expand All @@ -1144,7 +1144,7 @@ def _sshkey_type(sshkey):
sshkey_type, sshkey_value = _sshkey_type(sshkey_value)
user_details.update({
'level': user_details.pop('privLevel', 0),
'password': user_details.pop('secret', ''),
'password': unicode(user_details.pop('secret', '')),
'sshkeys': [sshkey_value]
})
users[user] = user_details
Expand Down Expand Up @@ -1472,32 +1472,32 @@ def get_config(self, retrieve="all"):

output = self.device.run_commands(commands, encoding="text")
return {
'startup': output[0]['output'] if get_startup else "",
'running': output[1]['output'] if get_running else "",
'candidate': output[2]['output'] if get_candidate else "",
'startup': unicode(output[0]['output']) if get_startup else u"",
'running': unicode(output[1]['output']) if get_running else u"",
'candidate': unicode(output[2]['output']) if get_candidate else u"",
}
elif get_startup or get_running:
commands = ['show {}-config'.format(retrieve)]
output = self.device.run_commands(commands, encoding="text")
return {
'startup': output[0]['output'] if get_startup else "",
'running': output[0]['output'] if get_running else "",
'candidate': "",
'startup': unicode(output[0]['output']) if get_startup else u"",
'running': unicode(output[0]['output']) if get_running else u"",
'candidate': u"",
}
elif get_candidate:
commands = ['show session-config named {}'.format(self.config_session)]
output = self.device.run_commands(commands, encoding="text")
return {
'startup': "",
'running': "",
'candidate': output[0]['output'],
'startup': u"",
'running': u"",
'candidate': unicode(output[0]['output']),
}
elif retrieve == "candidate":
# If we get here it means that we want the candidate but there is none.
return {
'startup': "",
'running': "",
'candidate': "",
'startup': u"",
'running': u"",
'candidate': u"",
}
else:
raise Exception("Wrong retrieve filter: {}".format(retrieve))
Expand Down

0 comments on commit ae03c9d

Please sign in to comment.