I need help understanding my error with urllib.
I wrote the following code to check the availability of updates for a software I wrote
try: datasource = urllib.urlopen("URL to FILE.txt") while 1: line = datasource.readline() if line == "": break if (line.find("<") > -1) : LastVersion="Error" else: LastVersion=line if LastVersion=="Error": do something elif version.VERSION==LastVersion: do somethingelse else: versioncheck = wx.MessageDialog(None,"It seems that a new version [v. "+LastVersion+"] is available!","MySoftware "+version.VERSION+"", wx.OK | wx.ICON_INFORMATION | wx.STAY_ON_TOP) versioncheck.ShowModal() except Exception, err: versioncheck = wx.MessageDialog(None,"An error has occurred in version checking. Please, try again later or contact the author","MySoftware "+version.VERSION+"", wx.OK | wx.ICON_ERROR | wx.STAY_ON_TOP) versioncheck.ShowModal()
Now, I don't understand why the
urllib.urlopen("URL to FILE.txt") returns the last line of that txt file and not the first (as I need).
Can you help me understand? And how can I fix it?