Skip to content

Arm-Pack-Manager Remove pycurl dependency #3097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,5 @@ requests
mbed-ls>=0.2.13
mbed-host-tests>=1.1.2
mbed-greentea>=0.2.24
pycurl>=4
beautifulsoup4>=4
fuzzywuzzy>=0.11
38 changes: 9 additions & 29 deletions tools/arm_pack_manager/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from pycurl import Curl
from urllib2 import urlopen, URLError
from bs4 import BeautifulSoup
from os.path import join, dirname, basename
from os import makedirs
Expand Down Expand Up @@ -49,19 +49,6 @@ def run(self) :
self.func(url)
self.queue.task_done()

class Cacher (Thread) :
def __init__(self, queue, func) :
Thread.__init__(self)
self.queue = queue
self.curl = Curl()
self.curl.setopt(self.curl.FOLLOWLOCATION, True)
self.func = func
def run(self) :
while True :
url = self.queue.get()
self.func(self.curl, url)
self.queue.task_done()


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

def cache_file (self, curl, url) :
def cache_file (self, url) :
"""Low level interface to caching a single file.

:param curl: The user is responsible for providing a curl.Curl object as the curl parameter.
Expand All @@ -104,18 +91,11 @@ def cache_file (self, curl, url) :
except OSError as exc :
if exc.errno == EEXIST : pass
else : raise
with open(dest, "wb+") as fd :
curl.setopt(curl.URL, url)
curl.setopt(curl.FOLLOWLOCATION, True)
curl.setopt(curl.WRITEDATA, fd)
if not self.no_timeouts :
curl.setopt(curl.CONNECTTIMEOUT, 2)
curl.setopt(curl.LOW_SPEED_LIMIT, 50 * 1024)
curl.setopt(curl.LOW_SPEED_TIME, 2)
try :
curl.perform()
except Exception as e :
stderr.write("[ ERROR ] file {} did not download {}\n".format(url, str(e)))
try:
with open(dest, "wb+") as fd :
fd.write(urlopen(url).read())
except URLError as e:
stderr.write(e.reason)
self.counter += 1
self.display_counter("Caching Files")

Expand Down Expand Up @@ -401,7 +381,7 @@ def cache_descriptor_list(self, list) :
"""
self.total = len(list)
self.display_counter("Caching Files")
do_queue(Cacher, self.cache_file, list)
do_queue(Reader, self.cache_file, list)
stdout.write("\n")

def cache_pack_list(self, list) :
Expand All @@ -412,7 +392,7 @@ def cache_pack_list(self, list) :
"""
self.total = len(list) * 2
self.display_counter("Caching Files")
do_queue(Cacher, self.cache_pdsc_and_pack, list)
do_queue(Reader, self.cache_pdsc_and_pack, list)
stdout.write("\n")

def pdsc_from_cache(self, url) :
Expand Down