diff options
author | Tom Zanussi <tom.zanussi@linux.intel.com> | 2014-08-03 17:02:31 -0500 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-08-11 10:53:09 +0100 |
commit | 29fb556a880e62f3b1193762af08688e32da8c6a (patch) | |
tree | 25a03a225b9574bf19696dec1352a35b416b356e | |
parent | d9096a659ea62274740b74a36f0dba5246cac236 (diff) | |
download | poky-29fb556a880e62f3b1193762af08688e32da8c6a.tar.gz |
wic: Remove grabber implementation
wic doesn't need to grab any urls, so remove it.
(From OE-Core rev: 55f8df07d82724b6d7ed694158ca6e9a5266cbc4)
Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | scripts/lib/mic/utils/grabber.py | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/scripts/lib/mic/utils/grabber.py b/scripts/lib/mic/utils/grabber.py deleted file mode 100644 index 45e30b4fb0..0000000000 --- a/scripts/lib/mic/utils/grabber.py +++ /dev/null | |||
@@ -1,97 +0,0 @@ | |||
1 | #!/usr/bin/python | ||
2 | |||
3 | import os | ||
4 | import sys | ||
5 | import rpm | ||
6 | import fcntl | ||
7 | import struct | ||
8 | import termios | ||
9 | |||
10 | from mic import msger | ||
11 | from mic.utils import runner | ||
12 | from mic.utils.errors import CreatorError | ||
13 | |||
14 | from urlgrabber import grabber | ||
15 | from urlgrabber import __version__ as grabber_version | ||
16 | |||
17 | if rpm.labelCompare(grabber_version.split('.'), '3.9.0'.split('.')) == -1: | ||
18 | msger.warning("Version of python-urlgrabber is %s, lower than '3.9.0', " | ||
19 | "you may encounter some network issues" % grabber_version) | ||
20 | |||
21 | def myurlgrab(url, filename, proxies, progress_obj = None): | ||
22 | g = grabber.URLGrabber() | ||
23 | if progress_obj is None: | ||
24 | progress_obj = TextProgress() | ||
25 | |||
26 | if url.startswith("file:/"): | ||
27 | filepath = "/%s" % url.replace("file:", "").lstrip('/') | ||
28 | if not os.path.exists(filepath): | ||
29 | raise CreatorError("URLGrabber error: can't find file %s" % url) | ||
30 | if url.endswith('.rpm'): | ||
31 | return filepath | ||
32 | else: | ||
33 | # untouch repometadata in source path | ||
34 | runner.show(['cp', '-f', filepath, filename]) | ||
35 | |||
36 | else: | ||
37 | try: | ||
38 | filename = g.urlgrab(url=str(url), | ||
39 | filename=filename, | ||
40 | ssl_verify_host=False, | ||
41 | ssl_verify_peer=False, | ||
42 | proxies=proxies, | ||
43 | http_headers=(('Pragma', 'no-cache'),), | ||
44 | quote=0, | ||
45 | progress_obj=progress_obj) | ||
46 | except grabber.URLGrabError, err: | ||
47 | msg = str(err) | ||
48 | if msg.find(url) < 0: | ||
49 | msg += ' on %s' % url | ||
50 | raise CreatorError(msg) | ||
51 | |||
52 | return filename | ||
53 | |||
54 | def terminal_width(fd=1): | ||
55 | """ Get the real terminal width """ | ||
56 | try: | ||
57 | buf = 'abcdefgh' | ||
58 | buf = fcntl.ioctl(fd, termios.TIOCGWINSZ, buf) | ||
59 | return struct.unpack('hhhh', buf)[1] | ||
60 | except: # IOError | ||
61 | return 80 | ||
62 | |||
63 | def truncate_url(url, width): | ||
64 | return os.path.basename(url)[0:width] | ||
65 | |||
66 | class TextProgress(object): | ||
67 | # make the class as singleton | ||
68 | _instance = None | ||
69 | def __new__(cls, *args, **kwargs): | ||
70 | if not cls._instance: | ||
71 | cls._instance = super(TextProgress, cls).__new__(cls, *args, **kwargs) | ||
72 | |||
73 | return cls._instance | ||
74 | |||
75 | def __init__(self, totalnum = None): | ||
76 | self.total = totalnum | ||
77 | self.counter = 1 | ||
78 | |||
79 | def start(self, filename, url, *args, **kwargs): | ||
80 | self.url = url | ||
81 | self.termwidth = terminal_width() | ||
82 | msger.info("\r%-*s" % (self.termwidth, " ")) | ||
83 | if self.total is None: | ||
84 | msger.info("\rRetrieving %s ..." % truncate_url(self.url, self.termwidth - 15)) | ||
85 | else: | ||
86 | msger.info("\rRetrieving %s [%d/%d] ..." % (truncate_url(self.url, self.termwidth - 25), self.counter, self.total)) | ||
87 | |||
88 | def update(self, *args): | ||
89 | pass | ||
90 | |||
91 | def end(self, *args): | ||
92 | if self.counter == self.total: | ||
93 | msger.raw("\n") | ||
94 | |||
95 | if self.total is not None: | ||
96 | self.counter += 1 | ||
97 | |||