示例#1
0
文件: HAR.py 项目: sinofeng/wpi-svm
    def __init__(self, har_ent):
        nid = str(uuid.uuid1())
        mod_node.Node.__init__(self, 'nd_' + nid, nid)
        WebObject.__init__(self)

        self.pageid = har_ent['pageref']
        self.user_ip = '0.0.0.0'  # tmp

        sdt = parse_field(har_ent, 'startedDateTime')
        if sdt is not None:
            self.start_time = logbasic.time_str2dt(sdt)

        timings = parse_field(har_ent, 'timings')
        if timings is not None:
            dns = parse_field(timings, 'dns')
            connect = parse_field(timings, 'connect')
            send = parse_field(timings, 'send')
            wait = parse_field(timings, 'wait')
            receive = parse_field(timings, 'receive')
            timings = [dns, connect, send, wait, receive]
            timings = [int(i) for i in timings if i != None]
            self.total_time = datetime.timedelta(milliseconds=sum(timings))
            if receive is not None:
                self.receiving_time = int(receive)

        request = parse_field(har_ent, 'request')
        if request is not None:
            self.url = parse_field(request, 'url')
            headers = parse_field(request, 'headers')
            if headers is not None:
                for field in headers:
                    if field['name'] == 'Referer':
                        self.referrer = field['value']
                    if field['name'] == 'User-Agent':
                        self.user_agent = field['value']

        response = parse_field(har_ent, 'response')
        if response is not None:
            self.status = int(parse_field(response, 'status'))
            bds = parse_field(response, 'bodySize')
            if bds != None:
                self.size = int(bds)
            content = parse_field(response, 'content')
            if content is not None:
                self.type = parse_field(content, 'mimeType')
            headers = parse_field(response, 'headers')
            for field in headers:
                if field['name'] == 'Location':
                    self.re_url = field['value']
示例#2
0
文件: HAR.py 项目: caesar0301/wpi-svm
	def __init__(self, har_ent):
		nid = str(uuid.uuid1())
		mod_node.Node.__init__(self, 'nd_'+nid, nid)
		WebObject.__init__(self)

		self.pageid = har_ent['pageref']
		self.user_ip = '0.0.0.0'	# tmp

		sdt = parse_field(har_ent, 'startedDateTime')
		if sdt is not None:
			self.start_time = logbasic.time_str2dt(sdt)

		timings = parse_field(har_ent, 'timings')
		if timings is not None:
			dns = parse_field(timings, 'dns')
			connect = parse_field(timings, 'connect')
			send = parse_field(timings, 'send')
			wait = parse_field(timings, 'wait')
			receive = parse_field(timings, 'receive')
			timings = [dns, connect, send, wait, receive]
			timings = [int(i) for i in timings if i != None]
			self.total_time = datetime.timedelta(milliseconds = sum(timings))
			if receive is not None:
				self.receiving_time = int(receive)

		request = parse_field(har_ent, 'request')
		if request is not None:
			self.url = parse_field(request, 'url')
			headers = parse_field(request, 'headers')
			if headers is not None:
				for field in headers:
					if field['name'] == 'Referer':
						self.referrer = field['value']
					if field['name'] == 'User-Agent':
						self.user_agent = field['value']

		response = parse_field(har_ent, 'response')
		if response is not None:
			self.status = int(parse_field(response, 'status'))
			bds = parse_field(response, 'bodySize')
			if bds != None:
				self.size = int(bds)
			content = parse_field(response, 'content')
			if content is not None:
				self.type = parse_field(content, 'mimeType')
			headers = parse_field(response, 'headers')
			for field in headers:
				if field['name'] == 'Location':
					self.re_url = field['value']
示例#3
0
	def __init__(self, logline):		
		line = logline.strip(' \n\r\t')
		values = line.split('\t\t')
		if len(attribute_names) != len(values):
			print 'Data format error: line#%d' % index
			exit(-1)
		rr = dict(zip(attribute_names, values))

		nid = str(uuid.uuid1())
		mod_node.Node.__init__(self, 'nd_'+nid, nid)
		WebObject.__init__(self)

		self.user_ip = parse_field(rr, 'source_ip')
		sdt = parse_field(rr, 'time')
		if sdt is not None:
			self.start_time = time_str2dt(sdt)

		dns = parse_field(rr, 'dns')
		connect = parse_field(rr, 'connect')
		send = parse_field(rr, 'send')
		wait = parse_field(rr, 'wait')
		receive = parse_field(rr, 'receive')
		timings = [dns, connect, send, wait, receive]
		timings = [int(i) for i in timings if i != None]
		self.total_time = datetime.timedelta(milliseconds = sum(timings))

		rt = parse_field(rr, 'receive')
		self.receiving_time = rt!=None and int(rt) or 0
		self.url = parse_field(rr, 'url')
		self.status = int(parse_field(rr, 'response_status'))
		rbz = parse_field(rr, 'response_body_size')
		self.size = (rbz != None and int(rbz) or 0)
		self.type = parse_field(rr, 'response_content_type')
		self.re_url = parse_field(rr, 'redirect_url')
		self.user_agent = parse_field(rr, 'user_agent_id')
		self.referrer = parse_field(rr, 'referrer')
示例#4
0
    def __init__(self, logline):
        line = logline.strip(' \n\r\t')
        values = line.split('\t\t')
        if len(attribute_names) != len(values):
            print 'Data format error: line#%d' % index
            exit(-1)
        rr = dict(zip(attribute_names, values))

        nid = str(uuid.uuid1())
        mod_node.Node.__init__(self, 'nd_' + nid, nid)
        WebObject.__init__(self)

        self.user_ip = parse_field(rr, 'source_ip')
        sdt = parse_field(rr, 'time')
        if sdt is not None:
            self.start_time = time_str2dt(sdt)

        dns = parse_field(rr, 'dns')
        connect = parse_field(rr, 'connect')
        send = parse_field(rr, 'send')
        wait = parse_field(rr, 'wait')
        receive = parse_field(rr, 'receive')
        timings = [dns, connect, send, wait, receive]
        timings = [int(i) for i in timings if i != None]
        self.total_time = datetime.timedelta(milliseconds=sum(timings))

        rt = parse_field(rr, 'receive')
        self.receiving_time = rt != None and int(rt) or 0
        self.url = parse_field(rr, 'url')
        self.status = int(parse_field(rr, 'response_status'))
        rbz = parse_field(rr, 'response_body_size')
        self.size = (rbz != None and int(rbz) or 0)
        self.type = parse_field(rr, 'response_content_type')
        self.re_url = parse_field(rr, 'redirect_url')
        self.user_agent = parse_field(rr, 'user_agent_id')
        self.referrer = parse_field(rr, 'referrer')