1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-03-21 18:18:41 +00:00

fix: moving is_file and is_directory into BaseLinuxDevice, as relied on by get_properties.

This commit is contained in:
Sergei Trofimov 2015-10-05 16:30:33 +01:00
parent fe4d49e334
commit 552ea2a1bb

View File

@ -189,6 +189,18 @@ class BaseLinuxDevice(Device): # pylint: disable=abstract-method
else: else:
self.busybox = 'busybox' self.busybox = 'busybox'
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 get_properties(self, context): def get_properties(self, context):
for propfile in self.property_files: for propfile in self.property_files:
try: try:
@ -726,18 +738,6 @@ 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: