Make gui executable and plugin func to call it on start

New requirement added:
	psutil - to check if pid is running on unix + windows

plugin still doesnt start gui on start, test the func first
This commit is contained in:
2015-12-19 22:33:25 +05:30
parent 34b3b7d3d5
commit 8446ef78fc
4 changed files with 52 additions and 33 deletions
+3 -1
View File
@@ -8,6 +8,7 @@ import PyQt4.QtCore as QtCore
from gui_backend import Controller from gui_backend import Controller
def main():
if len(sys.argv) > 1: if len(sys.argv) > 1:
dir_name_raw = sys.argv[1] dir_name_raw = sys.argv[1]
else: else:
@@ -38,7 +39,8 @@ app.bind(app_backend)
# app.html = u"" # app.html = u""
app_backend.redraw() app_backend.redraw()
app.start()
# Start application # Start application
if __name__ == "__main__": if __name__ == "__main__":
app.start() main()
+16 -5
View File
@@ -4,6 +4,7 @@ import time
import sys import sys
import redis import redis
import os import os
import psutil
env_redis_port = os.environ.get("pytest_status_port") env_redis_port = os.environ.get("pytest_status_port")
if env_redis_port: if env_redis_port:
@@ -14,6 +15,8 @@ else:
command_redis_server_gen = "redis-server --port {port} --maxheap 20MB" command_redis_server_gen = "redis-server --port {port} --maxheap 20MB"
command_redis_server = command_redis_server_gen.format(port=REDIS_PORT) command_redis_server = command_redis_server_gen.format(port=REDIS_PORT)
command_status_gui = "pytest_gui_status"
# Redis will look like: # Redis will look like:
# PYTEST_STATUS_DB = 1 # PYTEST_STATUS_DB = 1
# directories_to_hash = {"dir_a":hash_a,"dir_b":hash_b} # directories_to_hash = {"dir_a":hash_a,"dir_b":hash_b}
@@ -25,6 +28,7 @@ command_redis_server = command_redis_server_gen.format(port=REDIS_PORT)
# {hash_a}_pass = [test_a_name,...] # {hash_a}_pass = [test_a_name,...]
# {hash_a}_fail = [test_b_name,...] # {hash_a}_fail = [test_b_name,...]
# {hash_a}_skip = [test_c_name,...] # {hash_a}_skip = [test_c_name,...]
# {hash_a}_gui_pid = pid # check this before launching gui
class Helpers(object): class Helpers(object):
@@ -70,11 +74,22 @@ class Helpers(object):
# set last updated # set last updated
Helpers.modify_last_updated(dir_name) Helpers.modify_last_updated(dir_name)
@staticmethod
def start_gui(dir_name):
# craete redis connection
redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0)
hash_dir_name = redis_db.hget("directories_to_hash", dir_name)
existing_gui_pid = redis_db.get("{hash_a}_gui_pid".format(hash_a=hash_dir_name))
if (not existing_gui_pid) or (not psutil.pid_exists(existing_gui_pid)):
gui_popen_obj = subprocess.Popen(command_status_gui)
gui_pid = gui_popen_obj.pid
redis_db.set("{hash_a}_gui_pid".format(hash_a=hash_dir_name), gui_pid)
@staticmethod @staticmethod
def on_collectstart(dir_name): def on_collectstart(dir_name):
# craete redis connection # craete redis connection
redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0) redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0)
hash_dir_name = redis_db.hget("directories_to_hash", dir_name) hash_dir_name = redis_db.hget("directories_to_hash", dir_name)
redis_db.set("{hash_a}_state".format(hash_a=hash_dir_name), "collect") redis_db.set("{hash_a}_state".format(hash_a=hash_dir_name), "collect")
@@ -86,7 +101,6 @@ class Helpers(object):
def on_collectend(dir_name, list_test_name): def on_collectend(dir_name, list_test_name):
# craete redis connection # craete redis connection
redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0) redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0)
hash_dir_name = redis_db.hget("directories_to_hash", dir_name) hash_dir_name = redis_db.hget("directories_to_hash", dir_name)
redis_db.rpush("{hash_a}_collect".format(hash_a=hash_dir_name), *list_test_name) redis_db.rpush("{hash_a}_collect".format(hash_a=hash_dir_name), *list_test_name)
@@ -98,7 +112,6 @@ class Helpers(object):
def on_test_eachstart(dir_name): def on_test_eachstart(dir_name):
# craete redis connection # craete redis connection
redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0) redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0)
hash_dir_name = redis_db.hget("directories_to_hash", dir_name) hash_dir_name = redis_db.hget("directories_to_hash", dir_name)
redis_db.set("{hash_a}_state".format(hash_a=hash_dir_name), "runtest") redis_db.set("{hash_a}_state".format(hash_a=hash_dir_name), "runtest")
@@ -110,7 +123,6 @@ class Helpers(object):
def on_test_eachend(dir_name, list_test_result): def on_test_eachend(dir_name, list_test_result):
# craete redis connection # craete redis connection
redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0) redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0)
hash_dir_name = redis_db.hget("directories_to_hash", dir_name) hash_dir_name = redis_db.hget("directories_to_hash", dir_name)
list_testname_pass = [test_result.nodeid for test_result in list_testname_pass = [test_result.nodeid for test_result in
@@ -136,7 +148,6 @@ class Helpers(object):
def on_end(dir_name): def on_end(dir_name):
# craete redis connection # craete redis connection
redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0) redis_db = redis.StrictRedis(host='localhost', port=REDIS_PORT, db=0)
hash_dir_name = redis_db.hget("directories_to_hash", dir_name) hash_dir_name = redis_db.hget("directories_to_hash", dir_name)
redis_db.set("{hash_a}_state".format(hash_a=hash_dir_name), "end") redis_db.set("{hash_a}_state".format(hash_a=hash_dir_name), "end")
+3
View File
@@ -1,2 +1,5 @@
pytest pytest
python-dateutil python-dateutil
psutil
humanfriendly
+5 -2
View File
@@ -13,7 +13,7 @@ package_dir = {
setup( setup(
name='pytest_gui_status', name='pytest_gui_status',
version='0.0.2', version='0.0.3',
description='Show pytest status in gui', description='Show pytest status in gui',
author='Abhas Bhattacharya', author='Abhas Bhattacharya',
author_email='abhasbhattacharya2@gmail.com', author_email='abhasbhattacharya2@gmail.com',
@@ -26,6 +26,9 @@ setup(
entry_points={ entry_points={
# 'pytest11': [ # 'pytest11': [
# 'pytest_gui_status = pytest_gui_status.main', # 'pytest_gui_status = pytest_gui_status.main',
# ] # ],
'console_scripts': [
'pytest_gui_status = pytest_gui_status.status_gui.gui_frontend:main',
]
}, },
) )