Check for sock lib has installed

This commit is contained in:
TreeNode 2014-12-11 01:44:47 +02:00
parent aea8ff35a6
commit 54dd376b9c

View File

@ -15,7 +15,6 @@ import imaplib
import mimetypes import mimetypes
import poplib import poplib
import re import re
import socks
import socket import socket
from datetime import timedelta from datetime import timedelta
@ -87,6 +86,11 @@ def process_queue(q, quiet=False):
print "Processing: %s" % q print "Processing: %s" % q
if q.socks_proxy_type and q.socks_proxy_host and q.socks_proxy_port: if q.socks_proxy_type and q.socks_proxy_host and q.socks_proxy_port:
try:
import socks
except ImportError:
raise ImportError("Queue has been configured with proxy settings, but no socks library was installed. Try to install PySocks via pypi.")
proxy_type = { proxy_type = {
'socks4': socks.SOCKS4, 'socks4': socks.SOCKS4,
'socks5': socks.SOCKS5, 'socks5': socks.SOCKS5,