mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-19 04:21:17 +00:00
device: more reliable get_properites
Pulling entries from procfs does not work on some platforms. This commit updates get_properites() to cat the contents of a property_file and write it to output file on the host, rather than pulling it (directories are still pulled).
This commit is contained in:
parent
a6feb65b34
commit
b6442acf80
@ -191,12 +191,16 @@ class BaseLinuxDevice(Device): # pylint: disable=abstract-method
|
|||||||
|
|
||||||
def get_properties(self, context):
|
def get_properties(self, context):
|
||||||
for propfile in self.property_files:
|
for propfile in self.property_files:
|
||||||
if not self.file_exists(propfile):
|
|
||||||
continue
|
|
||||||
try:
|
try:
|
||||||
normname = propfile.lstrip(self.path.sep).replace(self.path.sep, '.')
|
normname = propfile.lstrip(self.path.sep).replace(self.path.sep, '.')
|
||||||
outfile = os.path.join(context.host_working_directory, normname)
|
outfile = os.path.join(context.host_working_directory, normname)
|
||||||
self.pull_file(propfile, outfile)
|
if self.is_file(propfile):
|
||||||
|
with open(outfile, 'w') as wfh:
|
||||||
|
wfh.write(self.execute('cat {}'.format(propfile)))
|
||||||
|
elif self.is_directory(propfile):
|
||||||
|
self.pull_file(propfile, outfile)
|
||||||
|
else:
|
||||||
|
continue
|
||||||
except DeviceError:
|
except DeviceError:
|
||||||
# We pull these files "opportunistically", so if a pull fails
|
# We pull these files "opportunistically", so if a pull fails
|
||||||
# (e.g. we don't have permissions to read the file), just note
|
# (e.g. we don't have permissions to read the file), just note
|
||||||
@ -722,6 +726,18 @@ class LinuxDevice(BaseLinuxDevice):
|
|||||||
# split out everything except the last word.
|
# split out everything except the last word.
|
||||||
return boolean(output.split()[-1]) # pylint: disable=maybe-no-member
|
return boolean(output.split()[-1]) # pylint: disable=maybe-no-member
|
||||||
|
|
||||||
|
def is_file(self, filepath):
|
||||||
|
output = self.execute('if [ -f \'{}\' ]; then echo 1; else echo 0; fi'.format(filepath))
|
||||||
|
# output from ssh my contain part of the expression in the buffer,
|
||||||
|
# split out everything except the last word.
|
||||||
|
return boolean(output.split()[-1]) # pylint: disable=maybe-no-member
|
||||||
|
|
||||||
|
def is_directory(self, filepath):
|
||||||
|
output = self.execute('if [ -d \'{}\' ]; then echo 1; else echo 0; fi'.format(filepath))
|
||||||
|
# output from ssh my contain part of the expression in the buffer,
|
||||||
|
# split out everything except the last word.
|
||||||
|
return boolean(output.split()[-1]) # pylint: disable=maybe-no-member
|
||||||
|
|
||||||
def listdir(self, path, as_root=False, **kwargs):
|
def listdir(self, path, as_root=False, **kwargs):
|
||||||
contents = self.execute('ls -1 {}'.format(path), as_root=as_root).strip()
|
contents = self.execute('ls -1 {}'.format(path), as_root=as_root).strip()
|
||||||
if not contents:
|
if not contents:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user