Fix imports + subparsers in python3

This commit is contained in:
Phyks 2014-08-03 00:09:07 +02:00
parent ce9d13eafa
commit 35541a43e6
2 changed files with 10 additions and 5 deletions

3
bmc.py
View File

@ -433,7 +433,8 @@ def update(entry):
if __name__ == '__main__':
parser = argparse.ArgumentParser(description="A bibliography " +
"management tool.")
subparsers = parser.add_subparsers(help="sub-command help")
subparsers = parser.add_subparsers(help="sub-command help", dest='parser')
subparsers.required = True # Fix for Python 3.3.5
parser_download = subparsers.add_parser('download', help="download help")
parser_download.add_argument('-t', '--type', default=None,

View File

@ -24,12 +24,13 @@ except ImportError:
# Fall back to Python 2's urllib2
from urllib2 import urlopen, URLError
import arxiv2bib as arxiv_metadata
import tools
import libbmc.tools
from bibtexparser.bparser import BibTexParser
from config import Config
from libbmc.config import Config
config = Config()
default_socket = socket.socket
def download(url):
@ -51,13 +52,16 @@ def download(url):
except ValueError:
port = None
socks.set_default_proxy(proxy_type, proxy, port)
else: # TODO : Reset if proxy is empty
socket.socket = socks.socksocket
elif proxy == '':
socket.socket = default_socket
else:
try:
proxy, port = proxy.split(':')
except ValueError:
port = None
socks.set_default_proxy(socks.HTTP, proxy, port)
socket.socket = socks.socksocket
socket.socket = socks.socksocket
try:
r = urlopen(url)
size = int(r.headers.getheader('content-length').strip())