simple-repo #1
1 changed files with 155 additions and 141 deletions
|
@ -32,7 +32,12 @@ except:
|
|||
|
||||
import dbus
|
||||
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.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>"
|
||||
__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')
|
||||
|
@ -131,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)
|
||||
|
||||
|
@ -222,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:
|
||||
|
@ -480,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 = []
|
||||
|
@ -1666,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):
|
||||
|
@ -1694,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
|
||||
|
@ -1887,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')
|
||||
|
||||
|
@ -1957,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:
|
||||
|
@ -2008,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 ##
|
||||
#################################################################
|
||||
|
@ -2119,8 +2134,6 @@ snapshots: %s
|
|||
um %s Uhr abgeschlossen.
|
||||
|
||||
%s
|
||||
http://www.google.com
|
||||
<a href="file:///home/jakob/backup">TEST</a>
|
||||
(Ugency: normal)
|
||||
""" % (args.ts.strftime('%Y-%m-%d'), args.ts.strftime('%H:%M:%S'), '\r'.join(volumes))
|
||||
# msg['action'] = dict()
|
||||
|
@ -2131,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:
|
||||
|
@ -2153,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
|
||||
|
|
Loading…
Reference in a new issue