releases/openstack_releases/xstaticutils.py
Sean McGinnis cf3504c6d8 Add validation for xstatic package versions
Xstatic packages need their version hard coded in the source. This
can cause problems if the version committed in the repo is different
than the tag being requested. This adds checking to our validation
to make sure there is not a mismatch for this value.

Change-Id: I5ad54c3623fe5caf3dd075195fb75a3a48165ebf
2018-06-25 09:40:46 -05:00

46 lines
1.4 KiB
Python

# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
import importlib
import os
import sys
def get_versions(workdir, repo):
"""Get the package versions from packages."""
versions = []
# Switch to the workdir
start_path = os.getcwd()
repo_dir = '%s/%s' % (workdir, repo)
os.chdir(repo_dir)
# Add the repo to the PYTHONPATH so we can import its contents
sys.path.append(repo_dir)
# Extract PACAKGE_VERSION from any xstatic packages found
try:
for name in os.listdir('xstatic/pkg'):
if '__' in name:
continue
if os.path.isdir('xstatic/pkg/%s' % name):
xs = importlib.import_module('xstatic.pkg.%s' % name)
versions.append(xs.PACKAGE_VERSION)
finally:
# Get back to our original state
sys.path.pop()
os.chdir(start_path)
return versions