<br><br><div class="gmail_quote">On Thu, Feb 24, 2011 at 12:49 PM, MRAB <span dir="ltr"><<a href="mailto:python@mrabarnett.plus.com">python@mrabarnett.plus.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<div><div></div><div class="h5">On 24/02/2011 16:41, Verde Denim wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
hi, all<br>
i can't believe i don't see this, but<br>
python from the command line:<br>
>>> x = '0D'<br>
>>> y = '0x' + x<br>
>>> print "%d" % int(y,0)<br>
13<br>
<br>
content of testme.py:<br>
x = '0D'<br>
y = '0x' + x<br>
print "%d" % int(y,0)<br>
TypeError: 'int' object is not callable<br>
<br>
what am i not seeing here??<br>
<br>
</blockquote></div></div>
I can only assume that at some point you assigned an int to 'int'.<br></blockquote><div><br>To put this in context, here is the code - <br>#!/usr/bin/env python<br><br>from scapy.all import *<br>from binascii import hexlify<br>
import sys, re, pprint<br><br>class C12Pcap:<br><br> __acse_pdu_open = [] # 1-byte indicating start of packet<br> __acse_pdu_len = [] # 1-byte indicating the length of the packet<br> __asn1_called_ident_type = [] # 1-byte indicating universal identifier<br>
__asn1_called_ident_length = [] # 1-byte indicating the length of this identifier<br><br> def __init__(self, pcap=None, portno=0):<br> self.__pcap = pcap<br> self.__portno = portno<br> self.__pcktList = []<br>
<br> def __action(self):<br> if self.__pcap:<br> self.__rdpcap()<br> self.__dump()<br> return<br><br> def __rdpcap(self):<br> self.__pcktList = rdpcap(self.__pcap)<br> return<br>
<br> def __dump(self):<br> x = int = 0<br> z = int = -1<br> for pckt in self.__pcktList: # for each packet<br> z += 1 # debug a smaller subset...<br> if z == 50: break # debug a smaller subset...<br>
layers = [] # a list of the layers' classes<br> layerDicts = [] # a list of each layer's fields and values<br> cltype = pckt.__class__<br> cl = pckt<br>
flds = cl.__dict__['fields']<br> while 1:<br> # walk down the layers until no payload<br> layers.append(cltype)<br> layerDicts.append(flds)<br>
cltype = cl.__dict__['payload'].__class__<br> cl = cl.__dict__['payload']<br> flds = cl.__dict__['fields']<br><br> # if tcp, we'll guess at req/resp and if psh is on (for now)<br>
if re.search('TCP', str(cltype)):<br> i = 0<br> for key, value in flds.items():<br> if key == 'flags' and long(value) == 24: # PUSH,ACK<br>
i = 1<br> if i == 1 and key == 'dport' and str(value) == str(portno):<br> pktType = 'REQUEST'<br> if i == 1 and key == 'sport' and str(value) == str(portno):<br>
pktType = 'RESPONSE'<br><br> # Do we have a Raw packet - the interesting ones for us<br> if re.search('Raw', str(cltype)):<br> h = hexlify(flds['load']) # hex representation of payload<br>
self.__acse_pdu_open = h[0:2]<br> self.__acse_pdu_len = h[2:4]<br> self.__asn1_called_ident_type = h[4:6]<br> self.__asn1_called_ident_length = '0x' + h[6:8]<br>
print self.__asn1_called_ident_length # WORKS FINE<br> print "%d" % (int(self.__asn1_called_ident_length,0)) # FAILS WITH:<br>#TypeError: 'int' object is not callable<br>
#File "/home/Scripts/Py/Elster_Lab/strip_raw_data1.py", line 103, in <module><br> #inst.run(pcap,portno)<br>#File "/home/Scripts/Py/Elster_Lab/strip_raw_data1.py", line 92, in run<br> #self.__action()<br>
#File "/home/Scripts/Py/Elster_Lab/strip_raw_data1.py", line 41, in __action<br> #self.__dump()<br>#File "/home/Scripts/Py/Elster_Lab/strip_raw_data1.py", line 86, in __dump<br> #print "%d" % (int(self.__asn1_called_ident_length,0))<br>
<br> if 'NoPayload' in str(cltype): break<br> <br> def run(self,pcap,portno):<br> self.__pcap = pcap<br> self.__portno = portno<br> self.__action()<br><br>def main():<br>
<br> return 0<br><br>if __name__ == '__main__':<br> inst = C12Pcap()<br> argl = sys.argv<br> pcap = argl[1]<br> portno = argl[2]<br> inst.run(pcap,portno)<br> main()<br></div></div><br><div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>