Revision 2359b052 image_creator/util.py

b/image_creator/util.py
87 87
    return stat.f_bavail * stat.f_frsize
88 88

  
89 89

  
90
def check_guestfs_version(ghandler, major, minor, release):
91
    """Checks if the version of the used libguestfs is smaller, equal or
92
    greater than the one specified by the major, minor and release triplet
93

  
94
    Returns:
95
        < 0 if the installed version is smaller than the specified one
96
        = 0 if they are equal
97
        > 0 if the installed one is greater than the specified one
98
    """
99

  
100
    ver = ghandler.version()
101

  
102
    for (a, b) in (ver['major'], major), (ver['minor'], minor), \
103
            (ver['release'], release):
104
        if a != b:
105
            return a - b
106

  
107
    return 0
108

  
109

  
90 110
class MD5:
91 111
    """Represents MD5 computations"""
92 112
    def __init__(self, output):
......
115 135

  
116 136
        return checksum
117 137

  
118
    def check_guestfs_version(ghandler, major, minor, release):
119
        """Checks if the version of the used libguestfs is smaller, equal or
120
        greater than the one specified by the major, minor and release triplet
121

  
122
        Returns:
123
            < 0 if the installed version is smaller than the specified one
124
            = 0 if they are equal
125
            > 0 if the installed one is greater than the specified one
126
        """
127

  
128
        ver = ghandler.version()
129

  
130
        for (a, b) in (ver['major'], major), (ver['minor'], minor), \
131
                (ver['release'], release):
132
            if a != b:
133
                return a - b
134

  
135
        return 0
136

  
137 138
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :

Also available in: Unified diff