
This just does python rewrites of these tools that were shell or sed or grep. Clearly the user of cloud-init has python, but it turns out that getting sane versions of sed or grep on different unixes is less than simple.
27 lines
738 B
Python
Executable File
27 lines
738 B
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import os
|
|
import re
|
|
import sys
|
|
|
|
if 'CLOUD_INIT_TOP_D' in os.environ:
|
|
topd = os.path.realpath(os.environ.get('CLOUD_INIT_TOP_D'))
|
|
else:
|
|
topd = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
|
|
|
|
for fname in ("setup.py", "ChangeLog"):
|
|
if not os.path.isfile(os.path.join(topd, fname)):
|
|
sys.stderr.write("Unable to locate '%s' file that should "
|
|
"exist in cloud-init root directory." % fname)
|
|
sys.exit(1)
|
|
|
|
vermatch = re.compile(r"^[0-9]+[.][0-9]+[.][0-9]+:$")
|
|
|
|
with open(os.path.join(topd, "ChangeLog"), "r") as fp:
|
|
for line in fp:
|
|
if vermatch.match(line):
|
|
sys.stdout.write(line.strip()[:-1] + "\n")
|
|
break
|
|
|
|
sys.exit(0)
|