All pastes #802221 Raw Edit

Omer F. USTA

public diff v1 · immutable
#802221 ·published 2007-11-30 00:16 UTC
rendered paste body
--- fetcher.py.old	Fri Nov 30 00:47:35 2007+++ fetcher.py	Fri Nov 30 00:47:12 2007@@ -144,7 +144,10 @@ class Fetcher:                            reget        = self._test_range_support(),                            user_agent   = 'PiSi Fetcher/' + pisi.__version__)         except urlgrabber.grabber.URLGrabError, e:-            raise FetchError(_('Could not fetch destination file "%s": %s') % (self.archive_file, e))+            if self.checkInternetConnection():+                raise FetchError(_('Could not fetch destination file "%s": %s') % (self.archive_file, e))+            else:+                raise FetchError(_('Check whether got a stable internet connection or not'))          if os.stat(self.partial_file).st_size == 0:             os.remove(self.partial_file)@@ -192,6 +195,15 @@ class Fetcher:             return 1024 * int(bandwidth_limit)         else:             return 0+        +    def checkInternetConnection(self):+        import urllib2+        try:+            file_obj = urllib2.urlopen("http://www.pardus.org.tr/resim/tubitak-uekae.png")+            file_obj.close()+            return True+        except:+            return False      def _test_range_support(self):         if not os.path.exists(self.partial_file):@@ -212,5 +224,8 @@ class Fetcher: # helper function def fetch_url(url, destdir, progress=None):     fetch = Fetcher(url, destdir)-    fetch.progress = progress-    fetch.fetch()+    if fetch.checkInternetConnection():+        fetch.progress = progress+        fetch.fetch()+    else:+        raise FetchError(_('Check whether got a stable internet connection or not'))