Skip to content
Permalink
Browse files

Switch time-slider to Python 3.5

  • Loading branch information...
pyhalov committed Apr 8, 2019
1 parent f4dad0b commit 2f6c4d9592723f3ee22f27e5e924e54bc4d83c32
Showing with 1,416 additions and 1,388 deletions.
  1. +7 −7 Makefile
  2. +1 −1 usr/bin/time-slider-setup
  3. +1 −1 usr/lib/time-slider-delete
  4. +1 −1 usr/lib/time-slider-notify
  5. +1 −1 usr/lib/time-slider-snapshot
  6. +1 −1 usr/lib/time-slider-version
  7. +1 −1 usr/lib/time-slider/plugins/rsync/rsync-backup
  8. +1 −1 usr/lib/time-slider/plugins/rsync/rsync-trigger
  9. +1 −1 usr/lib/time-slider/plugins/zfssend/zfssend
  10. +1 −1 usr/lib/time-sliderd
  11. +16 −14 usr/share/time-slider/lib/plugin/plugin.py
  12. +1 −1 usr/share/time-slider/lib/plugin/pluginsmf.py
  13. +30 −27 usr/share/time-slider/lib/plugin/rsync/backup.py
  14. +1 −1 usr/share/time-slider/lib/plugin/rsync/rsyncsmf.py
  15. +3 −3 usr/share/time-slider/lib/plugin/rsync/trigger.py
  16. +7 −8 usr/share/time-slider/lib/plugin/zfssend/zfssend.py
  17. +2 −2 usr/share/time-slider/lib/time_slider/__init__.py
  18. +57 −57 usr/share/time-slider/lib/time_slider/applet.py
  19. +13 −13 usr/share/time-slider/lib/time_slider/autosnapsmf.py
  20. +1 −1 usr/share/time-slider/lib/time_slider/dbussvc.py
  21. +82 −94 usr/share/time-slider/lib/time_slider/deletegui.py
  22. +228 −240 usr/share/time-slider/lib/time_slider/fileversion.py
  23. +6 −6 usr/share/time-slider/lib/time_slider/rbac.py
  24. +119 −132 usr/share/time-slider/lib/time_slider/setupgui.py
  25. +3 −3 usr/share/time-slider/lib/time_slider/smf.py
  26. +121 −118 usr/share/time-slider/lib/time_slider/snapnowui.py
  27. +60 −58 usr/share/time-slider/lib/time_slider/timesliderd.py
  28. +6 −6 usr/share/time-slider/lib/time_slider/timeslidersmf.py
  29. +17 −18 usr/share/time-slider/lib/time_slider/util.py
  30. +43 −40 usr/share/time-slider/lib/time_slider/zfs.py
  31. +357 −291 usr/share/time-slider/{glade/time-slider-delete.glade → ui/time-slider-delete.ui}
  32. +120 −123 usr/share/time-slider/{glade/time-slider-setup.glade → ui/time-slider-setup.ui}
  33. +34 −33 usr/share/time-slider/{glade/time-slider-snapshot.glade → ui/time-slider-snapshot.ui}
  34. +73 −83 usr/share/time-slider/{glade/time-slider-version.glade → ui/time-slider-version.ui}
@@ -8,9 +8,9 @@ INSTALL_SCRIPT = ${INSTALL} -f
RM = /usr/bin/rm -f
RMRF = /usr/bin/rm -Rf
RMDIR = /usr/bin/rmdir
# Use python 2.7 if PYTHON environent is not set
# Use python 3.5 if PYTHON environent is not set
ifeq ($(strip $(PYTHON)),)
PYTHON = /usr/bin/python2.7
PYTHON = /usr/bin/python3.5
endif

SUBDIRS = po data
@@ -86,11 +86,11 @@ install:
$(INSTALL_DATA) $(DESTDIR)/usr/share/icons/hicolor/72x72/apps usr/share/icons/hicolor/72x72/apps/time-slider-setup.png
$(mkinstalldirs) $(DESTDIR)/usr/share/icons/hicolor/96x96/apps
$(INSTALL_DATA) $(DESTDIR)/usr/share/icons/hicolor/96x96/apps usr/share/icons/hicolor/96x96/apps/time-slider-setup.png
$(mkinstalldirs) $(DESTDIR)/usr/share/time-slider/glade
$(INSTALL_DATA) $(DESTDIR)/usr/share/time-slider/glade usr/share/time-slider/glade/time-slider-delete.glade
$(INSTALL_DATA) $(DESTDIR)/usr/share/time-slider/glade usr/share/time-slider/glade/time-slider-setup.glade
$(INSTALL_DATA) $(DESTDIR)/usr/share/time-slider/glade usr/share/time-slider/glade/time-slider-snapshot.glade
$(INSTALL_DATA) $(DESTDIR)/usr/share/time-slider/glade usr/share/time-slider/glade/time-slider-version.glade
$(mkinstalldirs) $(DESTDIR)/usr/share/time-slider/ui
$(INSTALL_DATA) $(DESTDIR)/usr/share/time-slider/ui usr/share/time-slider/ui/time-slider-delete.ui
$(INSTALL_DATA) $(DESTDIR)/usr/share/time-slider/ui usr/share/time-slider/ui/time-slider-setup.ui
$(INSTALL_DATA) $(DESTDIR)/usr/share/time-slider/ui usr/share/time-slider/ui/time-slider-snapshot.ui
$(INSTALL_DATA) $(DESTDIR)/usr/share/time-slider/ui usr/share/time-slider/ui/time-slider-version.ui
$(mkinstalldirs) $(DESTDIR)/usr/share/time-slider/lib/time_slider
for file in usr/share/time-slider/lib/time_slider/*.py; do \
if test -f $$file ; then \
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5

import sys
from os.path import dirname, join, pardir, abspath
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5

import sys
from os.path import dirname, join, pardir, abspath
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5

import sys
from os.path import dirname, join, pardir, abspath
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5

import sys
from os.path import dirname, join, pardir, abspath
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5

import sys
from os.path import dirname, join, pardir, abspath
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5
import sys
from os.path import dirname, join, pardir, abspath
sys.path.insert(0, join(dirname(__file__), pardir, pardir, pardir, pardir,
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5
import sys
from os.path import dirname, join, pardir, abspath
sys.path.insert(0, join(dirname(__file__), pardir, pardir, pardir, pardir,
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5
import sys
from os.path import dirname, join, pardir, abspath
sys.path.insert(0, join(dirname(__file__), pardir, pardir, pardir, pardir,
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5
import sys
from os.path import dirname, join, pardir, abspath
sys.path.insert(0, join(dirname(__file__), pardir, 'share',
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5
#
# CDDL HEADER START
#
@@ -46,15 +46,15 @@ def __init__(self, instanceName, debug=False):
command = self.smfInst.get_trigger_command()
try:
statinfo = os.stat(command)
other_x = (statinfo.st_mode & 01)
other_x = (statinfo.st_mode & 0o1)
if other_x == 0:
raise RuntimeError, 'Plugin: %s:\nConfigured trigger command is not ' \
raise RuntimeError('Plugin: %s:\nConfigured trigger command is not ' \
'executable:\n%s' \
% (self.smfInst.instanceName, command)
% (self.smfInst.instanceName, command))
except OSError:
raise RuntimeError, 'Plugin: %s:\nCan not access the configured ' \
raise RuntimeError('Plugin: %s:\nCan not access the configured ' \
'plugin/trigger_command:\n%s' \
% (self.smfInst.instanceName, command)
% (self.smfInst.instanceName, command))


def execute(self, schedule, label):
@@ -95,10 +95,11 @@ def execute(self, schedule, label):
self._proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True)
except OSError, message:
raise RuntimeError, "%s subprocess error:\n %s" % \
(cmd, str(message))
close_fds=True,
universal_newlines=True)
except OSError as message:
raise RuntimeError("%s subprocess error:\n %s" % \
(cmd, str(message)))
self._proc = None

def is_running(self):
@@ -137,13 +138,14 @@ def refresh(self):
p = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
close_fds=True)
close_fds=True,
universal_newlines=True)
outdata,errdata = p.communicate()
err = p.wait()
if err != 0:
self._refreshLock.release()
raise RuntimeError, '%s failed with exit code %d\n%s' % \
(str(cmd), err, errdata)
raise RuntimeError('%s failed with exit code %d\n%s' % \
(str(cmd), err, errdata))
for line in outdata.rstrip().split('\n'):
line = line.rstrip().split()
state = line[0]
@@ -158,7 +160,7 @@ def refresh(self):
try:
plugin = Plugin(fmri, self.verbose)
self.plugins.append(plugin)
except RuntimeError, message:
except RuntimeError as message:
sys.stderr.write("Ignoring misconfigured plugin: %s\n" \
% (fmri))
sys.stderr.write("Reason:\n%s\n" % (message))
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5
#
# CDDL HEADER START
#
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5
#
# CDDL HEADER START
#
@@ -26,20 +26,23 @@
import tempfile
import sys
import subprocess
import statvfs
import time
import threading
import math
import syslog
import gobject
import gio
import dbus
import shutil
import copy
from bisect import insort, bisect_left

from time_slider import util, zfs, dbussvc, autosnapsmf, timeslidersmf
import rsyncsmf
from rsync import rsyncsmf

try:
import gi
from gi.repository import GObject, Gio
except:
sys.exit(1)


verboseprop = "plugin/verbose"
@@ -118,7 +121,8 @@ def run(self):
try:
self._proc = subprocess.Popen(self._cmd,
stderr=subprocess.PIPE,
close_fds=True)
close_fds=True,
universal_newlines=True)
except OSError as e:
# _check_exit_code() will pick up this and raise an
# exception in the original thread.
@@ -407,7 +411,7 @@ def _discover_backups(self):
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):
@@ -427,7 +431,7 @@ def _find_backup_device(self):
"Scanning removable devices.." \
% (path),
self._verbose)
volMonitor = gio.volume_monitor_get()
volMonitor = Gio.VolumeMonitor.get()
mounts = volMonitor.get_mounts()
for mount in mounts:
root = mount.get_root()
@@ -598,7 +602,7 @@ def _recover_space(self, deleteables):
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)
@@ -619,7 +623,7 @@ def _recover_space(self, deleteables):
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)
@@ -762,7 +766,7 @@ def backup_snapshot(self):
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:]
@@ -834,12 +838,12 @@ def backup_snapshot(self):
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] = {}
@@ -875,7 +879,7 @@ def backup_snapshot(self):
link + ".lock")

if not os.path.exists(lockFileDir):
os.makedirs(lockFileDir, 0755)
os.makedirs(lockFileDir, 0o755)

try:
lockFp = open(lockFile, 'w')
@@ -901,7 +905,7 @@ def backup_snapshot(self):
# 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)
@@ -976,10 +980,10 @@ def backup_snapshot(self):
# 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
@@ -1026,7 +1030,7 @@ def backup_snapshot(self):
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)
@@ -1041,7 +1045,7 @@ def backup_snapshot(self):
dirName + ".lock")

if not os.path.exists(lockFileDir):
os.makedirs(lockFileDir, 0755)
os.makedirs(lockFileDir, 0o755)

try:
lockFp = open(lockFile, 'w')
@@ -1194,7 +1198,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

@@ -1214,9 +1218,9 @@ def main(argv):
# to obtain an exclusive lock on it. If we can't then another
# instance is running and already has a lock on it so just exit.
lockFileDir = os.path.normpath(tempfile.gettempdir() + '/' + \
".time-slider")
".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')
@@ -1241,7 +1245,6 @@ def main(argv):
# Open up a syslog session
syslog.openlog(sys.argv[0], 0, syslog.LOG_DAEMON)

gobject.threads_init()
# Tell dbus to use the gobject mainloop for async ops
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
dbus.mainloop.glib.threads_init()
@@ -1251,9 +1254,9 @@ def main(argv):
dbusObj = dbussvc.RsyncBackup(sysbus, \
"/org/opensolaris/TimeSlider/plugin/rsync")

mainLoop = gobject.MainLoop()
mainLoop = GObject.MainLoop()
backupQueue = BackupQueue(pluginFMRI, dbusObj, mainLoop)
gobject.idle_add(backupQueue.backup_snapshot)
GObject.idle_add(backupQueue.backup_snapshot)
mainLoop.run()
sys.exit(0)

@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5
#
# CDDL HEADER START
#
@@ -1,4 +1,4 @@
#!/usr/bin/python2.7
#!/usr/bin/python3.5
#
# CDDL HEADER START
#
@@ -25,7 +25,7 @@
import subprocess
import syslog

import rsyncsmf
from rsync import rsyncsmf
from time_slider import util, smf, zfs

verboseprop = "plugin/verbose"
@@ -80,7 +80,7 @@ def main(argv):
# First: identify all snapshots matching the AUTOSNAP_LABEL
# value passed in by the time-slider daemon.
#
# Second: Filter out snapshots of volumes, since rsync can only
# Second: Filter out snapshots of volumes, since rsync can only
# back up filesystems.
#
# Third: we need to filter the results and ensure that the

0 comments on commit 2f6c4d9

Please sign in to comment.
You can’t perform that action at this time.