Пример #1
0
    def __init__(self, config):

        self.config = config

        # Configure logging and get the logger object.
        logging.basicConfig(stream=sys.stdout, format=getFormat(), level=logging.DEBUG)
        self.logger = logging.getLogger("prune")

        # Connect to database engine and start a session.
        self.engine = sa.create_engine(
            "mysql://{}:{}@{}/{}".format(
                self.config["username"], self.config["password"], self.config["host"], self.config["db_name"]
            )
        )
        try:
            conn = self.engine.connect()
        except sa.exc.OperationalError:
            self.logger.error("Failed to connect.")
            sys.exit(1)
Пример #2
0
import cv2
import mpipe
import coils

# Import local modules.
from mpipe_stages import DiskSaver, DbWriter
from log_format import getFormat

# Read command-line parameters.
DURATION = float(sys.argv[1])
CONFIG = sys.argv[2] if len(sys.argv)>=3 else 'wabbit.conf'

# Configure logging and get the logger object.
logging.basicConfig(
    stream=sys.stdout,
    format=getFormat(),
    level=logging.DEBUG,
    )
logger = logging.getLogger('prune')

# Load configuration file.
config = coils.Config(CONFIG)

# Connecting to video device may hang.
# Therefore let's first test-connect to the device 
# in a separate process which, in case the connection hangs, 
# we can terminate. The hang is detected when the join()
# method times out.
proc = Process(target=cv2.VideoCapture, args=(int(config['device']),))
proc.daemon = False
proc.start()