IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
瀏覽代碼

Added AmbiguousReference exception

tags/0.92
父節點
當前提交
357062b6b7
共有 1 個文件被更改,包括 9 次插入4 次删除
  1. +9
    -4
      zfs.py

+ 9
- 4
zfs.py 查看文件

@@ -4,6 +4,11 @@ import io
import os
class AmbiguousReference(ValueError):
def __init__(self, msg):
super().__init__(msg)
def zfs_run(command):
# print('Running:', command)
out = subprocess.check_output(command, stderr=subprocess.STDOUT)
@@ -29,7 +34,7 @@ def zfs_snapshot_by_tag_or_sha256(s, focker_type='image'):
if len(lst) == 0:
raise ValueError('Reference not found: ' + s)
if len(lst) > 1:
raise ValueError('Ambiguous reference: ' + s)
raise AmbiguousReference('Ambiguous reference: ' + s)
return (lst[0][3], lst[0][0])
@@ -46,7 +51,7 @@ def zfs_find(reference, focker_type='image', zfs_type='filesystem'):
if len(lst) == 0:
raise ValueError('Reference not found: ' + reference)
if len(lst) > 1:
raise ValueError('Ambiguous reference: ' + reference)
raise AmbiguousReference('Ambiguous reference: ' + reference)
return (lst[0][3], lst[0][0])
@@ -119,7 +124,7 @@ def zfs_snapshot_by_sha256(sha256, focker_type='image'):
if len(lst) == 0:
raise ValueError('Snapshot with given sha256 does not exist: ' + sha256)
if len(lst) > 1:
raise ValueError('Ambiguous snapshot sha256: ' + sha256)
raise AmbiguousReference('Ambiguous snapshot sha256: ' + sha256)
return lst[0][1]
@@ -158,7 +163,7 @@ def zfs_name(path):
if len(lst) == 0:
raise ValueError('Not a ZFS path')
if len(lst) > 1:
raise ValueError('Ambiguous ZFS path')
raise AmbiguousReference('Ambiguous ZFS path')
return lst[0][0]


Loading…
取消
儲存