Return the data from the file on given path.
(self, path, sudo=False, offset=None, length=None)
| 757 | self.run_shell(args=f'chmod {perms} {path}') |
| 758 | |
| 759 | def read_file(self, path, sudo=False, offset=None, length=None): |
| 760 | """ |
| 761 | Return the data from the file on given path. |
| 762 | """ |
| 763 | if path.find(self.hostfs_mntpt) == -1: |
| 764 | path = os.path.join(self.hostfs_mntpt, path) |
| 765 | |
| 766 | args = [] |
| 767 | if sudo: |
| 768 | args.append('sudo') |
| 769 | args.append('dd') |
| 770 | args.append(f'if={path}') |
| 771 | args.append('bs=1') |
| 772 | if offset: |
| 773 | args.append(f'skip={offset}') |
| 774 | if length: |
| 775 | args.append(f'count={length}') |
| 776 | |
| 777 | return self.run_shell(args=args, omit_sudo=False).stdout.getvalue().strip() |
| 778 | |
| 779 | def create_destroy(self): |
| 780 | assert(self.is_mounted()) |