summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@linux.intel.com>2014-08-03 17:02:31 -0500
committerRichard Purdie <richard.purdie@linuxfoundation.org>2014-08-11 10:53:09 +0100
commit29fb556a880e62f3b1193762af08688e32da8c6a (patch)
tree25a03a225b9574bf19696dec1352a35b416b356e /scripts
parentd9096a659ea62274740b74a36f0dba5246cac236 (diff)
downloadpoky-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>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lib/mic/utils/grabber.py97
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
3import os
4import sys
5import rpm
6import fcntl
7import struct
8import termios
9
10from mic import msger
11from mic.utils import runner
12from mic.utils.errors import CreatorError
13
14from urlgrabber import grabber
15from urlgrabber import __version__ as grabber_version
16
17if 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
21def 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
54def 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
63def truncate_url(url, width):
64 return os.path.basename(url)[0:width]
65
66class 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