simple-repo #1
1 changed files with 155 additions and 141 deletions
|
@ -32,7 +32,12 @@ except:
|
||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
import dbus.service
|
import dbus.service
|
||||||
import dbus.glib
|
# deprecated
|
||||||
|
#import dbus.glib
|
||||||
|
# replaces by this 2 lines
|
||||||
|
from dbus.mainloop.glib import DBusGMainLoop
|
||||||
|
DBusGMainLoop(set_as_default=True)
|
||||||
|
|
||||||
from mkbackup.system_notification_emitter import Emitter
|
from mkbackup.system_notification_emitter import Emitter
|
||||||
from mkbackup.mkbackup_emitter import Emitter as EM
|
from mkbackup.mkbackup_emitter import Emitter as EM
|
||||||
|
|
||||||
|
@ -43,6 +48,10 @@ from mkbackup.mkbackup_btrfs_config import __version__ as confversion
|
||||||
__author__ = "Jakobus Schürz <jakob@schuerz.at>"
|
__author__ = "Jakobus Schürz <jakob@schuerz.at>"
|
||||||
__version__ = "1.01.0"
|
__version__ = "1.01.0"
|
||||||
|
|
||||||
|
class EmDBUSDesktop(EM):
|
||||||
|
def __init__(self):
|
||||||
|
super().__init__(conn=dbus.SystemBus(), object_path='/at/xundeenergie/notifications/advanced')
|
||||||
|
|
||||||
class Notification(Emitter):
|
class Notification(Emitter):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__(conn=dbus.SystemBus(), object_path='/at/xundeenergie/notifications/advanced/Notification')
|
super().__init__(conn=dbus.SystemBus(), object_path='/at/xundeenergie/notifications/advanced/Notification')
|
||||||
|
@ -131,15 +140,15 @@ def check_lockfile(args,lf):
|
||||||
file.close()
|
file.close()
|
||||||
#if len(pid) > 0 and Myos().path_isfile('/proc/'+pid+'/cmdline',args.config.ssh[args.tag][st]):
|
#if len(pid) > 0 and Myos().path_isfile('/proc/'+pid+'/cmdline',args.config.ssh[args.tag][st]):
|
||||||
if len(pid) > 0 and os.path.isfile('/proc/'+pid+'/cmdline'):
|
if len(pid) > 0 and os.path.isfile('/proc/'+pid+'/cmdline'):
|
||||||
logger.warn('lockfile %s in use with process %s' % (lf,pid))
|
logger.warning('lockfile %s in use with process %s' % (lf,pid))
|
||||||
#DEBUG('lockfile %s in use with process %s' % (lf,pid),level=3,verbose=args.verbose)
|
#DEBUG('lockfile %s in use with process %s' % (lf,pid),level=3,verbose=args.verbose)
|
||||||
return(True)
|
return(True)
|
||||||
else:
|
else:
|
||||||
logger.warn('lockfile %s unused' % (lf))
|
logger.warning('lockfile %s unused' % (lf))
|
||||||
#DEBUG('lockfile %s unused' % (lf),level=3,verbose=args.verbose)
|
#DEBUG('lockfile %s unused' % (lf),level=3,verbose=args.verbose)
|
||||||
return(False)
|
return(False)
|
||||||
else:
|
else:
|
||||||
logger.warn('lockfile %s not existing' % (lf))
|
logger.warning('lockfile %s not existing' % (lf))
|
||||||
#DEBUG('lockfile %s not existing' % (lf),level=3,verbose=args.verbose)
|
#DEBUG('lockfile %s not existing' % (lf),level=3,verbose=args.verbose)
|
||||||
return(None)
|
return(None)
|
||||||
|
|
||||||
|
@ -222,7 +231,7 @@ class BtrfsListing:
|
||||||
self.scanfs()
|
self.scanfs()
|
||||||
|
|
||||||
def scanfs(self):
|
def scanfs(self):
|
||||||
logger.warn('SCAN btrfs-drive: %s' % (self.StorePath))
|
logger.warning('SCAN btrfs-drive: %s' % (self.StorePath))
|
||||||
if self.single:
|
if self.single:
|
||||||
cmd=['btrfs','subvolume','list','-R','-u','-q','-c','-o',self.StorePath]
|
cmd=['btrfs','subvolume','list','-R','-u','-q','-c','-o',self.StorePath]
|
||||||
else:
|
else:
|
||||||
|
@ -480,13 +489,13 @@ class SubVolume(SubVolumeInfo):
|
||||||
self.SnapLock = self.SnapName+'.part'
|
self.SnapLock = self.SnapName+'.part'
|
||||||
self.SLockFile = '.'+self.SnapName+'.~lock'
|
self.SLockFile = '.'+self.SnapName+'.~lock'
|
||||||
self.SnapID = None
|
self.SnapID = None
|
||||||
logger.warn('OrigName : %s' % (self.OrigName))
|
logger.warning('OrigName : %s' % (self.OrigName))
|
||||||
logger.warn('SourceName: %s' % (self.SourceName))
|
logger.warning('SourceName: %s' % (self.SourceName))
|
||||||
logger.warn('OrigLock : %s' % (self.OrigLock))
|
logger.warning('OrigLock : %s' % (self.OrigLock))
|
||||||
logger.warn('OLockFile : %s' % (self.OLockFile))
|
logger.warning('OLockFile : %s' % (self.OLockFile))
|
||||||
logger.warn('SnapName : %s' % (self.SnapName))
|
logger.warning('SnapName : %s' % (self.SnapName))
|
||||||
logger.warn('SnapLock : %s' % (self.SnapLock))
|
logger.warning('SnapLock : %s' % (self.SnapLock))
|
||||||
logger.warn('SLockFile : %s' % (self.SLockFile))
|
logger.warning('SLockFile : %s' % (self.SLockFile))
|
||||||
|
|
||||||
self.parent = ''
|
self.parent = ''
|
||||||
self.subvolsshort = []
|
self.subvolsshort = []
|
||||||
|
@ -1666,19 +1675,18 @@ def restore(args):
|
||||||
#class desktop_notification:
|
#class desktop_notification:
|
||||||
# def __init__(self, args, urgency=1):
|
# def __init__(self, args, urgency=1):
|
||||||
# self.args = args
|
# self.args = args
|
||||||
# self.dbus_path = "/at/xundeenergie/notifications"
|
# self.dbus_path = "/at/xundeenergie/notifications/advanced"
|
||||||
# self.dbus_iface = "at.xundeenergie.notifications.advanced"
|
# self.dbus_iface = "at.xundeenergie.Notification"
|
||||||
# self.dbus_busname = "at.xundeenergie.notifications"
|
|
||||||
# self.timestamp = datetime.datetime.now()
|
# self.timestamp = datetime.datetime.now()
|
||||||
# self.time = self.timestamp.strftime('%H:%M:%S')
|
# self.time = self.timestamp.strftime('%H:%M:%S')
|
||||||
# self.date = self.timestamp.strftime('%d. %B %Y')
|
# self.date = self.timestamp.strftime('%d. %B %Y')
|
||||||
# self.bus = dbus.SystemBus()
|
# self.bus = dbus.SystemBus()
|
||||||
# if int(urgency) == 0:
|
# if int(urgency) == 0:
|
||||||
# self.signal_name = 'Notification_low'
|
# self.signal_name = 'low'
|
||||||
# elif int(urgency) == 1:
|
# elif int(urgency) == 1:
|
||||||
# self.signal_name = 'Notification_normal'
|
# self.signal_name = 'normal'
|
||||||
# else:
|
# else:
|
||||||
# self.signal_name = 'Notification_critical'
|
# self.signal_name = 'critical'
|
||||||
# print('NO',int(urgency),self.signal_name)
|
# print('NO',int(urgency),self.signal_name)
|
||||||
#
|
#
|
||||||
# def send_signal(self, intv='default', *args):
|
# def send_signal(self, intv='default', *args):
|
||||||
|
@ -1694,7 +1702,8 @@ def restore(args):
|
||||||
#""" % (self.date, self.time, '\n'.join(args), self.signal_name)
|
#""" % (self.date, self.time, '\n'.join(args), self.signal_name)
|
||||||
# msg['expiration_timeout'] = '-1'
|
# msg['expiration_timeout'] = '-1'
|
||||||
# message = dbus.lowlevel.SignalMessage(self.dbus_path, self.dbus_iface, self.signal_name)
|
# message = dbus.lowlevel.SignalMessage(self.dbus_path, self.dbus_iface, self.signal_name)
|
||||||
# message.append(msg)
|
# #message.append(msg)
|
||||||
|
# message.append({'body': 'blafoo'})
|
||||||
# self.bus.send_message(message)
|
# self.bus.send_message(message)
|
||||||
|
|
||||||
# PARSER
|
# PARSER
|
||||||
|
@ -1887,7 +1896,7 @@ if __name__ == '__main__':
|
||||||
# 'application' code
|
# 'application' code
|
||||||
logger.debug('debug message')
|
logger.debug('debug message')
|
||||||
logger.info('info message')
|
logger.info('info message')
|
||||||
logger.warn('warn message')
|
logger.warning('warn message')
|
||||||
logger.error('error message')
|
logger.error('error message')
|
||||||
logger.critical('critical message')
|
logger.critical('critical message')
|
||||||
|
|
||||||
|
@ -1957,7 +1966,7 @@ if __name__ == '__main__':
|
||||||
for st in args.store:
|
for st in args.store:
|
||||||
args.sourcepath[st] = args.config.getStorePath(st,args.tag)
|
args.sourcepath[st] = args.config.getStorePath(st,args.tag)
|
||||||
args.destpath[st] = args.config.getStorePath(st,args.tag)
|
args.destpath[st] = args.config.getStorePath(st,args.tag)
|
||||||
logger.warn('''Action is %s
|
logger.warning('''Action is %s
|
||||||
Source is %s
|
Source is %s
|
||||||
Destination is %s''' % (args.action,args.sourcepath,args.destpath))
|
Destination is %s''' % (args.action,args.sourcepath,args.destpath))
|
||||||
else:
|
else:
|
||||||
|
@ -2008,6 +2017,12 @@ Author: %s""" % (confversion,__version__,__author__))
|
||||||
args.mdb = EmDBUS()
|
args.mdb = EmDBUS()
|
||||||
args.mdb.reset(args.tag)
|
args.mdb.reset(args.tag)
|
||||||
args.mdb.start(args.tag)
|
args.mdb.start(args.tag)
|
||||||
|
args.mdbd = EmDBUSDesktop()
|
||||||
|
# msg = dict()
|
||||||
|
# msg['sender'] = "mkbackup"
|
||||||
|
# msg['header'] = "%s-backup" % (args.tag)
|
||||||
|
# msg['body'] = "Start"
|
||||||
|
# args.mdbd.critical(msg)
|
||||||
#################################################################
|
#################################################################
|
||||||
## Run action ##
|
## Run action ##
|
||||||
#################################################################
|
#################################################################
|
||||||
|
@ -2119,8 +2134,6 @@ snapshots: %s
|
||||||
um %s Uhr abgeschlossen.
|
um %s Uhr abgeschlossen.
|
||||||
|
|
||||||
%s
|
%s
|
||||||
http://www.google.com
|
|
||||||
<a href="file:///home/jakob/backup">TEST</a>
|
|
||||||
(Ugency: normal)
|
(Ugency: normal)
|
||||||
""" % (args.ts.strftime('%Y-%m-%d'), args.ts.strftime('%H:%M:%S'), '\r'.join(volumes))
|
""" % (args.ts.strftime('%Y-%m-%d'), args.ts.strftime('%H:%M:%S'), '\r'.join(volumes))
|
||||||
# msg['action'] = dict()
|
# msg['action'] = dict()
|
||||||
|
@ -2131,6 +2144,7 @@ http://www.google.com
|
||||||
|
|
||||||
advnotify = Notification()
|
advnotify = Notification()
|
||||||
advnotify.normal(msg)
|
advnotify.normal(msg)
|
||||||
|
args.mdbd.critical(msg)
|
||||||
elif args.notification == None:
|
elif args.notification == None:
|
||||||
logger.critical("No notification at all")
|
logger.critical("No notification at all")
|
||||||
else:
|
else:
|
||||||
|
@ -2153,4 +2167,4 @@ http://www.google.com
|
||||||
# msg = """
|
# msg = """
|
||||||
# Hello!""" # The /n separates the message from the headers
|
# Hello!""" # The /n separates the message from the headers
|
||||||
# server.sendmail("first.recipient@provider1.example", "second.recipient@provider2.example", msg)
|
# server.sendmail("first.recipient@provider1.example", "second.recipient@provider2.example", msg)
|
||||||
#
|
#header
|
||||||
|
|
Loading…
Reference in a new issue