Commit a108236a by Czémán Arnold

freebsd: resolve flake8 warnings in FreeBSD specific files

parent a0f8465b
......@@ -7,19 +7,19 @@ from shutil import copy, rmtree, move
import subprocess
import sys
system = platform.system()
working_directory = sys.path[0]
system = platform.system() # noqa
working_directory = sys.path[0] # noqa
try:
# load virtio console driver, the device is /dev/ttyV0.1
subprocess.call(('/sbin/kldload', '-n', 'virtio_console'))
subprocess.call(('/sbin/kldload', '-n', 'smbfs'))
chdir(working_directory)
subprocess.call(
('/usr/local/bin/pip', 'install', '-r', 'requirements.txt'))
copy("/root/agent/misc/vm_renewal", "/usr/local/bin/")
except:
pass # hope it works
try: # noqa
# load virtio console driver, the device is /dev/ttyV0.1 # noqa
subprocess.call(('/sbin/kldload', '-n', 'virtio_console')) # noqa
subprocess.call(('/sbin/kldload', '-n', 'smbfs')) # noqa
chdir(working_directory) # noqa
subprocess.call( # noqa
('/usr/local/bin/pip', 'install', '-r', 'requirements.txt')) # noqa
copy("/root/agent/misc/vm_renewal", "/usr/local/bin/") # noqa
except Exception: # noqa
pass # hope it works # noqa
import logging
......@@ -109,7 +109,7 @@ class Context(BaseContext):
Context._freebsd_set_time(float(time))
try:
subprocess.call(['/usr/sbin/service' 'ntpd', 'onerestart'])
except:
except Exception:
pass
@staticmethod
......@@ -152,7 +152,7 @@ class Context(BaseContext):
for line in f.readlines():
try:
retval.append(PubKey.from_str(line))
except:
except Exception:
logger.exception(u'Invalid ssh key: ')
except IOError:
pass
......@@ -177,7 +177,7 @@ class Context(BaseContext):
p = PubKey.from_str(key)
if p not in new_keys:
new_keys.append(p)
except:
except Exception:
logger.exception(u'Invalid ssh key: ')
Context._save_keys(new_keys)
......@@ -191,7 +191,7 @@ class Context(BaseContext):
new_keys.remove(p)
except ValueError:
pass
except:
except Exception:
logger.exception(u'Invalid ssh key: ')
Context._save_keys(new_keys)
......
from base64 import decodestring
from struct import unpack
import binascii
import unittest
class InvalidKeyType(Exception):
......@@ -56,8 +57,7 @@ class PubKey(object):
return u'<PubKey: %s>' % unicode(self)
import unittest
# Unit tests
class SshTestCase(unittest.TestCase):
def setUp(self):
......@@ -102,5 +102,6 @@ class SshTestCase(unittest.TestCase):
s.add(self.p3)
self.assertEqual(len(s), 2)
if __name__ == '__main__':
unittest.main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment