How to use get_available_filesystems method in avocado

Best Python code snippet using avocado_python

mount.py

Source:mount.py Github

copy

Full Screen

...9 Add arguments and `func` to `p`.10 :param p: ArgumentParser11 :return: ArgumentParser12 """13 available_filesystems = get_available_filesystems()14 available_filesystems.sort()15 p.set_defaults(func=func)16 p.description = "Mount a filesystem"17 p.add_argument('SOURCE', nargs='?')18 p.add_argument('DEST', nargs='?')19 p.add_argument(20 "-a",21 "--all",22 action="store_true",23 help="Mount all filesystems mentioned in fstab",24 )25 # p.add_argument(26 # "-o", "--options", default=0,27 # help="print only the effective group ID")28 p.add_argument(29 "-t",30 "--types",31 default="ext2",32 help="Filesystem type. Supported types: " + ", ".join(available_filesystems),33 )34 p.add_argument(35 "-v", "--verbose", action="store_true", help="Output debugging information"36 )37 return p38def func(args):39 if args.SOURCE and args.DEST:40 mount_c(args.SOURCE, args.DEST, args.types, args.verbose)41 elif args.SOURCE or args.all:42 # Read fstab43 try:44 with open('/etc/fstab') as fd:45 lines = fd.readlines()46 except IOError:47 print("Error: Couldn't read /etc/ftab", file=sys.stderr)48 return49 # Mount filesystem50 mounted_something = False51 for line in lines:52 line = line.partition('#')[0] # Remove comments53 source, dest, fstype, options, freq, passno = line.split()54 if source == args.SOURCE or dest == args.SOURCE or args.all:55 mount_c(dest, dest, fstype, args.verbose)56 mounted_something = True57 if not mounted_something:58 print(args.SOURCE + " not found in /etc/fstab", file=sys.stderr)59 else:60 # Display currently mounted filesystems61 try:62 print(open('/etc/mtab').read().strip())63 except IOError:64 print("Error: Couldn't read /etc/mtab", file=sys.stderr)65def mount_c(source, dest, fstype, options=0, data='', verbose=False):66 """67 Frontend to libc mount68 """69 if verbose:70 print("Trying to mount {0} on {1} as type {2}".format(source, dest, fstype))71 libc = ctypes.CDLL(ctypes.util.find_library('c'))72 res = libc.mount(str(source), str(dest), str(fstype), options, str(data))73 if res < 0:74 print(75 "Error: Mounting {0} on {1} failed!".format(source, dest), file=sys.stderr76 )77def get_available_filesystems():78 ell = []79 try:80 with open('/proc/filesystems') as fd:81 for line in fd.readlines():82 ell.append(line.split()[-1])83 except IOError:84 print(85 "Error reading supported filesystems from /proc/filesystems",86 file=sys.stderr,87 )88 return ell...

Full Screen

Full Screen

test_utils_disk.py

Source:test_utils_disk.py Github

copy

Full Screen

...46 expected_fs = ['dax', 'bpf', 'pipefs', 'hugetlbfs', 'devpts', 'ext3']47 open_mocked = unittest.mock.mock_open(read_data=PROC_FILESYSTEMS)48 with unittest.mock.patch('builtins.open', open_mocked):49 self.assertEqual(sorted(expected_fs),50 sorted(disk.get_available_filesystems()))51 def test_get_filesystem_type_default_root(self):52 open_mocked = unittest.mock.mock_open(read_data=PROC_MOUNTS)53 with unittest.mock.patch('builtins.open', open_mocked):54 self.assertEqual('ext4', disk.get_filesystem_type())55 def test_get_filesystem_type(self):56 open_mocked = unittest.mock.mock_open(read_data=PROC_MOUNTS)57 with unittest.mock.patch('builtins.open', open_mocked):58 self.assertEqual('ext2', disk.get_filesystem_type(mount_point='/home'))59if __name__ == '__main__':...

Full Screen

Full Screen

test_disk.py

Source:test_disk.py Github

copy

Full Screen

...48 expected_fs = ["dax", "bpf", "pipefs", "hugetlbfs", "devpts", "ext3"]49 open_mocked = unittest.mock.mock_open(read_data=PROC_FILESYSTEMS)50 with unittest.mock.patch("builtins.open", open_mocked):51 self.assertEqual(52 sorted(expected_fs), sorted(disk.get_available_filesystems())53 )54 def test_get_filesystem_type_default_root(self):55 open_mocked = unittest.mock.mock_open(read_data=PROC_MOUNTS)56 with unittest.mock.patch("builtins.open", open_mocked):57 self.assertEqual("ext4", disk.get_filesystem_type())58 def test_get_filesystem_type(self):59 open_mocked = unittest.mock.mock_open(read_data=PROC_MOUNTS)60 with unittest.mock.patch("builtins.open", open_mocked):61 self.assertEqual("ext2", disk.get_filesystem_type(mount_point="/home"))62if __name__ == "__main__":...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful