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"
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):
pending = [name for time,name in \
list_pending_snapshots(self._propName) if \
name.find(snapshot.fsname + '@') == 0]
- cmd = [zfs.PFCMD, zfs.ZFSCMD, "inherit", self._propName]
+ cmd = [zfs.ZFSCMD, "inherit", self._propName]
util.debug("Unqueuing pending backups of deselected " \
"filesystem: " + snapshot.fsname + '\n' + \
str(pending),
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)
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)
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:]
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]:
link + ".lock")
if not os.path.exists(lockFileDir):
- os.makedirs(lockFileDir, 0755)
+ os.makedirs(lockFileDir, 0o755)
try:
lockFp = open(lockFile, 'w')
# 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)
# 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
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)
dirName + ".lock")
if not os.path.exists(lockFileDir):
- os.makedirs(lockFileDir, 0755)
+ os.makedirs(lockFileDir, 0o755)
try:
lockFp = open(lockFile, 'w')
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
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')