예제 #1
0
    def start_session(self):

        if not self.password or not self.username:
            resp = self.start_session_resolve_user(
                user_id=self.username,
                remote_ip=self.remote_ip,
                remote_site=self.remote_site,
            )

            crypto_block = resp['crypto_block']
            self.username = resp['running_user'].user_id
            self.running_user = resp['running_user']

        else:
            arg_dict={
                'user_id': self.username,
                'sub_id': self.sub_id,
                'user_passwd': self.password,
            }

            if self.sub_id:
                arg_dict.update(
                    sub_id=self.sub_id,
                )

            resp = self._create_xml_and_post(
                method_name='start_session',
                arg_dict=arg_dict,
            )

            parse.script_error(resp)
            running_user = resp.find('running_user')

            if running_user is not None:
                self.running_user = parse._parse_running_user(running_user)

            crypto_block = resp.findtext('crypto_block')

        return crypto_block
예제 #2
0
    def parse_response(self, parse_function, xml_elem):
        """ Calls the specified parse function

        Calls the specified parse function and logs
        any errors that are raised.

        """
        try:
            result = parse_function(
                parse.script_error(xml_elem)
            )
        except Exception as e:
            logger.error(e)
            raise e

        return result