Skip to content

Commit 800792a

Browse files
committed
Remove pycurl dependency
1 parent a6e199a commit 800792a

File tree

2 files changed

+9
-30
lines changed

2 files changed

+9
-30
lines changed

requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,5 @@ requests
99
mbed-ls>=0.2.13
1010
mbed-host-tests>=1.1.2
1111
mbed-greentea>=0.2.24
12-
pycurl>=4
1312
beautifulsoup4>=4
1413
fuzzywuzzy>=0.11

tools/arm_pack_manager/__init__.py

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from pycurl import Curl
1+
from urllib2 import urlopen, URLError
22
from bs4 import BeautifulSoup
33
from os.path import join, dirname, basename
44
from os import makedirs
@@ -49,19 +49,6 @@ def run(self) :
4949
self.func(url)
5050
self.queue.task_done()
5151

52-
class Cacher (Thread) :
53-
def __init__(self, queue, func) :
54-
Thread.__init__(self)
55-
self.queue = queue
56-
self.curl = Curl()
57-
self.curl.setopt(self.curl.FOLLOWLOCATION, True)
58-
self.func = func
59-
def run(self) :
60-
while True :
61-
url = self.queue.get()
62-
self.func(self.curl, url)
63-
self.queue.task_done()
64-
6552

6653
class Cache () :
6754
""" The Cache object is the only relevant API object at the moment
@@ -88,7 +75,7 @@ def display_counter (self, message) :
8875
stdout.write("{} {}/{}\r".format(message, self.counter, self.total))
8976
stdout.flush()
9077

91-
def cache_file (self, curl, url) :
78+
def cache_file (self, url) :
9279
"""Low level interface to caching a single file.
9380
9481
:param curl: The user is responsible for providing a curl.Curl object as the curl parameter.
@@ -104,18 +91,11 @@ def cache_file (self, curl, url) :
10491
except OSError as exc :
10592
if exc.errno == EEXIST : pass
10693
else : raise
107-
with open(dest, "wb+") as fd :
108-
curl.setopt(curl.URL, url)
109-
curl.setopt(curl.FOLLOWLOCATION, True)
110-
curl.setopt(curl.WRITEDATA, fd)
111-
if not self.no_timeouts :
112-
curl.setopt(curl.CONNECTTIMEOUT, 2)
113-
curl.setopt(curl.LOW_SPEED_LIMIT, 50 * 1024)
114-
curl.setopt(curl.LOW_SPEED_TIME, 2)
115-
try :
116-
curl.perform()
117-
except Exception as e :
118-
stderr.write("[ ERROR ] file {} did not download {}\n".format(url, str(e)))
94+
try:
95+
with open(dest, "wb+") as fd :
96+
fd.write(urlopen(url).read())
97+
except URLError as e:
98+
stderr.write(e.reason)
11999
self.counter += 1
120100
self.display_counter("Caching Files")
121101

@@ -401,7 +381,7 @@ def cache_descriptor_list(self, list) :
401381
"""
402382
self.total = len(list)
403383
self.display_counter("Caching Files")
404-
do_queue(Cacher, self.cache_file, list)
384+
do_queue(Reader, self.cache_file, list)
405385
stdout.write("\n")
406386

407387
def cache_pack_list(self, list) :
@@ -412,7 +392,7 @@ def cache_pack_list(self, list) :
412392
"""
413393
self.total = len(list) * 2
414394
self.display_counter("Caching Files")
415-
do_queue(Cacher, self.cache_pdsc_and_pack, list)
395+
do_queue(Reader, self.cache_pdsc_and_pack, list)
416396
stdout.write("\n")
417397

418398
def pdsc_from_cache(self, url) :

0 commit comments

Comments
 (0)