Skip to content

Commit

Permalink
Fix args for Popen while running gauge to get version #125
Browse files Browse the repository at this point in the history
  • Loading branch information
BugDiver committed Dec 24, 2018
1 parent 14cdc73 commit 7cfdccd
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions check_and_install_getgauge.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,46 @@


def get_version():
proc = Popen(['gauge', '-v', '--machine-readable'], stdout=PIPE, stderr=PIPE, shell=True)
proc = Popen("gauge -v --machine-readable",
stdout=PIPE, stderr=PIPE, shell=True)
out, _ = proc.communicate()
data = json.loads(str(out.decode()))
for plugin in data['plugins']:
if plugin['name'] == 'python':
return plugin['version']
return ''


def get_dev_getgauge_version(plugin_nightly_version):
refined_version = plugin_nightly_version.replace('nightly','').replace('-','')
refined_version = plugin_nightly_version.replace(
'nightly', '').replace('-', '')
return refined_version[:6] + "dev" + refined_version[6:]


def install_getgauge(getgauge_version):
if "dev" in getgauge_version:
subprocess.call([sys.executable, "-m", "pip", "install", "--pre", getgauge_version, "--user"],stdout=open(os.devnull, 'wb'))
subprocess.call([sys.executable, "-m", "pip", "install", "--pre",
getgauge_version, "--user"], stdout=open(os.devnull, 'wb'))
else:
subprocess.call([sys.executable, "-m", "pip", "install",getgauge_version,"--user"],stdout=open(os.devnull, 'wb'))
subprocess.call([sys.executable, "-m", "pip", "install",
getgauge_version, "--user"], stdout=open(os.devnull, 'wb'))


def assert_versions():
python_plugin_version = get_version()
expected_gauge_version = python_plugin_version
expected_gauge_version = python_plugin_version

if "nightly" in python_plugin_version:
expected_gauge_version = get_dev_getgauge_version(python_plugin_version)
expected_gauge_version = get_dev_getgauge_version(
python_plugin_version)

try:
getgauge_version = pkg_resources.get_distribution('getgauge').version
getgauge_version = pkg_resources.get_distribution('getgauge').version
if getgauge_version is not expected_gauge_version:
install_getgauge("getgauge=="+expected_gauge_version)
except pkg_resources.DistributionNotFound:
install_getgauge("getgauge=="+expected_gauge_version)



if __name__ == '__main__':
assert_versions()


assert_versions()

0 comments on commit 7cfdccd

Please sign in to comment.