Skip to content

Commit

Permalink
add exe build support; add new locker & singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
tsbxmw committed Mar 15, 2019
1 parent 9f15e8e commit d8f844c
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
Binary file added docs/png/haf.ico
Binary file not shown.
4 changes: 4 additions & 0 deletions haf/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,7 @@ def main_args():
print("using python -m haf help to show help infos")


if __name__ == "__main__":
import multiprocessing
multiprocessing.freeze_support()
main_args()
14 changes: 13 additions & 1 deletion haf/mark.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# encoding='utf-8'
import functools
import inspect
import contextlib
import time
from haf.common.lock import Lock

Expand Down Expand Up @@ -90,4 +91,15 @@ def lock(self, *args, **kwargs):
func(self, *args, **kwargs)
locker.release_lock()
return
return lock
return lock


@contextlib.contextmanager
def new_locker(bus_client, key):
locker = Locker(bus_client, key)
locker.get_lock()
try:
yield
finally:
locker.release_lock()
return
8 changes: 5 additions & 3 deletions haf/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from haf.common.exception import FailRunnerException
from haf.common.log import Log
from haf.config import *
from haf.mark import locker
from haf.mark import locker, new_locker
from haf.result import HttpApiResult, AppResult, WebResult
from haf.suite import HttpApiSuite, AppSuite
from haf.utils import Utils
Expand Down Expand Up @@ -64,10 +64,12 @@ def put_web_message(self, key:str):
self.web_queue.get()
self.web_queue.put(self.runner)

@locker
# TODO: try new_locker here, still need some tests
# @locker
def put_case_back(self, key:str, case):
logger.info(f"{self.runner_key} : runner put case {case.ids.id}.{case.ids.subid}-{case.ids.name}")
self.case_handler_queue.put(case)
with new_locker(self.bus_client, key):
self.case_handler_queue.put(case)

def result_handler(self, result):
if isinstance(result, HttpApiResult) or isinstance(result, AppResult):
Expand Down
3 changes: 3 additions & 0 deletions publish/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
xcopy /e /a /y ..\haf\* .\
pyinstaller -F main.py -i ..\docs\png\haf.ico --additional-hooks-dir=

5 changes: 5 additions & 0 deletions publish/hook-ctypes.macholib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# -*- coding: utf-8 -*-

from PyInstaller.utils.hooks import copy_metadata

datas = copy_metadata('jsonschema')

0 comments on commit d8f844c

Please sign in to comment.