Beispiel #1
0
    def setup_class(self):
        config = configparser.ConfigParser()
        config.read('config.ini')

        try:
            db = mysql.connector.connect(
                host=config['db']['host'],
                user=config['db']['user'],
                password=config['db']['pass'],
                database=config['db']['database']
            )
            db.autocommit = True
        except mysql.connector.errors.ProgrammingError as e:
            print " ERROR: Can`t connect to MySQL server! ({0})".format(str(e))
            exit(0)

        try:
            mc = MongoClient(host=config['mongo']['host'], port=int(config['mongo']['port']))
            mongo_collection = getattr(mc, config['mongo']['collection'])
        except pymongo.errors.ConnectionFailure as e:
            print " ERROR: Can`t connect to MongoDB server! ({0})".format(str(e))
            exit(0)

        R = Registry()
        R.set('config', config)
        R.set('db', db)
        R.set('mongo', mongo_collection)
        R.set('wr_path', wrpath)
        R.set('data_path', wrpath + '/data/')
        R.set('ndb',
              Database(config['db']['host'], config['db']['user'], config['db']['pass'], config['db']['database']))
        R.set('proxies', Proxies())

        self.db = R.get('ndb')
Beispiel #2
0
    def check_backups(self):
        """ Simple check backups """
        Http = Registry().get('http')
        check = []
        result = []

        dirs = file_to_list(Registry().get('wr_path') + "/bases/pre-backups-dirs.txt")
        dirs.append(self.options['host'].value)
        files = file_to_list(Registry().get('wr_path') + "/bases/pre-backups-files.txt")
        dirs_exts = file_to_list(Registry().get('wr_path') + "/bases/bf-dirs.txt")
        files_exts = file_to_list(Registry().get('wr_path') + "/bases/bf-files.txt")

        for _dir in dirs:
            for dir_ext in dirs_exts:
                check.append(dir_ext.replace('|name|', _dir))
        for _file in files:
            for file_ext in files_exts:
                check.append(file_ext.replace('|name|', _file))

        for url in check:
            r = Http.get(self.root_url + url)
            if not self._response_404(r):
                result.append({'url': self.root_url + url, 'code': r.status_code})

        return result
Beispiel #3
0
    def check_backups(self):
        """ Simple check backups """
        Http = Registry().get('http')
        check = []
        result = []

        dirs = file_to_list(Registry().get('wr_path') +
                            "/bases/pre-backups-dirs.txt")
        dirs.append(self.options['host'].value)
        files = file_to_list(Registry().get('wr_path') +
                             "/bases/pre-backups-files.txt")
        dirs_exts = file_to_list(Registry().get('wr_path') +
                                 "/bases/bf-dirs.txt")
        files_exts = file_to_list(Registry().get('wr_path') +
                                  "/bases/bf-files.txt")

        for _dir in dirs:
            for dir_ext in dirs_exts:
                check.append(dir_ext.replace('|name|', _dir))
        for _file in files:
            for file_ext in files_exts:
                check.append(file_ext.replace('|name|', _file))

        for url in check:
            r = Http.get(self.root_url + url)
            if not self._response_404(r):
                result.append({
                    'url': self.root_url + url,
                    'code': r.status_code
                })

        return result
Beispiel #4
0
    def check_dafs(self, _type):
        """ Simple dafs search """
        Http = Registry().get('http')
        result = []
        _dict = open(Registry().get('wr_path') + '/bases/pre-dafs-{0}.txt'.format(_type), 'r').read().split("\n")
        for obj in _dict:
            r = Http.get(self.root_url + obj)
            if r is not None and not self._response_404(r):
                result.append({'url': "/" + obj, 'code': r.status_code, 'time': 0})

        return result
Beispiel #5
0
    def check_dafs(self, _type):
        """ Simple dafs search """
        Http = Registry().get('http')
        result = []
        _dict = open(
            Registry().get('wr_path') +
            '/bases/pre-dafs-{0}.txt'.format(_type), 'r').read().split("\n")
        for obj in _dict:
            r = Http.get(self.root_url + obj)
            if r is not None and not self._response_404(r):
                result.append({
                    'url': "/" + obj,
                    'code': r.status_code,
                    'time': 0
                })

        return result