Hi, I'd kindly ask for some obviously newbie guidance here:
I have a code: ------------------------------------------------------------------------- self.time = time.time() HOST = '192.168.0.14' # The remote host PORT = 8083 # The same port as used by the server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: s.connect((HOST, PORT)) except: print "Error communicating with TINIA server - Is it running ?" input = "?" else: s.send('state $Office_Motion_sensor\n') input = s.recv(1024) s.close() self.motion = " %s" % (input[:-2]) print "Got response: %s \n" % (input[:-2]) ------------------------------------------ Now if MH server is not active on this port, Freevo crashes with "Connection refused" on s.connect statement. I must be oding sometyhing worng - shouldn't try statement catch this error and prevent Freevo from crashing ? Thanks, Robert. ----- Original Message ----- From: "Robert Rozman" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, April 02, 2004 9:31 AM Subject: Re: [Freevo-users] Newbie python: problems with try except > Hi, > > please see below. > > ----- Original Message ----- > From: "Rob Shortt" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, April 02, 2004 2:52 AM > Subject: Re: [Freevo-users] Newbie python: problems with try except > > > > It crashes but what kind of error do you get? Does it complain about a > > certain line? If your s.connect() call fails in this case it will print > > your error and set input = "?", and then just continue with the code. > That's the problem . I assume from this code that this would hapen. But > Freevo crashes on this one with (couldn't connect to ... (I don't have MH > running so connection is refused) shows this error ion black screen and > shuts down in few seconds. It seems like major Freevo catching exceptions > code caught this one instead of local try except commands ? This code is > located in idlebar plugin. > > Sorry can't give more info for now, cause I'm not at the computer. > > Thanks for help in advance, > > Robert. > > > > > > > > > What you need to do it print a traceback. Try this: > > > > import traceback > > > > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > > > try: > > > s.connect((HOST, PORT)) > > > except: > > > print "Error communicating with TINIA server - Is it > running ?" > > traceback.print_exc() > > > input = "?" > > > > Then you should see some more info which may give you some leads. If > > you have further code that relies on that connection you may have to > > if/else it in order to not crash when the connection fails. > > > > -Rob > > > > > > ------------------------------------------------------- > > This SF.Net email is sponsored by: IBM Linux Tutorials > > Free Linux tutorial presented by Daniel Robbins, President and CEO of > > GenToo technologies. Learn everything from fundamentals to system > > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > > _______________________________________________ > > Freevo-users mailing list > > [EMAIL PROTECTED] > > https://lists.sourceforge.net/lists/listinfo/freevo-users > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: IBM Linux Tutorials > Free Linux tutorial presented by Daniel Robbins, President and CEO of > GenToo technologies. Learn everything from fundamentals to system > administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click > _______________________________________________ > Freevo-users mailing list > [EMAIL PROTECTED] > https://lists.sourceforge.net/lists/listinfo/freevo-users ------------------------------------------------------- This SF.Net email is sponsored by: IBM Linux Tutorials Free Linux tutorial presented by Daniel Robbins, President and CEO of GenToo technologies. Learn everything from fundamentals to system administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click _______________________________________________ Freevo-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/freevo-users