Example #1
0
 def test_fstab_detect_snapshot(self, mock_commands):
     # Using python-mock 0.7 style, for precise compatibility
     mock_commands.side_effect = lambda f: f in ("/sbin/btrf")
     self.assertFalse(supported(fstab=os.path.join(self.testdir, "data", "fstab")))
     mock_commands.side_effect = lambda f: f in ("/sbin/btrfs")
     self.assertTrue(supported(fstab=os.path.join(self.testdir, "data", "fstab")))
     self.assertFalse(supported(fstab=os.path.join(self.testdir, "data", "fstab.no-btrfs")))
     self.assertFalse(supported(fstab=os.path.join(self.testdir, "data", "fstab.bug806065")))
     self.assertTrue(supported(fstab=os.path.join(self.testdir, "data", "fstab.bug872145")))
Example #2
0
    supported,
)
import snapshots
from snapshots import (
    Snapshot,
    SNAP_PREFIX,
)
from dpkg_history import DpkgHistory

if __name__ == "__main__":

    if os.getuid() != 0 and len(sys.argv) == 1:
        print(_("Sorry, you need to be root to run this program"))
        sys.exit(1)

    if not supported():
        print(_("Sorry, your system lacks support for the snapshot feature"))
        sys.exit(1)
    
    if len(sys.argv) > 1:
        apt_btrfs = AptBtrfsSnapshot(test_mp = sys.argv[1])
    else:
        apt_btrfs = AptBtrfsSnapshot()
    mountpoint = apt_btrfs.mp
    snaplist = snapshots.get_list()
    snaplist.sort(key = lambda x: x.date)
    
    previous = None
    for snap in snaplist:
        if previous:
            snap.parent = previous