#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    6
    Rep Power
    0

    TypeError: 'module' object is not callable


    Hi there,

    Im having problem with running my python module. My module locationService(locService) has a simple class (MSLocService) but when i try to run the class from __main__ function i get the following error:

    Traceback (most recent call last):
    File "locService.py", line 82, in ?
    l = MSLocService()

    i have tried to google, shows that its wrong with the naming, but i dont see any wrong at all.

    Can any body help me.. plz ??
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    Post the code leading up to the error, if you would.

    I'm guessing you're doing something like:

    Code:
    import MSLocService
    
    ...
    
    l = MSLocService()
    and instead, you need to do

    Code:
    import MSLocService
    
    ...
    
    l = MSLocService.MSLocService()
    or use "from MSLocService import MSLocService" instead, but I don't understand what "My module locationService(locService)" means, so I might be on the wrong track completely.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    6
    Rep Power
    0

    some code..


    Hi,

    First, thank u so much for a quick replay,

    Her's my code, im not imporing my module in the file but generall threadding, and then some services moudle called Handler and Listener.


    the code ():

    --
    import threading

    from Service import Handler, Listener

    class MSLocService(Listener, threading.Thread):

    """ This is listener for the location service. It will receive an event and queue to its handler. """

    # not so sure about the gui stuff
    def __init__(self):

    threading.Thread.__init__(self)


    # Initlizing the Listner
    Listener.__init__(self,
    name="LocatinServices",
    host= "lgserv3.stud.cs.uit.no",
    port= 7070
    )
    # put some debug functionality
    Listener.setDaemon(1)


    # set the loggin funtunality
    self.logger.setLevel(logging.DEBUG)


    self.handler = Handler(self,
    self.name,
    self.jobQueue,
    self.logger
    )
    def main (self):

    self.logger.info("Main: Have started the Locatino WAIF service")

    # make sure that we are logging on right mode=> DEBUG mode


    try:
    self.handler.registerFunction(self.myHandler, "LocationHandler")

    self.server.serve_forever()

    except KeyboardInterrupt:
    self.logger.info("Cntrl -C Qutting!")

    except:
    self.logger.exception("Internal Error: Exception Cought: - Shutting down")

    print "[Internal ERROR]: Shutting down"

    def insert_pos(params):

    params = params._asdict()
    self.myPos.put(params)
    print "Inserted into the queue: %s ->%d", (params, d)

    def myHandler(self, event):

    waifID, subID, handle, args = event

    profile = self.users[waifID][subID]
    print "[Profile]"
    if args and type(args) == type({}):
    newmsg = args

    newmsg['data'] = ['From ','location', 'Service']
    newmsg['Datatype'] = list
    # have to parse troght the events.. check the buss rute and timer funtions
    #
    self.logger.warining("Received a message")
    print "Reaceived:", event

    self.handler.push(profile['taddr'],
    wailID,
    profile['remoteID'],
    newmsg)

    if __name__ =="__main__":
    print "Calling"
    l = MSLocService()
    l.main()
    print "Done ........"
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    6
    Rep Power
    0

    Post


    it looked terribly that code that i posted, anyway
    the main part is this.

    import threading

    from WAIFService import Handler, Listener

    class MSLocService(Listener, threading.Thread):
    ...
    def main():


    if __name__ =="__main__":
    print "Calling"
    l = MSLocService()
    l.think()
    print "Done ........"
  8. #5
  9. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2004
    Posts
    6
    Rep Power
    0

    its running no


    Hi sir,

    I found out that there was bugs in the listener module that i imported.
    download the listener module again, and now its working..

    Thank you for ur help,

IMN logo majestic logo threadwatch logo seochat tools logo