Example #1
0
        def inner():
            ctx = {
                'mountpoint': url_for('page_post'),
                'hostname': socket.gethostname(),
            }

            # Do we have connection data?
            try:
                connection_info = config.parse_config(CONFIG_PATH)
            except exceptions.NoConnectionInfo:
                flash(u'MySQL connection information is unavailable', 'error')
                return render_template('config_error.html', **ctx)

            # Does it work?
            try:
                output = page(connection_info,
                              **(ctx if takes_context else {}))
            except exceptions.NoConnectionEstablished as err:
                ctx['error'] = err.error
                if err.connection_info.master:
                    flash(
                        u'An error occurred when writing '
                        u'to the Master MySQL database!', 'error')
                    template = 'write_error.html'
                else:
                    flash(
                        u'An error occurred when reading '
                        u'from a Slave MySQL database!', 'error')
                    template = 'read_error.html'
                return render_template(template,
                                       connection_info=connection_info,
                                       **ctx)

            return output
Example #2
0
        def inner():
            ctx = {
                'mountpoint': url_for('page_post'),
                'hostname': socket.gethostname(),
                'git_branch': find_git_branch(),
            }

            # Do we have configuration?
            connection_info = config.load_config_from_env() or config.parse_config(CONFIG_PATH)
            if connection_info is None:
                flash(u'MySQL connection information is unavailable', 'error')
                return render_template('config_error.html', **ctx)

            # Does it work?
            try:
                output = page(connection_info,
                              **(ctx if takes_context else {}))
            except exceptions.NoConnectionEstablished as err:
                ctx['error'] = err.error
                if err.connection_info.master:
                    flash(u'An error occurred when writing '
                          u'to the Master MySQL database!', 'error')
                    template = 'write_error.html'
                else:
                    flash(u'An error occurred when reading '
                          u'from a Slave MySQL database!', 'error')
                    template = 'read_error.html'
                return render_template(template,
                                       connection_info=connection_info,
                                       **ctx)

            return output
Example #3
0
    def test_valid_config(self):
        """
        Check that a valid config gets parsed correctly
        """
        conf = config.parse_config(self.test_dir)

        for fname, attr in config.FILE_CONFIG_STRUCTURE:
            self.assertEqual(getattr(conf, attr), fname)
Example #4
0
    def test_valid_config(self):
        """
        Check that a valid config gets parsed correctly
        """
        conf = config.parse_config(self.test_dir)

        for fname, attr in config.CONFIG_STRUCTURE:
            self.assertEqual(getattr(conf, attr), fname)
Example #5
0
 def test_to_db_connection(self):
     """
     Check that config info interacts well with DB info
     """
     conn_info = config.parse_config(self.test_dir)
     self.assertEqual("mysql-master", conn_info.master_ip)
     self.assertEqual("mysql-slave", conn_info.slave_ip)
     self.assertEqual(["mysql-slave"], conn_info.slave_ips)
     self.assertEqual("mysql-username", conn_info.username)
     self.assertEqual("mysql-password", conn_info.password)
Example #6
0
 def test_to_db_connection(self):
     """
     Check that config info interacts well with DB info
     """
     conn_info = config.parse_config(self.test_dir)
     self.assertEqual("mysql-master", conn_info.master_ip)
     self.assertEqual("mysql-slave", conn_info.slave_ip)
     self.assertEqual(["mysql-slave"], conn_info.slave_ips)
     self.assertEqual("mysql-username", conn_info.username)
     self.assertEqual("mysql-password", conn_info.password)
Example #7
0
 def test_invalid_config(self):
     """
     Check that we handle invalid configs
     """
     self.assertEqual(None, config.parse_config('/wrongpath'))
Example #8
0
 def test_invalid_config(self):
     """
     Check that we handle invalid configs
     """
     self.assertEqual(None, config.parse_config('/wrongpath'))