def preliminaries(self):
        if ('MySQLServer' not in self.raw_config and
                'mysql_server' not in self.raw_config['MySQLServer'] or
                self.raw_config['MySQLServer']['mysql_server'] == '' or
                self.raw_config['MySQLServer']['mysql_user'] == '' or
                self.raw_config['MySQLServer']['mysql_pass'] == ''):
            self.checks_logger.debug('mysql: config not set')
            return False

        if not self.raw_config['MySQLServer'].get('mysql_port'):
            self.raw_config['MySQLServer']['mysql_port'] = "3306"

        self.checks_logger.debug('mysql: config set')

        try:
            import MySQLdb
        except __HOLE__:
            self.checks_logger.error('mysql: unable to import MySQLdb')
            return False

        # Note, code here doesn't really make sense. See what I copied.
        if self.raw_config['MySQLServer'].get('mysql_server'):
            # Connect
            try:
                MySQLdb.connect(
                    host=self.raw_config['MySQLServer']['mysql_server'],
                    user=self.raw_config['MySQLServer']['mysql_user'],
                    passwd=self.raw_config['MySQLServer']['mysql_pass'],
                    port=int(self.raw_config['MySQLServer']['mysql_port'])
                    )
            except MySQLdb.OperationalError as message:
                self.checks_logger.error(
                    "mysql: MySQL connection error: {0}".format(message))
                return False
        elif (self.raw_config['MySQLServer'].get('mysql_ssl_cert') and
                self.raw_config['MySQLServer'].get('mysql_ssl_key')):
            ssl = {
                'cert': self.raw_config['MySQLServer']['mysql_ssl_cert'],
                'key': self.raw_config['MySQLServer']['mysql_ssl_key']
            }
            MySQLdb.connect(
                host=self.raw_config['MySQLServer']['mysql_server'],
                user=self.raw_config['MySQLServer']['mysql_user'],
                passwd=self.raw_config['MySQLServer']['mysql_pass'],
                port=int(self.raw_config['MySQLServer']['mysql_port']),
                ssl=ssl
            )
        else:
            # Connect
            try:
                MySQLdb.connect(
                    host='localhost',
                    user=self.raw_config['MySQLServer']['mysql_user'],
                    passwd=self.raw_config['MySQLServer']['mysql_pass'],
                    port=int(self.raw_config['MySQLServer']['mysql_port']))
            except MySQLdb.OperationalError as message:
                self.checks_logger.error(
                    'mysql: MySQL connection error: {0}'.format(message)
                    )
                return False
        return True
dataset/ETHPy150Open serverdensity/sd-agent-plugins/MySQL/MySQL.py/MySQL.preliminaries