1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-31 10:11:17 +00:00

daq: make EnumEntry picklable to support multiprocessing invocation

This commit is contained in:
Sergei Trofimov 2015-04-29 12:32:15 +01:00
parent 82fed172d5
commit bb5d5cba8e
2 changed files with 15 additions and 11 deletions

View File

@ -23,7 +23,7 @@ class Serializer(json.JSONEncoder):
def default(self, o): # pylint: disable=E0202
if isinstance(o, Serializable):
return o.serialize()
if isinstance(o, Enum.EnumEntry):
if isinstance(o, EnumEntry):
return o.name
return json.JSONEncoder.default(self, o)
@ -58,6 +58,18 @@ class DaqServerResponse(Serializable):
return '{} {}'.format(self.status, self.message or '')
class EnumEntry(object):
def __init__(self, name):
self.name = name
def __str__(self):
return self.name
def __cmp__(self, other):
return cmp(self.name, str(other))
class Enum(object):
"""
Assuming MyEnum = Enum('A', 'B'),
@ -74,17 +86,9 @@ class Enum(object):
"""
class EnumEntry(object):
def __init__(self, name):
self.name = name
def __str__(self):
return self.name
def __cmp__(self, other):
return cmp(self.name, str(other))
def __init__(self, *args):
for a in args:
setattr(self, a, self.EnumEntry(a))
setattr(self, a, EnumEntry(a))
def __call__(self, value):
if value not in self.__dict__:

View File

@ -258,7 +258,7 @@ if __name__ == '__main__':
output_directory = sys.argv[1]
duration = float(sys.argv[2])
print "Avialable devices:", list_availabe_devices()
print "Avialable devices:", list_available_devices()
runner = DaqRunner(dev_config, output_directory)
runner.start()
time.sleep(duration)