On 30/03/12 06:14, James Cammarata wrote:
On Thu, Mar 29, 2012 at 6:50 PM, James Cammarata
<jimi(a)sngx.net> wrote:
> So the .lower() has been in there forever. The real issue is that I
> changed it to return x, whereas before it was returning the url
> variable, which did not work if the url started with whitespace. The
> lower() just seems to make sure you get http instead of HtTp or
> something random a user may enter, so I'll fix this to be a bit
> smarter. Sorry for the breakage.
Here's my fix:
# git diff
diff --git a/cobbler/utils.py b/cobbler/utils.py
index f30cdff..7a83317 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -432,8 +432,11 @@ def find_kickstart(url):
"""
if url is None:
return None
- x = url.lower().lstrip()
+ x = url.lstrip()
for y in ["http://", "nfs://", "ftp://",
"/"]:
+ # make sure we get a lower-case protocol without
+ # affecting the rest of the string
+ x = re.sub(r"(?i)%s" % y, y, x, count=1)
if x.startswith(y):
if x.startswith("/") and not os.path.isfile(x):
return None
Test results:
$ cobbler profile edit --name=test
--kickstart=/var/lib/cobbler/kickstarts/Test-File.ks
$ cobbler profile report --name=test | grep ^Kickstart
Kickstart : /var/lib/cobbler/kickstarts/Test-File.ks
Kickstart Metadata : {}
really?
my take on it was more like this:
$ git diff
diff --git a/cobbler/utils.py b/cobbler/utils.py
index f30cdff..d7f1da1 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -432,12 +432,13 @@ def find_kickstart(url):
"""
if url is None:
return None
- x = url.lower().lstrip()
- for y in ["http://", "nfs://", "ftp://",
"/"]:
- if x.startswith(y):
- if x.startswith("/") and not os.path.isfile(x):
- return None
- return x
+ proto, path = urllib2.splittype(url.lstrip())
+ if proto:
+ if proto in ["http", "nfs", "ftp"]:
+ return '%s:%s' %( proto.lower(), path)
+ else:
+ if path.startswith('/') and os.path.isfile(path):
+ return path
return None
with the same test results.
still, as long as it works now...
Stuart
--
Stuart Sears RHCA etc. "It's today!" said Piglet. "My favourite
day,"
said Pooh.