fetcher: Add a timeout parameter to Fetcher.test()

This commit is contained in:
Fatih Aşıcı
2011-01-31 09:01:18 +00:00
parent 29acb90f34
commit 303d800148
+3 -2
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# Copyright (C) 2005 - 2007, TUBITAK/UEKAE # Copyright (C) 2005 - 2011, TUBITAK/UEKAE
# #
# This program is free software; you can redistribute it and/or modify it under # This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free # the terms of the GNU General Public License as published by the Free
@@ -122,7 +122,7 @@ class Fetcher:
util.ensure_dirs(self.destdir) util.ensure_dirs(self.destdir)
def test(self): def test(self, timeout=3):
import urlgrabber import urlgrabber
try: try:
@@ -130,6 +130,7 @@ class Fetcher:
http_headers = self._get_http_headers(), http_headers = self._get_http_headers(),
ftp_headers = self._get_ftp_headers(), ftp_headers = self._get_ftp_headers(),
proxies = self._get_proxies(), proxies = self._get_proxies(),
timeout = timeout,
user_agent = 'PiSi Fetcher/' + pisi.__version__) user_agent = 'PiSi Fetcher/' + pisi.__version__)
except urlgrabber.grabber.URLGrabError: except urlgrabber.grabber.URLGrabError:
return False return False