def run(self): try: if "backup_path" not in self._device_info: raise KeyError("Could not obtain device backup path for %s" % self._device_info["id"]) if self._device_info["backup_path"] is None: raise ValueError("backup path is None for device %s" % self._device_info["id"]) backup_path = os.path.join(self._results_dir, self._device_info["backup_path"]) self._db_credentials["name"] = "%s_db" % self._device_info["name"] mirror = MySQLdbToSQlite( backup_path, self._db_credentials["name"], remote_host=self._database_ip, remote_pass=self._db_credentials["password"], remote_user=self._db_credentials["user"]) mirror.update_roi_tables() except DBNotReadyError as e: logging.warning(e) logging.warning("Database %s on IP %s not ready, will try later" % (self._db_credentials["name"], self._database_ip)) pass except Exception as e: logging.error(traceback.format_exc())
__author__ = 'quentin' from ethoscope_node.utils.helpers import generate_new_device_map from ethoscope_node.utils.mysql_backup import MySQLdbToSQlite, DBNotReadyError import logging import optparse import time import multiprocessing import traceback import os import subprocess import re db_credentials = { "name": "ethoscope_db", "user": "******", "password": "******" } database_ip = "localhost" mirror = MySQLdbToSQlite("/tmp/test.db", db_credentials["name"], remote_host=database_ip, remote_pass=db_credentials["password"], remote_user=db_credentials["user"]) mirror.update_roi_tables()