Exemple #1
0
 def packed(self):
     try:
         ctime = xstat.nsecs_to_timespec(self.ctime)
         mtime = xstat.nsecs_to_timespec(self.mtime)
         atime = xstat.nsecs_to_timespec(self.atime)
         return struct.pack(
             INDEX_SIG,
             self.dev,
             self.ino,
             self.nlink,
             ctime[0],
             ctime[1],
             mtime[0],
             mtime[1],
             atime[0],
             atime[1],
             self.size,
             self.mode,
             self.gitmode,
             self.sha,
             self.flags,
             self.children_ofs,
             self.children_n,
             self.meta_ofs,
         )
     except (DeprecationWarning, struct.error) as e:
         log("pack error: %s (%r)\n" % (e, self))
         raise
Exemple #2
0
 def _encode_common(self):
     atime = xstat.nsecs_to_timespec(self.atime)
     mtime = xstat.nsecs_to_timespec(self.mtime)
     ctime = xstat.nsecs_to_timespec(self.ctime)
     result = vint.pack('VVsVsVvVvVvV', self.mode, self.uid, self.owner,
                        self.gid, self.group, self.rdev, atime[0], atime[1],
                        mtime[0], mtime[1], ctime[0], ctime[1])
     return result
Exemple #3
0
 def _encode_common(self):
     if not self.mode:
         return None
     atime = xstat.nsecs_to_timespec(self.atime)
     mtime = xstat.nsecs_to_timespec(self.mtime)
     ctime = xstat.nsecs_to_timespec(self.ctime)
     result = vint.pack('vvsvsvvVvVvV', self.mode, self.uid, self.user,
                        self.gid, self.group, self.rdev, atime[0], atime[1],
                        mtime[0], mtime[1], ctime[0], ctime[1])
     return result
Exemple #4
0
def test_fstime():
    WVPASSEQ(xstat.timespec_to_nsecs((0, 0)), 0)
    WVPASSEQ(xstat.timespec_to_nsecs((1, 0)), 10**9)
    WVPASSEQ(xstat.timespec_to_nsecs((0, 10**9 / 2)), 500000000)
    WVPASSEQ(xstat.timespec_to_nsecs((1, 10**9 / 2)), 1500000000)
    WVPASSEQ(xstat.timespec_to_nsecs((-1, 0)), -10**9)
    WVPASSEQ(xstat.timespec_to_nsecs((-1, 10**9 / 2)), -500000000)
    WVPASSEQ(xstat.timespec_to_nsecs((-2, 10**9 / 2)), -1500000000)
    WVEXCEPT(Exception, xstat.timespec_to_nsecs, (0, -1))
    WVPASSEQ(type(xstat.timespec_to_nsecs((2, 22222222))), type(0))
    WVPASSEQ(type(xstat.timespec_to_nsecs((-2, 22222222))), type(0))

    WVPASSEQ(xstat.nsecs_to_timespec(0), (0, 0))
    WVPASSEQ(xstat.nsecs_to_timespec(10**9), (1, 0))
    WVPASSEQ(xstat.nsecs_to_timespec(500000000), (0, 10**9 / 2))
    WVPASSEQ(xstat.nsecs_to_timespec(1500000000), (1, 10**9 / 2))
    WVPASSEQ(xstat.nsecs_to_timespec(-10**9), (-1, 0))
    WVPASSEQ(xstat.nsecs_to_timespec(-500000000), (-1, 10**9 / 2))
    WVPASSEQ(xstat.nsecs_to_timespec(-1500000000), (-2, 10**9 / 2))
    x = xstat.nsecs_to_timespec(1977777778)
    WVPASSEQ(type(x[0]), type(0))
    WVPASSEQ(type(x[1]), type(0))
    x = xstat.nsecs_to_timespec(-1977777778)
    WVPASSEQ(type(x[0]), type(0))
    WVPASSEQ(type(x[1]), type(0))

    WVPASSEQ(xstat.fstime_floor_secs(0), 0)
    WVPASSEQ(xstat.fstime_floor_secs(10**9 / 2), 0)
    WVPASSEQ(xstat.fstime_floor_secs(10**9), 1)
    WVPASSEQ(xstat.fstime_floor_secs(-10**9 / 2), -1)
    WVPASSEQ(xstat.fstime_floor_secs(-10**9), -1)
    WVPASSEQ(type(xstat.fstime_floor_secs(10**9 / 2)), type(0))
    WVPASSEQ(type(xstat.fstime_floor_secs(-10**9 / 2)), type(0))
Exemple #5
0
def test_fstime():
    WVPASSEQ(xstat.timespec_to_nsecs((0, 0)), 0)
    WVPASSEQ(xstat.timespec_to_nsecs((1, 0)), 10**9)
    WVPASSEQ(xstat.timespec_to_nsecs((0, 10**9 / 2)), 500000000)
    WVPASSEQ(xstat.timespec_to_nsecs((1, 10**9 / 2)), 1500000000)
    WVPASSEQ(xstat.timespec_to_nsecs((-1, 0)), -10**9)
    WVPASSEQ(xstat.timespec_to_nsecs((-1, 10**9 / 2)), -500000000)
    WVPASSEQ(xstat.timespec_to_nsecs((-2, 10**9 / 2)), -1500000000)
    WVEXCEPT(Exception, xstat.timespec_to_nsecs, (0, -1))
    WVPASSEQ(type(xstat.timespec_to_nsecs((2, 22222222))), type(0))
    WVPASSEQ(type(xstat.timespec_to_nsecs((-2, 22222222))), type(0))

    WVPASSEQ(xstat.nsecs_to_timespec(0), (0, 0))
    WVPASSEQ(xstat.nsecs_to_timespec(10**9), (1, 0))
    WVPASSEQ(xstat.nsecs_to_timespec(500000000), (0, 10**9 / 2))
    WVPASSEQ(xstat.nsecs_to_timespec(1500000000), (1, 10**9 / 2))
    WVPASSEQ(xstat.nsecs_to_timespec(-10**9), (-1, 0))
    WVPASSEQ(xstat.nsecs_to_timespec(-500000000), (-1, 10**9 / 2))
    WVPASSEQ(xstat.nsecs_to_timespec(-1500000000), (-2, 10**9 / 2))
    x = xstat.nsecs_to_timespec(1977777778)
    WVPASSEQ(type(x[0]), type(0))
    WVPASSEQ(type(x[1]), type(0))
    x = xstat.nsecs_to_timespec(-1977777778)
    WVPASSEQ(type(x[0]), type(0))
    WVPASSEQ(type(x[1]), type(0))

    WVPASSEQ(xstat.fstime_floor_secs(0), 0)
    WVPASSEQ(xstat.fstime_floor_secs(10**9 / 2), 0)
    WVPASSEQ(xstat.fstime_floor_secs(10**9), 1)
    WVPASSEQ(xstat.fstime_floor_secs(-10**9 / 2), -1)
    WVPASSEQ(xstat.fstime_floor_secs(-10**9), -1)
    WVPASSEQ(type(xstat.fstime_floor_secs(10**9 / 2)), type(0))
    WVPASSEQ(type(xstat.fstime_floor_secs(-10**9 / 2)), type(0))
Exemple #6
0
 def packed(self):
     try:
         ctime = xstat.nsecs_to_timespec(self.ctime)
         mtime = xstat.nsecs_to_timespec(self.mtime)
         atime = xstat.nsecs_to_timespec(self.atime)
         return struct.pack(INDEX_SIG, self.dev, self.ino, self.nlink,
                            ctime[0], ctime[1], mtime[0], mtime[1],
                            atime[0], atime[1], self.size, self.mode,
                            self.gitmode, self.sha, self.flags,
                            self.children_ofs, self.children_n,
                            self.meta_ofs)
     except (DeprecationWarning, struct.error) as e:
         log('pack error: %s (%r)\n' % (e, self))
         raise
Exemple #7
0
 def _encode_common(self):
     atime = xstat.nsecs_to_timespec(self.atime)
     mtime = xstat.nsecs_to_timespec(self.mtime)
     ctime = xstat.nsecs_to_timespec(self.ctime)
     result = vint.pack('VVsVsVvVvVvV',
                        self.mode,
                        self.uid,
                        self.owner,
                        self.gid,
                        self.group,
                        self.rdev,
                        atime[0],
                        atime[1],
                        mtime[0],
                        mtime[1],
                        ctime[0],
                        ctime[1])
     return result
Exemple #8
0
def test_fstime():
    with no_lingering_errors():
        WVPASSEQ(xstat.timespec_to_nsecs((0, 0)), 0)
        WVPASSEQ(xstat.timespec_to_nsecs((1, 0)), 10**9)
        WVPASSEQ(xstat.timespec_to_nsecs((0, 10**9 / 2)), 500000000)
        WVPASSEQ(xstat.timespec_to_nsecs((1, 10**9 / 2)), 1500000000)
        WVPASSEQ(xstat.timespec_to_nsecs((-1, 0)), -10**9)
        WVPASSEQ(xstat.timespec_to_nsecs((-1, 10**9 / 2)), -500000000)
        WVPASSEQ(xstat.timespec_to_nsecs((-2, 10**9 / 2)), -1500000000)
        WVPASSEQ(xstat.timespec_to_nsecs((0, -1)), -1)
        WVPASSEQ(type(xstat.timespec_to_nsecs((2, 22222222))), type(0))
        WVPASSEQ(type(xstat.timespec_to_nsecs((-2, 22222222))), type(0))

        WVPASSEQ(xstat.nsecs_to_timespec(0), (0, 0))
        WVPASSEQ(xstat.nsecs_to_timespec(10**9), (1, 0))
        WVPASSEQ(xstat.nsecs_to_timespec(500000000), (0, 10**9 / 2))
        WVPASSEQ(xstat.nsecs_to_timespec(1500000000), (1, 10**9 / 2))
        WVPASSEQ(xstat.nsecs_to_timespec(-10**9), (-1, 0))
        WVPASSEQ(xstat.nsecs_to_timespec(-500000000), (-1, 10**9 / 2))
        WVPASSEQ(xstat.nsecs_to_timespec(-1500000000), (-2, 10**9 / 2))
        x = xstat.nsecs_to_timespec(1977777778)
        WVPASSEQ(type(x[0]), type(0))
        WVPASSEQ(type(x[1]), type(0))
        x = xstat.nsecs_to_timespec(-1977777778)
        WVPASSEQ(type(x[0]), type(0))
        WVPASSEQ(type(x[1]), type(0))

        WVPASSEQ(xstat.nsecs_to_timeval(0), (0, 0))
        WVPASSEQ(xstat.nsecs_to_timeval(10**9), (1, 0))
        WVPASSEQ(xstat.nsecs_to_timeval(500000000), (0, (10**9 / 2) / 1000))
        WVPASSEQ(xstat.nsecs_to_timeval(1500000000), (1, (10**9 / 2) / 1000))
        WVPASSEQ(xstat.nsecs_to_timeval(-10**9), (-1, 0))
        WVPASSEQ(xstat.nsecs_to_timeval(-500000000), (-1, (10**9 / 2) / 1000))
        WVPASSEQ(xstat.nsecs_to_timeval(-1500000000), (-2, (10**9 / 2) / 1000))
        x = xstat.nsecs_to_timeval(1977777778)
        WVPASSEQ(type(x[0]), type(0))
        WVPASSEQ(type(x[1]), type(0))
        x = xstat.nsecs_to_timeval(-1977777778)
        WVPASSEQ(type(x[0]), type(0))
        WVPASSEQ(type(x[1]), type(0))

        WVPASSEQ(xstat.fstime_floor_secs(0), 0)
        WVPASSEQ(xstat.fstime_floor_secs(10**9 / 2), 0)
        WVPASSEQ(xstat.fstime_floor_secs(10**9), 1)
        WVPASSEQ(xstat.fstime_floor_secs(-10**9 / 2), -1)
        WVPASSEQ(xstat.fstime_floor_secs(-10**9), -1)
        WVPASSEQ(type(xstat.fstime_floor_secs(10**9 / 2)), type(0))
        WVPASSEQ(type(xstat.fstime_floor_secs(-10**9 / 2)), type(0))
Exemple #9
0
def test_fstime():
    with no_lingering_errors():
        WVPASSEQ(xstat.timespec_to_nsecs((0, 0)), 0)
        WVPASSEQ(xstat.timespec_to_nsecs((1, 0)), 10**9)
        WVPASSEQ(xstat.timespec_to_nsecs((0, 10**9 / 2)), 500000000)
        WVPASSEQ(xstat.timespec_to_nsecs((1, 10**9 / 2)), 1500000000)
        WVPASSEQ(xstat.timespec_to_nsecs((-1, 0)), -10**9)
        WVPASSEQ(xstat.timespec_to_nsecs((-1, 10**9 / 2)), -500000000)
        WVPASSEQ(xstat.timespec_to_nsecs((-2, 10**9 / 2)), -1500000000)
        WVPASSEQ(xstat.timespec_to_nsecs((0, -1)), -1)
        WVPASSEQ(type(xstat.timespec_to_nsecs((2, 22222222))), type(0))
        WVPASSEQ(type(xstat.timespec_to_nsecs((-2, 22222222))), type(0))

        WVPASSEQ(xstat.nsecs_to_timespec(0), (0, 0))
        WVPASSEQ(xstat.nsecs_to_timespec(10**9), (1, 0))
        WVPASSEQ(xstat.nsecs_to_timespec(500000000), (0, 10**9 / 2))
        WVPASSEQ(xstat.nsecs_to_timespec(1500000000), (1, 10**9 / 2))
        WVPASSEQ(xstat.nsecs_to_timespec(-10**9), (-1, 0))
        WVPASSEQ(xstat.nsecs_to_timespec(-500000000), (-1, 10**9 / 2))
        WVPASSEQ(xstat.nsecs_to_timespec(-1500000000), (-2, 10**9 / 2))
        x = xstat.nsecs_to_timespec(1977777778)
        WVPASSEQ(type(x[0]), type(0))
        WVPASSEQ(type(x[1]), type(0))
        x = xstat.nsecs_to_timespec(-1977777778)
        WVPASSEQ(type(x[0]), type(0))
        WVPASSEQ(type(x[1]), type(0))

        WVPASSEQ(xstat.nsecs_to_timeval(0), (0, 0))
        WVPASSEQ(xstat.nsecs_to_timeval(10**9), (1, 0))
        WVPASSEQ(xstat.nsecs_to_timeval(500000000), (0, (10**9 / 2) / 1000))
        WVPASSEQ(xstat.nsecs_to_timeval(1500000000), (1, (10**9 / 2) / 1000))
        WVPASSEQ(xstat.nsecs_to_timeval(-10**9), (-1, 0))
        WVPASSEQ(xstat.nsecs_to_timeval(-500000000), (-1, (10**9 / 2) / 1000))
        WVPASSEQ(xstat.nsecs_to_timeval(-1500000000), (-2, (10**9 / 2) / 1000))
        x = xstat.nsecs_to_timeval(1977777778)
        WVPASSEQ(type(x[0]), type(0))
        WVPASSEQ(type(x[1]), type(0))
        x = xstat.nsecs_to_timeval(-1977777778)
        WVPASSEQ(type(x[0]), type(0))
        WVPASSEQ(type(x[1]), type(0))

        WVPASSEQ(xstat.fstime_floor_secs(0), 0)
        WVPASSEQ(xstat.fstime_floor_secs(10**9 / 2), 0)
        WVPASSEQ(xstat.fstime_floor_secs(10**9), 1)
        WVPASSEQ(xstat.fstime_floor_secs(-10**9 / 2), -1)
        WVPASSEQ(xstat.fstime_floor_secs(-10**9), -1)
        WVPASSEQ(type(xstat.fstime_floor_secs(10**9 / 2)), type(0))
        WVPASSEQ(type(xstat.fstime_floor_secs(-10**9 / 2)), type(0))
Exemple #10
0
 def _encode_common(self):
     if not self.mode:
         return None
     atime = xstat.nsecs_to_timespec(self.atime)
     mtime = xstat.nsecs_to_timespec(self.mtime)
     ctime = xstat.nsecs_to_timespec(self.ctime)
     result = vint.pack('vvsvsvvVvVvV',
                        self.mode,
                        self.uid,
                        self.user,
                        self.gid,
                        self.group,
                        self.rdev,
                        atime[0],
                        atime[1],
                        mtime[0],
                        mtime[1],
                        ctime[0],
                        ctime[1])
     return result