def get_current_Id(conn_type): """ Return id of active connection :param conn_type: :return: """ cfg = read_dict(settings.grass_config) if cfg: if conn_type in cfg: return cfg.get(conn_type) else: return None
def get_current_Id(conn_type): """ Return id of active connection :param conn_type: :return: """ cfg = read_dict(settings.grass_config) if cfg: if cfg.has_key(conn_type): return cfg.get(conn_type) else: return None
def show_active_connections(): """ Print active connection :return: """ cfg = read_dict(settings.grass_config) if cfg: grass.message('***' * 30) grass.message('\n Primary connection for db drivers\n') for key, val in cfg.iteritems(): grass.message(' conn_type: %s -> conn_id: %s\n' % (key, val)) else: grass.message(' No connection defined\n') grass.message('***' * 30)
def _set_active_connection(self, conn_type=None, conn_id=None): """ Set active connection :param conn_type: driver :param conn_id: id of connection :return: """ if conn_type is None: conn_type = self.conn_type if conn_id is None: conn_id = self.conn_id cfg = read_dict(settings.grass_config) cfg[conn_type] = conn_id save_dict(settings.grass_config, cfg)