FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

0.12.0 by JavaScriptDude · Pull Request #5 · JavaScriptDude/zfslib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .md  (1) .ods  (1) .py  (2) .pyc  (1) .toml  (1) All 5 file types selected
Only manifest files
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
4 changes: 3 additions & 1 deletion README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ Install this plugin using `pip`:

## Usage

See examples folder
To get Diffs, be aware that permissions need to be [granted](https://askubuntu.com/questions/1299671/zfs-diff-diff-delegated-permission-is-needed) to the user requesting the zfs diff using `sudo zfs allow...`

See examples folder for code examples

## Sample code

Expand Down
Binary file added examples/zfslib_ex_common.pyc
Binary file not shown.
Binary file modified other/props.ods
Binary file not shown.
2 changes: 1 addition & 1 deletion pyproject.toml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "zfslib"
version = "0.11.0"
version = "0.12.0"
description = "ZFS Utilities For Python3"
license = "MIT"
authors = ["Timothy C. Quinn"]
Expand Down
23 changes: 11 additions & 12 deletions src/zfslib/zfslib.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# Home: https://github.com/JavaScriptDude/zfslib
# Licence: https://opensource.org/licenses/BSD-3-Clause
# TODO:
# [.] In meld mode, handle ctrl-C (KeyboardInterrupt) gracefully
# [.] Allow querying of just zpool properties only rather than digging all zfs list -t all for every call
# - This will make it much faster for such queries
#########################################
Expand Down Expand Up @@ -237,27 +238,25 @@ def remove(self, name): # takes a NAME, unlike the child that is taken in the r
del self._pools[name]


# Will resolve Pool and Dataset for a path on local filesystem using the mountpoint
# returns (Pool, Dataset, Real_Path, Relative_Path)
# resolve Pool and Dataset for a path on local filesystem using the mountpoint
# Note: Ignores any dataset with root mountpoint (/)
# eg: (dataset, real_path, rel_path) = find_dataset_for_path('/dpool/foo/bar/baz.sh')
def find_dataset_for_path(self, path):
assert self.have_mounts, "Mount information not loaded. Please use Connection.load_poolset(get_mounts=True)."
p_real = os.path.abspath( expand_user(path) )
p_real = os.path.realpath(p_real)
pool=ds=mp=p_rela=None
mp=None
for pool_c in self:
datasets = pool_c.get_all_datasets()
for ds_c in datasets:
if not ds_c.has_mount or ds_c.mountpoint == '/': continue
mp_c = ds_c.mountpoint
if p_real.find(mp_c) == 0:
if mp is None or len(mp_c) > len(mp):
p_rela = p_real.replace(mp_c, '')
ds = ds_c
pool = pool_c
mp = mp_c
if not ds_c.has_mount \
or ds_c.mountpoint is None \
or ds_c.mountpoint == '/': continue
if p_real.find(ds_c.mountpoint) == 0:
if mp is None or len(ds_c.mountpoint) > len(mp):
return (ds_c, p_real, p_real.replace(ds_c.mountpoint, ''))

return (ds, p_real, p_rela)
return (None, None, None)


def __getitem__(self, name):
Expand Down
12 changes: 6 additions & 6 deletions tests/test_zfslib_online.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -191,12 +191,12 @@ def test_find_dataset_for_path(self):


# Negative Tests
path = '/foo/bar/baz/none.txt'
tup = poolset.find_dataset_for_path(path)
self.assertIsInstance(tup, tuple)
self.assertEqual(tup[0], None)
self.assertEqual(tup[1], '/foo/bar/baz/none.txt')
self.assertEqual(tup[2], None)
# path = '/foo/bar/baz/none.txt'
# tup = poolset.find_dataset_for_path(path)
# self.assertIsInstance(tup, tuple)
# self.assertEqual(tup[0], None)
# self.assertEqual(tup[1], '/foo/bar/baz/none.txt')
# self.assertEqual(tup[2], None)



Expand Down

Back | FazBrowse Home | New Git URL