'Updates progress information'

@classmethod
def handle_cursor(cls, cursor, query, session):

    from pyhive import hive
    unfinished_states = (hive.ttypes.TOperationState.INITIALIZED_STATE, hive.ttypes.TOperationState.RUNNING_STATE)
    polled = cursor.poll()
    last_log_line = 0
    tracking_url = None
    job_id = None
    while (polled.operationState in unfinished_states):
        query = session.query(type(query)).filter_by(id=query.id).one()
        if (query.status == QueryStatus.STOPPED):
            cursor.cancel()
            break
        log = (cursor.fetch_logs() or u'')
        if log:
            log_lines = log.splitlines()
            progress = cls.progress(log_lines)
            logging.info(u'Progress    total:    {}'.format(progress))
            needs_commit = False
            if (progress > query.progress):
                query.progress = progress
                needs_commit = True
            if (not tracking_url):
                tracking_url = cls.get_tracking_url(log_lines)
                if tracking_url:
                    job_id = tracking_url.split(u'/')[(-2)]
                    logging.info(u'Found    the    tracking    url:    {}'.format(tracking_url))
                    tracking_url = tracking_url_trans(tracking_url)
                    logging.info(u'Transformation    applied:    {}'.format(tracking_url))
                    query.tracking_url = tracking_url
                    logging.info(u'Job    id:    {}'.format(job_id))
                    needs_commit = True
            if (job_id and (len(log_lines) > last_log_line)):
                for l in log_lines[last_log_line:]:
                    logging.info(u'[{}]    {}'.format(job_id, l))
                last_log_line = len(log_lines)
            if needs_commit:
                session.commit()
        time.sleep(5)
        polled = cursor.poll()
