2N/A# The contents of this file are subject to the terms of the 2N/A# Common Development and Distribution License (the "License"). 2N/A# You may not use this file except in compliance with the License. 2N/A# See the License for the specific language governing permissions 2N/A# and limitations under the License. 2N/A# When distributing Covered Code, include this CDDL HEADER in each 2N/A# If applicable, add the following below this CDDL HEADER, with the 2N/A# fields enclosed by brackets "[]" replaced with your own identifying 2N/A# information: Portions Copyright [yyyy] [name of copyright owner] 2N/A# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A"""This module provides utility functions for ZFS. 2N/A# Note: this module (zfs.util) should not import zfs.ioctl, because that 2N/A# would introduce a circular dependency 2N/A """A simple __repr__ function.""" 2N/A return "<%s %s>" % \
2N/A """This exception class represents a potentially user-visible 2N/A ZFS error. If uncaught, it will be printed and the process will 2N/A exit with exit code 1. 2N/A errno -- the error number (eg, from ioctl(2)).""" 2N/A """Create a ZFS exception. 2N/A eno -- the error number (errno) 2N/A task -- a string describing the task that failed 2N/A why -- a string describing why it failed (defaults to 2N/A _(
"delegated administration is disabled on pool"),
2N/A _(
"snapshot permissions cannot be modified"),
2N/A """Return a nice string (eg "1.23M") for this integer.""" 2N/A # it's an exact multiple of its index, or it wouldn't 2N/A # fit as floating point, so print as an integer 2N/A return "%u%c" % (n, u)
2N/A # due to rounding, it's tricky to tell what precision to 2N/A # use; try each precision and see which one fits 2N/A """A function for OptionParser which appends a tuple (opt, value).""" 2N/A """This option parser class raises errors as exception strings 2N/A rather than exiting immediately."""