Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 10th, 2004, 07:30 AM
thanray thanray is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 6 thanray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 56 m 34 sec
Reputation 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 ??

Reply With Quote
  #2  
Old December 10th, 2004, 07:42 AM
sfb sfb is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Posts: 447 sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level)sfb User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 2 Days 1 h 43 m 45 sec
Reputation Power: 9
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.

Reply With Quote
  #3  
Old December 10th, 2004, 08:02 AM
thanray thanray is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 6 thanray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 56 m 34 sec
Reputation 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 ........"

Reply With Quote
  #4  
Old December 10th, 2004, 08:09 AM
thanray thanray is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 6 thanray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 56 m 34 sec
Reputation 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 ........"

Reply With Quote
  #5  
Old December 10th, 2004, 08:37 AM
thanray thanray is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 6 thanray User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 56 m 34 sec
Reputation 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,

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > TypeError: 'module' object is not callable


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT