<commit_before>from django.conf import settings
import traceback
import logging
import sys
from restclients.pws import PWS
from myuw_mobile.user import UserService
from myuw_mobile.logger.timer import Timer

class Person:
    """
    The Person class encapsulates the interactions
    with the PWS person resource
    """

    # static class variables
    _logger = logging.getLogger('myuw_mobile.dao.pws.Person')

    def get_person_by_netid(self, netid):
        timer = Timer()
        try:
            return PWS().get_person_by_netid(netid)
        except Exception, message:
            print 'Failed to get person data: ', message
            traceback.print_exc()
            Person._logger.error("get_person_by_netid %s %s", 
                                 message,
                                 UserService().get_log_user_info())
        finally:
            Person._logger.info("PWS get_person_by_netid time=%s %s", 
                                timer.get_elapsed(),
                                UserService().get_log_user_info())
        return None

    def is_student(self, netid):
        res = self.get_person_by_netid(netid)
        if res:
            return res.is_student
        return None

    def get_regid(self, netid):
        res = self.get_person_by_netid(netid)
        if res:
            return res.uwregid
        return None

    def get_contact(self, regid):
        contact = None
        timer = Timer()
        try:
            contact = PWS().get_contact(regid)
        except Exception, message:
            print 'Failed to get instructor data: ', message
            traceback.print_exc()
            Person._logger.error("get_contact for %s: %s %s", 
                                 regid, message,
                                 UserService().get_log_user_info())
        finally:
            Person._logger.info("PWS get_contact for %s time=%s %s", 
                                regid, timer.get_elapsed(),
                                UserService().get_log_user_info())

        if contact and not contact["WhitepagesPublish"] :
            affiliations = contact["PersonAffiliations"]
            if "EmployeePersonAffiliation" in affiliations:
                data = affiliations["EmployeePersonAffiliation"]
                data["EmployeeWhitePages"] = {}

            if "StudentPersonAffiliation" in affiliations:
                data = affiliations["StudentPersonAffiliation"]
                data["StudentWhitePages"] = {}

        return contact                


<commit_msg>Reviced logging calls. No need to pass in netid in param.<commit_after>from django.conf import settings
import traceback
import logging
import sys
from restclients.pws import PWS
from myuw_mobile.user import UserService
from myuw_mobile.logger.timer import Timer
from myuw_mobile.logger.util import log_resp_time, log_exception

class Person:
    """
    The Person class encapsulates the interactions
    with the PWS person resource
    """

    # static class variables
    _logger = logging.getLogger('myuw_mobile.dao.pws.Person')

    def _get_person(self):
        timer = Timer()
        try:
            netid = UserService().get_user()
            return PWS().get_person_by_netid(netid)
        except Exception, message:
            traceback.print_exc()
            log_exception(Person._logger, 'get_person_by_netid', message)
        finally:
            log_resp_time(Person._logger, 'pws.get_person_by_netid', timer)
        return None

    def is_student(self):
        res = self._get_person()
        if res:
            return res.is_student
        return None

    def get_regid(self):
        res = self._get_person()
        if res:
            return res.uwregid
        return None

    def get_contact(self, regid):
        contact = None
        timer = Timer()
        try:
            contact = PWS().get_contact(regid)
        except Exception, message:
            traceback.print_exc()
            log_exception(Person._logger, 'pws.get_contact for ' + regid, message)
        finally:
            log_resp_time(Person._logger, 'pws.get_contact for ' + regid, timer)

        if contact and not contact["WhitepagesPublish"] :
            affiliations = contact["PersonAffiliations"]
            if "EmployeePersonAffiliation" in affiliations:
                data = affiliations["EmployeePersonAffiliation"]
                data["EmployeeWhitePages"] = {}

            if "StudentPersonAffiliation" in affiliations:
                data = affiliations["StudentPersonAffiliation"]
                data["StudentWhitePages"] = {}

        return contact                



{'fraction_non_alphanumeric': 0.07996560619088564, 'fraction_numerical': 0.0, 'mean_word_length': 1.9674744897959184, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4189834', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1205, 'n_words': 302}