Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_interface_subjects(self):
netdev = self._proc.open('net', 'dev')
faces = []
subjects = {}
for line in netdev:
line = line.split()
if line[0].count(":"):
faces.append(line[0][:line[0].index(":")])
unis = UNISInstance(unis_url=self.unis_url)
for face in faces:
try:
capacity = ethtool.get_speed(face)
except OSError:
capacity = 0
### some sort of verification here that capacity is right
post_dict={"name":face,
"capacity":capacity}
resp = unis.post_port(post_dict)
if isinstance(resp, dict):
subjects[face]=resp['selfRef']
return subjects