def _check_owner(self): # Firstly, determine for whom listcases is being run and if they're a # Red Hat employee (isInternal == True) or not # If they're internal, then display the open cases they *own* in SFDC # ...except however if the -o all, -g or -u options are specified, then # it displays cases in the Red Hat employee's account. # If they're not internal, then display the open cases in their account try: api = apihelper.get_api() username = api.config.username userobj = contextmanager.get('user') if not userobj: userobj = api.users.get(username) contextmanager.add('user', userobj) if self._options['owner']: if not userobj.isInternal: raise Exception("The -o switch is only available to Red Hat" " employees") elif self._options['owner'].lower() != 'all': username = self._options['owner'] userobj = api.users.get(username) if not userobj.isInternal: # for some reason RH users can't display non-RH users raise Exception("Red Hat employees are unable to list" "cases for non-Red Hat portal users.") if userobj.isInternal: if not (str(self._options['owner']).lower() == 'all' or self._caseGroupNumbers or self._options['ungrouped']): # this will trigger the display of cases owned as per SFDC self._associateSSOName = username self._view = 'internal' except RequestError, re: if re.status == 404: msg = _("Unable to find user %s" % username) else: msg = _('Problem querying the support services API. Reason: ' '%s' % re.reason) print msg logger.log(logging.WARNING, msg) raise
def _check_owner(self): # Firstly, determine for whom listcases is being run and if they're a # Red Hat employee (isInternal == True) or not # If they're internal, then display the open cases they *own* in SFDC # ...except however if the -o all, -g or -u options are specified, then # it displays cases in the Red Hat employee's account. # If they're not internal, then display the open cases in their account try: api = apihelper.get_api() username = api.config.username userobj = contextmanager.get('user') if not userobj: userobj = api.users.get(username) contextmanager.add('user', userobj) if self._options['owner']: if not userobj.isInternal: raise Exception( "The -o switch is only available to Red Hat" " employees") elif self._options['owner'].lower() != 'all': username = self._options['owner'] userobj = api.users.get(username) if not userobj.isInternal: # for some reason RH users can't display non-RH users raise Exception("Red Hat employees are unable to list" "cases for non-Red Hat portal users.") if userobj.isInternal: if not (str(self._options['owner']).lower() == 'all' or self._caseGroupNumbers or self._options['ungrouped']): # this will trigger the display of cases owned as per SFDC self._associateSSOName = username self._view = 'internal' except RequestError, re: if re.status == 404: msg = _("Unable to find user %s" % username) else: msg = _('Problem querying the support services API. Reason: ' '%s' % re.reason) print msg logger.log(logging.WARNING, msg) raise
def _getProxy(self): return contextmanager.get('proxy')