General cleanup of opencafe

* Fixed pep8 issues
* Corrected typos

Change-Id: Id03a03e3c981586a44b914b3aa45cafe6b957259
This commit is contained in:
Daryl Walleck
2013-04-08 22:29:23 -05:00
parent cde272db05
commit ff07350cc3
11 changed files with 62 additions and 48 deletions

View File

@@ -30,20 +30,25 @@ class BasePersistentLinuxClient(object):
def format_disk_device(self, device, fstype):
'''Formats entire device, does not create partitions'''
return self.ssh_client.exec_command("mkfs.%s %s\n" % (str(fstype).lower(), str(device)))
return self.ssh_client.exec_command(
"mkfs.%s %s\n" % (str(fstype).lower(), str(device)))
def mount_disk_device(self, device, mountpoint, fstype, create_mountpoint=True):
'''
Mounts a disk at a specified mountpoint. performs 'touch mountpoint' before executing
Mounts a disk at a specified mountpoint.
Performs 'touch mountpoint' before executing
'''
self.ssh_client.exec_command("mkdir %s" % str(mountpoint))
return self.ssh_client.exec_command("mount -t %s %s %s\n" % (str(fstype).lower(), str(device), str(mountpoint)))
return self.ssh_client.exec_command(
"mount -t %s %s %s\n" % (str(fstype).lower(),
str(device), str(mountpoint)))
def unmount_disk_device(self, mountpoint):
'''
Forces unmounts (umount -f) a disk at a specified mountpoint.
Forces unmounts (umount -f) a disk at a specified mountpoint.
'''
return self.ssh_client.exec_command("umount -f %s\n" % (str(mountpoint)))
return self.ssh_client.exec_command(
"umount -f %s\n" % (str(mountpoint)))
def write_random_data_to_disk(self, dir_path, filename, blocksize=1024,
count=1024):
@@ -62,7 +67,8 @@ class BasePersistentLinuxClient(object):
"dd if=/dev/urandom of=%s bs=%s count=%s\n" %
(str(dd_of), str(blocksize), str(count)))
def write_zeroes_data_to_disk(self, disk_mountpoint, filename, blocksize=1024, count=1024):
def write_zeroes_data_to_disk(self, disk_mountpoint, filename,
blocksize=1024, count=1024):
'''By default writes one mebibyte (2^20 bytes)'''
of = '%s/%s' % (disk_mountpoint, str(filename))

View File

@@ -31,7 +31,7 @@ class FreeBSDClient(LinuxClient):
uptime_string = self.ssh_client.exec_command('uptime')
uptime = uptime_string.replace('\n', '').split(',')[0].split()[2]
uptime_unit = uptime_string.replace('\n', '').split(',')[0].split()[3]
if (uptime_unit == 'mins'):
if uptime_unit == 'mins':
uptime_unit_format = 'M'
else:
uptime_unit_format = 'S'

View File

@@ -90,7 +90,7 @@ def _log_transaction(log, level=cclogging.logging.DEBUG):
log.exception(exception)
logline = ''.join([
'\n{0}\nRESPONSE RECIEVED\n{0}\n'.format('-' * 17),
'\n{0}\nRESPONSE RECEIVED\n{0}\n'.format('-' * 17),
'response status..: {0}\n'.format(response),
'response time....: {0}\n'.format(elapsed),
'response headers.: {0}\n'.format(response.headers),
@@ -142,7 +142,7 @@ class BaseRestClient(BaseClient):
@_inject_exception(_exception_handlers)
@_log_transaction(log=_log)
def request(self, method, url, **kwargs):
""" Performs <method> HTTP request to <url> using the requests lib"""
""" Performs <method> HTTP request to <url> using the requests lib"""
return requests.request(method, url, **kwargs)
def put(self, url, **kwargs):
@@ -197,13 +197,13 @@ class BaseRestClient(BaseClient):
class RestClient(BaseRestClient):
"""
@summary: Allows clients to inherit all requests-defined RESTfull
@summary: Allows clients to inherit all requests-defined RESTful
verbs. Redefines request() so that keyword args are passed
through a named dictionary instead of kwargs.
Client methods can then take paramaters that may overload
request paramaters, which allows client method calls to
override parts of the request with paramters sent directly
to requests, overiding the client method logic either in
Client methods can then take parameters that may overload
request parameters, which allows client method calls to
override parts of the request with parameters sent directly
to requests, overriding the client method logic either in
part or whole on the fly.
@see: http://docs.python-requests.org/en/latest/api/#configurations
@@ -244,8 +244,8 @@ class RestClient(BaseRestClient):
if requestslib_kwargs[key] is None:
del requestslib_kwargs[key]
#Create the final paramaters for the call to the base request()
#Wherever a paramater is provided both by the calling method AND
#Create the final parameters for the call to the base request()
#Wherever a parameter is provided both by the calling method AND
#the requests_lib kwargs dictionary, requestslib_kwargs "wins"
requestslib_kwargs = dict({'headers': headers,
'params': params,
@@ -275,7 +275,7 @@ class AutoMarshallingRestClient(RestClient):
requestslib_kwargs = requestslib_kwargs if (requestslib_kwargs is not
None) else {}
#set the 'data' paramater of the request to either what's already in
#set the 'data' parameter of the request to either what's already in
#requestslib_kwargs, or the deserialized output of the request_entity
if request_entity is not None:
requestslib_kwargs = dict(