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
+28 -26
View File
@@ -8,37 +8,39 @@ import PyQt4.QtCore as QtCore
from gui_backend import Controller
if len(sys.argv) > 1:
dir_name_raw = sys.argv[1]
else:
dir_name_raw = "."
dir_name = os.path.abspath(dir_name_raw)
def main():
if len(sys.argv) > 1:
dir_name_raw = sys.argv[1]
else:
dir_name_raw = "."
dir_name = os.path.abspath(dir_name_raw)
# GUI initializations
app = htmlPy.AppGUI(title=u"{dir_name} - Test Status".format(dir_name=dir_name),
developer_mode=True, width=150, height=80)
app.window.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
screen_geo = QApplication.desktop().availableGeometry()
screen_topright = screen_geo.topRight()
app.x_pos = (screen_topright.x() - 20) - app.width
app.y_pos = (screen_topright.y() + 20)
# import pdb;pdb.set_trace()
# GUI initializations
app = htmlPy.AppGUI(title=u"{dir_name} - Test Status".format(dir_name=dir_name),
developer_mode=True, width=150, height=80)
app.window.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint)
screen_geo = QApplication.desktop().availableGeometry()
screen_topright = screen_geo.topRight()
app.x_pos = (screen_topright.x() - 20) - app.width
app.y_pos = (screen_topright.y() + 20)
# import pdb;pdb.set_trace()
# GUI configarg
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
app.static_path = os.path.join(BASE_DIR, "static/")
app.template_path = os.path.join(BASE_DIR, "tmpl/")
app.dir_name = dir_name
# GUI configarg
BASE_DIR = os.path.abspath(os.path.dirname(__file__))
app.static_path = os.path.join(BASE_DIR, "static/")
app.template_path = os.path.join(BASE_DIR, "tmpl/")
app.dir_name = dir_name
# Register back-end functionalities
app_backend = Controller(app)
app.bind(app_backend)
# Register back-end functionalities
app_backend = Controller(app)
app.bind(app_backend)
# GUI render config
# app.html = u""
app_backend.redraw()
# GUI render config
# app.html = u""
app_backend.redraw()
app.start()
# Start application
if __name__ == "__main__":
app.start()
main()
+16 -5
View File
@@ -4,6 +4,7 @@ import time
import sys
import redis
import os
import psutil
env_redis_port = os.environ.get("pytest_status_port")
if env_redis_port:
@@ -14,6 +15,8 @@ else:
command_redis_server_gen = "redis-server --port {port} --maxheap 20MB"
command_redis_server = command_redis_server_gen.format(port=REDIS_PORT)
command_status_gui = "pytest_gui_status"
# Redis will look like:
# PYTEST_STATUS_DB = 1
# 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}_fail = [test_b_name,...]
# {hash_a}_skip = [test_c_name,...]
# {hash_a}_gui_pid = pid # check this before launching gui
class Helpers(object):
@@ -70,11 +74,22 @@ class Helpers(object):
# set last updated
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
def on_collectstart(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)
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):
# 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)
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):
# 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)
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):
# 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)
list_testname_pass = [test_result.nodeid for test_result in
@@ -136,7 +148,6 @@ class Helpers(object):
def on_end(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)
redis_db.set("{hash_a}_state".format(hash_a=hash_dir_name), "end")
+3
View File
@@ -1,2 +1,5 @@
pytest
python-dateutil
psutil
humanfriendly
+5 -2
View File
@@ -13,7 +13,7 @@ package_dir = {
setup(
name='pytest_gui_status',
version='0.0.2',
version='0.0.3',
description='Show pytest status in gui',
author='Abhas Bhattacharya',
author_email='abhasbhattacharya2@gmail.com',
@@ -26,6 +26,9 @@ setup(
entry_points={
# 'pytest11': [
# 'pytest_gui_status = pytest_gui_status.main',
# ]
# ],
'console_scripts': [
'pytest_gui_status = pytest_gui_status.status_gui.gui_frontend:main',
]
},
)