/usr/share/backintime/common/dummytools.py is in backintime-common 1.1.12-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | # Copyright (C) 2012-2016 Germar Reitze
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import gettext
import config
import mount
_=gettext.gettext
class Dummy(mount.MountControl):
"""
This is a template for mounting services. For simple mount services
all you need to do is:
- add your settings in gnome|kde/settingsdialog.py (search for the dummy examples)
- add settings in gnome/settingsdialog.glade (copy GtkFrame 'mode_dummy')
- add settings in common/config.py (search for the dummy examples)
- modify a copy of this file
Please use self.mountpoint as your local mountpoint.
This class inherit from mount.MountControl. All methodes from MountControl can
be used exactly like they were in this class.
Methodes from MountControl also can be overriden in here if you need
something different."""
def __init__(self, cfg = None, profile_id = None, hash_id = None, tmp_mount = False, parent = None, symlink = True, **kwargs):
self.config = cfg
if self.config is None:
self.config = config.Config()
self.profile_id = profile_id
if self.profile_id is None:
self.profile_id = self.config.get_current_profile()
self.tmp_mount = tmp_mount
self.hash_id = hash_id
self.parent = parent
self.symlink = symlink
#init MountControl
super(Dummy, self).__init__()
self.all_kwargs = {}
#First we need to map the settings.
#If <arg> is in kwargs (e.g. if this class is called with dummytools.Dummy(<arg> = <value>)
#this will map self.<arg> to kwargs[<arg>]; else self.<arg> = <default> from config
#e.g. self.setattr_kwargs(<arg>, <default>, **kwargs)
self.setattr_kwargs('mode', self.config.get_snapshots_mode(self.profile_id), **kwargs)
self.setattr_kwargs('hash_collision', self.config.get_hash_collision(), **kwargs)
#start editing from here---------------------------------------------------------
self.setattr_kwargs('user', self.config.get_dummy_user(self.profile_id), **kwargs)
self.setattr_kwargs('host', self.config.get_dummy_host(self.profile_id), **kwargs)
self.setattr_kwargs('port', self.config.get_dummy_port(self.profile_id), **kwargs)
self.setattr_kwargs('password', self.config.get_password(parent, self.profile_id), store = False, **kwargs)
self.set_default_args()
#if self.mountpoint is not the remote snapshot path you can specify
#a subfolder of self.mountpoint for the symlink
self.symlink_subfolder = None
self.log_command = '%s: %s@%s' % (self.mode, self.user, self.host)
def _mount(self):
"""mount the service"""
#implement your mountprocess here
pass
def _umount(self):
"""umount the service"""
#implement your unmountprocess here
pass
def pre_mount_check(self, first_run = False):
"""check what ever conditions must be given for the mount to be done successful
raise MountException( _('Error discription') ) if service can not mount
return True if everything is okay
all pre|post_[u]mount_check can also be used to prepare things or clean up"""
return True
def post_mount_check(self):
"""check if mount was successful
raise MountException( _('Error discription') ) if not"""
return True
def pre_umount_check(self):
"""check if service is safe to umount
raise MountException( _('Error discription') ) if not"""
return True
def post_umount_check(self):
"""check if umount successful
raise MountException( _('Error discription') ) if not"""
return True
|