diff --git a/files/usr/local/bin/mkbackup-btrfs b/files/usr/local/bin/mkbackup-btrfs index a0344e2..509bd92 100755 --- a/files/usr/local/bin/mkbackup-btrfs +++ b/files/usr/local/bin/mkbackup-btrfs @@ -48,6 +48,10 @@ from mkbackup.mkbackup_btrfs_config import __version__ as confversion __author__ = "Jakobus Schürz " __version__ = "1.01.0" +class EmDBUSDesktop(EM): + def __init__(self): + super().__init__(conn=dbus.SystemBus(), object_path='/at/xundeenergie/notifications/advanced') + class Notification(Emitter): def __init__(self): super().__init__(conn=dbus.SystemBus(), object_path='/at/xundeenergie/notifications/advanced/Notification') @@ -136,15 +140,15 @@ def check_lockfile(args,lf): file.close() #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'): - 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) return(True) else: - logger.warn('lockfile %s unused' % (lf)) + logger.warning('lockfile %s unused' % (lf)) #DEBUG('lockfile %s unused' % (lf),level=3,verbose=args.verbose) return(False) 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) return(None) @@ -227,7 +231,7 @@ class BtrfsListing: self.scanfs() def scanfs(self): - logger.warn('SCAN btrfs-drive: %s' % (self.StorePath)) + logger.warning('SCAN btrfs-drive: %s' % (self.StorePath)) if self.single: cmd=['btrfs','subvolume','list','-R','-u','-q','-c','-o',self.StorePath] else: @@ -485,13 +489,13 @@ class SubVolume(SubVolumeInfo): self.SnapLock = self.SnapName+'.part' self.SLockFile = '.'+self.SnapName+'.~lock' self.SnapID = None - logger.warn('OrigName : %s' % (self.OrigName)) - logger.warn('SourceName: %s' % (self.SourceName)) - logger.warn('OrigLock : %s' % (self.OrigLock)) - logger.warn('OLockFile : %s' % (self.OLockFile)) - logger.warn('SnapName : %s' % (self.SnapName)) - logger.warn('SnapLock : %s' % (self.SnapLock)) - logger.warn('SLockFile : %s' % (self.SLockFile)) + logger.warning('OrigName : %s' % (self.OrigName)) + logger.warning('SourceName: %s' % (self.SourceName)) + logger.warning('OrigLock : %s' % (self.OrigLock)) + logger.warning('OLockFile : %s' % (self.OLockFile)) + logger.warning('SnapName : %s' % (self.SnapName)) + logger.warning('SnapLock : %s' % (self.SnapLock)) + logger.warning('SLockFile : %s' % (self.SLockFile)) self.parent = '' self.subvolsshort = [] @@ -1671,19 +1675,18 @@ def restore(args): #class desktop_notification: # def __init__(self, args, urgency=1): # self.args = args -# self.dbus_path = "/at/xundeenergie/notifications" -# self.dbus_iface = "at.xundeenergie.notifications.advanced" -# self.dbus_busname = "at.xundeenergie.notifications" +# self.dbus_path = "/at/xundeenergie/notifications/advanced" +# self.dbus_iface = "at.xundeenergie.Notification" # self.timestamp = datetime.datetime.now() # self.time = self.timestamp.strftime('%H:%M:%S') # self.date = self.timestamp.strftime('%d. %B %Y') # self.bus = dbus.SystemBus() # if int(urgency) == 0: -# self.signal_name = 'Notification_low' +# self.signal_name = 'low' # elif int(urgency) == 1: -# self.signal_name = 'Notification_normal' +# self.signal_name = 'normal' # else: -# self.signal_name = 'Notification_critical' +# self.signal_name = 'critical' # print('NO',int(urgency),self.signal_name) # # def send_signal(self, intv='default', *args): @@ -1699,7 +1702,8 @@ def restore(args): #""" % (self.date, self.time, '\n'.join(args), self.signal_name) # msg['expiration_timeout'] = '-1' # 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) # PARSER @@ -1892,7 +1896,7 @@ if __name__ == '__main__': # 'application' code logger.debug('debug message') logger.info('info message') - logger.warn('warn message') + logger.warning('warn message') logger.error('error message') logger.critical('critical message') @@ -1962,7 +1966,7 @@ if __name__ == '__main__': for st in args.store: args.sourcepath[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 Destination is %s''' % (args.action,args.sourcepath,args.destpath)) else: @@ -2013,6 +2017,12 @@ Author: %s""" % (confversion,__version__,__author__)) args.mdb = EmDBUS() args.mdb.reset(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 ## ################################################################# @@ -2124,8 +2134,6 @@ snapshots: %s um %s Uhr abgeschlossen. %s -http://www.google.com -TEST (Ugency: normal) """ % (args.ts.strftime('%Y-%m-%d'), args.ts.strftime('%H:%M:%S'), '\r'.join(volumes)) # msg['action'] = dict() @@ -2136,6 +2144,7 @@ http://www.google.com advnotify = Notification() advnotify.normal(msg) + args.mdbd.critical(msg) elif args.notification == None: logger.critical("No notification at all") else: @@ -2158,4 +2167,4 @@ http://www.google.com # msg = """ # Hello!""" # The /n separates the message from the headers # server.sendmail("first.recipient@provider1.example", "second.recipient@provider2.example", msg) -# +#header