mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-22 21:08:51 +00:00
fw/instrument: Fix compatibility with Python2
The Python2 inspect module does not contain the `getfullargspec` method so call the appropriate method depending on Python version.
This commit is contained in:
parent
6239f6ab2f
commit
8cd79f2ac4
@ -98,6 +98,7 @@ and the code to clear these file goes in teardown method. ::
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
import sys
|
||||||
import logging
|
import logging
|
||||||
import inspect
|
import inspect
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
@ -324,7 +325,10 @@ def install(instrument, context):
|
|||||||
if not callable(attr):
|
if not callable(attr):
|
||||||
msg = 'Attribute {} not callable in {}.'
|
msg = 'Attribute {} not callable in {}.'
|
||||||
raise ValueError(msg.format(attr_name, instrument))
|
raise ValueError(msg.format(attr_name, instrument))
|
||||||
argspec = inspect.getfullargspec(attr)
|
if sys.version_info[0] == 3:
|
||||||
|
argspec = inspect.getfullargspec(attr)
|
||||||
|
else:
|
||||||
|
argspec = inspect.getargspec(attr) # pylint: disable=deprecated-method
|
||||||
arg_num = len(argspec.args)
|
arg_num = len(argspec.args)
|
||||||
# Instrument callbacks will be passed exactly two arguments: self
|
# Instrument callbacks will be passed exactly two arguments: self
|
||||||
# (the instrument instance to which the callback is bound) and
|
# (the instrument instance to which the callback is bound) and
|
||||||
|
Loading…
x
Reference in New Issue
Block a user