예제 #1
0
    def setUp(self):
        super(DuplicityTestCase, self).setUp()
        self.savedEnviron = {}
        self.savedConfig = {}

        log.setup()
        log.setverbosity(log.WARNING)
        self.set_config(u'print_statistics', 0)
        backend.import_backends()

        # Have all file references in tests relative to our testing dir
        os.chdir(_testing_dir)
예제 #2
0
    def setUp(self):
        super(DuplicityTestCase, self).setUp()
        self.savedEnviron = {}
        self.savedGlobals = {}

        # TODO: remove these lines
        log.setup()
        log.setverbosity(log.WARNING)
        self.set_global('print_statistics', 0)
        backend.import_backends()

        # Have all file references in tests relative to our testing dir
        os.chdir(_testing_dir)
예제 #3
0
    def setUp(self):
        super(DuplicityTestCase, self).setUp()
        self.savedEnviron = {}
        self.savedGlobals = {}

        # TODO: remove these lines
        log.setup()
        log.setverbosity(log.WARNING)
        self.set_global('print_statistics', 0)
        backend.import_backends()

        # Have all file references in tests relative to our testing dir
        os.chdir(_testing_dir)
예제 #4
0
 def runduplicity(self):
     if self.url is None:
         return
     log.setup()
     log.setverbosity(int(self.debuglevel))
     if self.passphrasefd:
         self.passphrasefd = int(self.passphrasefd)
     if self.passwordfd:
         self.passwordfd = int(self.passwordfd)
     if self.url.find("file:/") != 0:
         get_backendpassphrase(self.passwordfd)
     opts = []
     for i in self.options:
         try:
             v = eval("self." + i.replace("-", ""))
             if v:
                 opts.append("--%s=%s" % (i, v))
         except:
             pass
     for i in self.no_options:
         try:
             v = eval("self." + i.replace("-", ""))
             if v:
                 opts.append("--%s" % (i))
         except:
             pass
     self.options = []
     parameter = ["list-current-files", "--ssh-askpass"] + opts + [self.url]
     log.Log("processing %s" % (" ".join(parameter)), 5)
     sys.argv = ["duplicity"] + parameter
     action = commandline.ProcessCommandLine(parameter)
     log.Log("running action %s" % (action), 5)
     globals.gpg_profile.passphrase = get_passphrase(self.passphrasefd)
     self.col_stats = collections.CollectionsStatus(
         globals.backend, globals.archive_dir,
         "collection-status").set_values()
     self.date_types = []
     for chain in self.col_stats.all_backup_chains:
         for s in chain.get_all_sets():
             self.date_types.append(
                 (datetime.fromtimestamp(s.get_time()), s.type))
     for s in self.date_types:
         self.dircache[date2str(s[0]) + '_' + s[1]] = None
예제 #5
0
    def runduplicity(self):
        if not self.url:
            return
        duplicity_log.setup()
        duplicity_log.setverbosity(int(self.debuglevel))
        log.addHandler(logging.handlers.SysLogHandler(address='/dev/log'))

        if self.passphrasefd:
            self.passphrasefd = int(self.passphrasefd)
        if self.passwordfd:
            self.passwordfd = int(self.passwordfd)
        if self.url.find("file:/") != 0:
            get_backendpassphrase(self.passwordfd)
        opts = []
        self_dict = vars(self)
        for option in self.options:
            value = self_dict.get(option.replace("-", ""))
            if value:
                opts.append("--%s=%s" % (option, value))
        for option in self.no_options:
            if option.replace("-", "") in self_dict:
                opts.append("--%s" % (option))
        self.options = []
        parameter = ["list-current-files", "--ssh-askpass"] + opts + [self.url]
        debug_log("processing %s" % (" ".join(parameter)))
        sys.argv = ["duplicity"] + parameter
        action = commandline.ProcessCommandLine(parameter)
        debug_log("running action %s" % (action))
        globals.gpg_profile.passphrase = get_passphrase(self.passphrasefd)
        self.col_stats = collections.CollectionsStatus(
            globals.backend, globals.archive_dir,
            "collection-status").set_values()
        self.date_types = [(datetime.fromtimestamp(s.get_time()), s.type)
                           for chain in self.col_stats.all_backup_chains
                           for s in chain.get_all_sets()]
        self.dircache.update({(date2str(timestamp) + '_' + type): None
                              for timestamp, type in self.date_types})
        debug_log("initialized cache: " + str(self.date_types) + ", " +
                  str(self.dircache))
예제 #6
0
from duplicity import diffdir
from duplicity import dup_collections
from duplicity import dup_main
from duplicity import dup_time
from duplicity import globals as dup_globals
from duplicity import gpg
from duplicity import log
from duplicity import util

from splunk import Intersplunk
from splunk.clilib.bundle_paths import make_splunkhome_path

with open(make_splunkhome_path(["etc", "auth", "splunk.secret"]), "r") as f:
    os.environ["PASSPHRASE"] = f.read().strip()

log.setup()
log._logger.handlers = []


def skip_exit(code):
    pass


log.sys.exit = skip_exit


def log_startup_parms(verbosity=log.INFO):
    pass


dup_main.log_startup_parms = log_startup_parms
예제 #7
0
from duplicity import log
from duplicity import globals
from duplicity.errors import BackendException

import re
from models import *
from datetime import datetime

import sys

#needed to handle ftp unicode output - directory names for example
#TODO may break something! better to handle unicode some way
reload(sys)  
sys.setdefaultencoding('utf8')

log.setup()
backend.import_backends()
log.setverbosity(log.DEBUG)

globals.ssl_no_check_certificate = True #TODO better to check, but way to store self-signed

def check_all():
	actions = Action.objects.all()

	for action in actions:
		check(action)

def build_url(action):
	storage = action.storage
	url = storage.access_type+"://"+storage.login + ":" + storage.password + "@" + storage.url + action.dest_path
	print url
예제 #8
0
파일: helper.py 프로젝트: AZed/duplicity
def setup():
    """ setup for unit tests """
    log.setup()
    log.setverbosity(log.WARNING)
    globals.print_statistics = 0
    backend.import_backends()