Hi,

I modified my code little bit and it is working fine now,

=====================================================
    if os.access("C:/Python25/Own.log", os.F_OK):
        f = open("C:/Python25/Own.log")
        time.sleep(30)
        try:
            line = f.readlines()
            a = string.join(line)

            if "Request timed out.." not in a:
                print("Ping is not successful.")
                pLogger.info("Ping is not successful.")
            else:
                print ("Ping is successful.")
                pLogger.info("Ping is successful.")

        finally:
            f.close()
    else:
        pLogger.info("File doesn't exist")
=======================================================

But I have question to ask, as you can see I am using "time.sleep(30)" to
make my code wait. Is there any other way I can write my script to resolve
synchronization issues.

Thanks,
AD

On Thu, Sep 17, 2009 at 12:13 AM, Steve Willoughby <st...@alchemy.com>wrote:

> > Ansuman Dash wrote:
> > >Now I am trying to validate that the command is executed successfully.
> > >I have written following script to validate the log file which is
> created
> > >after running the command.
>
> Notice what's happening here:
>
> > >            for line in f.readlines():
> > >                a=line
>
> This sets a to EACH line from the file, overwriting
> the previous one.  What you end up with after that
> executes is a holding the LAST line in the file.
>
> > >            if "Request timed out.." not in a:
> > >                print("Ping is not successful.")
> > >                pLogger.info("Ping is not successful.")
>
> Also... this looks backwards.  If "Request timed out.." is NOT found
> then the ping was NOT successful?
>
> --
> Steve Willoughby    |  Using billion-dollar satellites
> st...@alchemy.com   |  to hunt for Tupperware.
>
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to