X-Git-Url: https://git.camperquake.de/gitweb.cgi?p=time-slider.git;a=blobdiff_plain;f=usr%2Fshare%2Ftime-slider%2Flib%2Fplugin%2Frsync%2Fbackup.py;fp=usr%2Fshare%2Ftime-slider%2Flib%2Fplugin%2Frsync%2Fbackup.py;h=0b403cccdb721799463adfbca1e1c97776c80194;hp=2d1779f3a9fb8f8f3a6426b3c13ceb539d9bc2b1;hb=75feb72a4aa1bf0940b4b2eaddd68c781cdf50ee;hpb=1ad3b546afd04dedd97020e33bd153531b4cdee2 diff --git a/usr/share/time-slider/lib/plugin/rsync/backup.py b/usr/share/time-slider/lib/plugin/rsync/backup.py index 2d1779f..0b403cc 100644 --- a/usr/share/time-slider/lib/plugin/rsync/backup.py +++ b/usr/share/time-slider/lib/plugin/rsync/backup.py @@ -39,7 +39,7 @@ import copy from bisect import insort, bisect_left from time_slider import util, zfs, dbussvc, autosnapsmf, timeslidersmf -import rsyncsmf +from . import rsyncsmf # Set to True if SMF property value of "plugin/command" is "true" @@ -408,7 +408,7 @@ class BackupQueue(): not os.path.islink(d)] for d in dirList: mtime = os.stat(d).st_mtime - insort(self._backups, [long(mtime), os.path.abspath(d)]) + insort(self._backups, [int(mtime), os.path.abspath(d)]) self._backupTimes[dirName][d] = mtime def _find_backup_device(self): @@ -599,7 +599,7 @@ class BackupQueue(): lockFile = os.path.join(lockFileDir, tail) if not os.path.exists(lockFileDir): - os.makedirs(lockFileDir, 0755) + os.makedirs(lockFileDir, 0o755) try: lockFp = open(lockFile, 'w') fcntl.flock(lockFp, fcntl.LOCK_EX | fcntl.LOCK_NB) @@ -620,7 +620,7 @@ class BackupQueue(): trashDir = os.path.join(trash, tail) if not os.path.exists(trash): - os.makedirs(trash, 0755) + os.makedirs(trash, 0o755) util.debug("Deleting rsync backup to recover space: %s"\ % (dirName), self._verbose) @@ -763,7 +763,7 @@ class BackupQueue(): self._bus.rsync_started(self._rsyncBaseDir) ctime,snapName = self._currentQueueSet[0] - snapshot = zfs.Snapshot(snapName, long(ctime)) + snapshot = zfs.Snapshot(snapName, int(ctime)) # Make sure the snapshot didn't get destroyed since we last # checked it. remainingList = self._currentQueueSet[1:] @@ -835,18 +835,18 @@ class BackupQueue(): dirList = [] if not os.path.exists(partialDir): - os.makedirs(partialDir, 0755) + os.makedirs(partialDir, 0o755) if not os.path.exists(logDir): - os.makedirs(logDir, 0755) + os.makedirs(logDir, 0o755) if not os.path.exists(targetDir): - os.makedirs(targetDir, 0755) + os.makedirs(targetDir, 0o755) # Add the new directory to our internal # mtime dictionary and sorted list. self._backupTimes[targetDir] = {} insort(self._backupDirs, targetDir) else: - for name,value in self._backupTimes[targetDir].items(): + for name,value in list(self._backupTimes[targetDir].items()): if ctime > value: if nearestOlder == None or \ value > nearestOlder[1]: @@ -876,7 +876,7 @@ class BackupQueue(): link + ".lock") if not os.path.exists(lockFileDir): - os.makedirs(lockFileDir, 0755) + os.makedirs(lockFileDir, 0o755) try: lockFp = open(lockFile, 'w') @@ -902,7 +902,7 @@ class BackupQueue(): # Set umask temporarily so that rsync backups are read-only to # the owner by default. Rync will override this to match the # permissions of each snapshot as appropriate. - origmask = os.umask(0222) + origmask = os.umask(0o222) util.debug("Starting rsync backup of '%s' to: %s" \ % (sourceDir, partialDir), self._verbose) @@ -977,10 +977,10 @@ class BackupQueue(): # they match the snapshot creation time. This is extremely important # because the backup mechanism relies on it to determine backup times # and nearest matches for incremental rsync (linkDest) - os.utime(backupDir, (long(ctime), long(ctime))) + os.utime(backupDir, (int(ctime), int(ctime))) # Update the dictionary and time sorted list with ctime also - self._backupTimes[targetDir][snapshot.snaplabel] = long(ctime) - insort(self._backups, [long(ctime), os.path.abspath(backupDir)]) + self._backupTimes[targetDir][snapshot.snaplabel] = int(ctime) + insort(self._backups, [int(ctime), os.path.abspath(backupDir)]) snapshot.set_user_property(self._propName, "completed") snapshot.release(self._propName) self._currentQueueSet = remainingList @@ -1027,7 +1027,7 @@ class BackupQueue(): snapshot.fsname, rsyncsmf.RSYNCTRASHSUFFIX) if not os.path.exists(trash): - os.makedirs(trash, 0755) + os.makedirs(trash, 0o755) for mtime,dirName in purgeList: trashDir = os.path.join(trash, dirName) @@ -1042,7 +1042,7 @@ class BackupQueue(): dirName + ".lock") if not os.path.exists(lockFileDir): - os.makedirs(lockFileDir, 0755) + os.makedirs(lockFileDir, 0o755) try: lockFp = open(lockFile, 'w') @@ -1195,7 +1195,7 @@ def list_pending_snapshots(propName): outdata,errdata = util.run_command(cmd) for line in outdata.rstrip().split('\n'): ctimeStr,name = line.split() - insort(sortsnaplist, tuple((long(ctimeStr), name))) + insort(sortsnaplist, tuple((int(ctimeStr), name))) sortsnaplist.reverse() return sortsnaplist @@ -1217,7 +1217,7 @@ def main(argv): lockFileDir = os.path.normpath(tempfile.gettempdir() + '/' + \ ".time-slider") if not os.path.exists(lockFileDir): - os.makedirs(lockFileDir, 0755) + os.makedirs(lockFileDir, 0o755) lockFile = os.path.join(lockFileDir, 'rsync-backup.lock') lockFp = open(lockFile, 'w')