2

I'm making a network analysis tool using python 2.5 ( windows) , that captures network traffic using scapy and stores the capture data in *.pcap file . What i'm trying to achieve is to allow users to write their own functions that can analyze the network traffic . So what i did is that i created a interface class that would allow users to write the function.

#analyzer function class
class date_validator:
    def __init__(self,dbh):

        #any intializations required for the function.
        self.dbHandle=dbh
        #All interaction with the database can be done by using this handle.
        return

    def importer(self):
        #contains all the modules that have to be imported for
        #execution of the analyzer function.
        return

    def LogAnalyzer(self):
       #Main function that contains the analyzer code.

       return data
       #this function must return 2D data to populate a table View.
       # It can accomadate 1D data also .

Now the problem that i face is that after packaging the whole program as an exe , if i load a analyzer function with the above given structure and it has to import a module lets say " import nmap " how will that work and in case that module is installed on the system ?

So my question is that how do i accomplish this task , is there a better way ?

Thanks in advance .

thecreator232
  • 2,145
  • 1
  • 36
  • 51
  • Is there any reason you're using Python 2.5, not 2.7? – rlms Jan 05 '14 at 13:59
  • @sweeneyrod : yeah scapy does not exactly work well in python 2.7 , so i had to use python 2.5 . – thecreator232 Jan 05 '14 at 14:02
  • i would have loved it , if scapy would have worked on python 2.7 ,i tried to make it work on 2.7 but had no luck . – thecreator232 Jan 05 '14 at 14:04
  • Oh, OK. In answer to your question of whether there is a better way, I would suggest considering not packaging as an exe if you want to allow users extending it. If you expect your users to write a function, then it is reasonable to expect that they either have Python already installed, or are competent enough to install it. – rlms Jan 05 '14 at 14:36
  • @sweeneyrod : Thanx u gave me an idea. I can simply write a batch file that would open the application from the cmd " Python application.py ". This would help me extend the application , so i can just write the analyzer class and load it into the application. – thecreator232 Jan 05 '14 at 14:47
  • If I understand what you mean, you could just tell the user to write the function in a file with a specific name, and then import that in the application. – rlms Jan 05 '14 at 15:43
  • @sweeneyrod : yeah exactly , but with a bit of sophistication . Thanx – thecreator232 Jan 05 '14 at 16:04
  • With what tool are you packaging it to an .exe? – Alexandru Chirila Jan 05 '14 at 18:20
  • 1
    @ChirilaAlexandru : Py2exe , i used it before , works fine. – thecreator232 Jan 06 '14 at 02:44

0 Answers0