Skip to contentSkip to conversation

wic: remove all urlgrabber references

PATCH New Tom Zanussi 1 participant 2 messages Sep 9, 2014

lore
Share & tools
lore
#0 lore raw

cover wic: remove all urlgrabber references

This fixes a problem noticed by a user, that urlgrabber was still being referenced even though it had been removed from the 3rdparty code.

The following changes since commit a44006262cf3b810ec78b4cccd8076102a7a0f3e:

distro/poky: Add Debian 7.5 and 7.6 version as validated (2014-09-03 16:00:29 +0100)

are available in the git repository at:

git://git.yoctoproject.org/poky-contrib.git tzanussi/wic-urlgrabber-fixes-2
http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=tzanussi/wic-urlgrabber-fixes-2

Tom Zanussi (1):
wic: Completely remove all urlgrabber references

 scripts/lib/wic/3rdparty/pykickstart/parser.py  | 87 +------------------------
 scripts/lib/wic/3rdparty/pykickstart/version.py | 29 ---------
 2 files changed, 2 insertions(+), 114 deletions(-)
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH 1/1 wic: Completely remove all urlgrabber references

The previous commit, 'wic: Remove 3rdparty/urlgrabber' didn't actually remove all references to urlgrabber - this does however.

---
 scripts/lib/wic/3rdparty/pykickstart/parser.py  | 87 +------------------------
 scripts/lib/wic/3rdparty/pykickstart/version.py | 29 ---------
 2 files changed, 2 insertions(+), 114 deletions(-)
scripts/lib/wic/3rdparty/pykickstart/parser.py +2 -85
index 840a448..9c9674b 100644
@@ -38,8 +38,6 @@ import sys
 import tempfile
 from copy import copy
 from optparse import *
-from urlgrabber import urlread
-import urlgrabber.grabber as grabber
 
 import constants
 from errors import KickstartError, KickstartParseError, KickstartValueError, formatErrorMsg
@@ -55,87 +53,6 @@ STATE_COMMANDS = "commands"
 
 ver = version.DEVEL
 
-def _preprocessStateMachine (lineIter):
-    l = None
-    lineno = 0
-
-    # Now open an output kickstart file that we are going to write to one
-    # line at a time.
-    (outF, outName) = tempfile.mkstemp("-ks.cfg", "", "/tmp")
-
-    while True:
-        try:
-            l = lineIter.next()
-        except StopIteration:
-            break
-
-        # At the end of the file?
-        if l == "":
-            break
-
-        lineno += 1
-        url = None
-
-        ll = l.strip()
-        if not ll.startswith("%ksappend"):
-            os.write(outF, l)
-            continue
-
-        # Try to pull down the remote file.
-        try:
-            ksurl = ll.split(' ')[1]
-        except:
-            raise KickstartParseError, formatErrorMsg(lineno, msg=_("Illegal url for %%ksappend: %s") % ll)
-
-        try:
-            url = grabber.urlopen(ksurl)
-        except grabber.URLGrabError, e:
-            raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file: %s") % e.strerror)
-        else:
-            # Sanity check result.  Sometimes FTP doesn't catch a file
-            # is missing.
-            try:
-                if url.size < 1:
-                    raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file"))
-            except:
-                raise KickstartError, formatErrorMsg(lineno, msg=_("Unable to open %%ksappend file"))
-
-        # If that worked, write the remote file to the output kickstart
-        # file in one burst.  Then close everything up to get ready to
-        # read ahead in the input file.  This allows multiple %ksappend
-        # lines to exist.
-        if url is not None:
-            os.write(outF, url.read())
-            url.close()
-
-    # All done - close the temp file and return its location.
-    os.close(outF)
-    return outName
-
-def preprocessFromString (s):
-    """Preprocess the kickstart file, provided as the string str.  This
-        method is currently only useful for handling %ksappend lines,
-        which need to be fetched before the real kickstart parser can be
-        run.  Returns the location of the complete kickstart file.
-    """
-    i = iter(s.splitlines(True) + [""])
-    rc = _preprocessStateMachine (i.next)
-    return rc
-
-def preprocessKickstart (f):
-    """Preprocess the kickstart file, given by the filename file.  This
-        method is currently only useful for handling %ksappend lines,
-        which need to be fetched before the real kickstart parser can be
-        run.  Returns the location of the complete kickstart file.
-    """
-    try:
-        fh = urlopen(f)
-    except grabber.URLGrabError, e:
-        raise KickstartError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)
-
-    rc = _preprocessStateMachine (iter(fh.readlines()))
-    fh.close()
-    return rc
 
 class PutBackIterator(Iterator):
     def __init__(self, iterable):
@@ -682,8 +599,8 @@ class KickstartParser:
         self.currentdir[self._includeDepth] = cd
 
         try:
-            s = urlread(f)
-        except grabber.URLGrabError, e:
+            s = file(f).read()
+        except IOError, e:
             raise KickstartError, formatErrorMsg(0, msg=_("Unable to open input kickstart file: %s") % e.strerror)
 
         self.readKickstartFromString(s, reset=False)
scripts/lib/wic/3rdparty/pykickstart/version.py +0 -29
index 102cc37..8a8e6aa 100644
@@ -44,7 +44,6 @@ This module also exports several functions:
                       have a version= comment in it.
 """
 import imputil, re, sys
-from urlgrabber import urlopen
 
 import gettext
 _ = lambda x: gettext.ldgettext("pykickstart", x)
@@ -132,34 +131,6 @@ def versionToString(version, skipDevel=False):
 
     raise KickstartVersionError(_("Unsupported version specified: %s") % version)
 
-def versionFromFile(f):
-    """Given a file or URL, look for a line starting with #version= and
-       return the version number.  If no version is found, return DEVEL.
-    """
-    v = DEVEL
-
-    fh = urlopen(f)
-
-    while True:
-        try:
-            l = fh.readline()
-        except StopIteration:
-            break
-
-        # At the end of the file?
-        if l == "":
-            break
-
-        if l.isspace() or l.strip() == "":
-            continue
-
-        if l[:9] == "#version=":
-            v = stringToVersion(l[9:].rstrip())
-            break
-
-    fh.close()
-    return v
-
 def returnClassForVersion(version=DEVEL):
     """Return the class of the syntax handler for version.  version can be
        either a string or the matching constant.  Raises KickstartValueError
Signature · 1 line
1.8.3.1