This repository was archived by the owner on Sep 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[add] wfhelper: Add multi session support
- Loading branch information
Showing
11 changed files
with
289 additions
and
243 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
/configs | ||
/prebuilt | ||
/runners | ||
/template | ||
/tools | ||
__pycache__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import os | ||
import sys | ||
from pathlib import Path | ||
|
||
from lib.logger import Logger | ||
|
||
VENV_PYTHON_PATH = 'tools/Scripts/python.exe' | ||
RUNNER_DIR = 'runners/' | ||
WIN_SCRIPT_NAME = '.bat' | ||
LINUX_SCRIPT_NAME = '.sh' | ||
|
||
if len(sys.argv) == 3: | ||
if not 0 <= int(sys.argv[1]) <= 65536: | ||
Logger.displayLog("端口号无效", Logger.LOG_LEVEL_ERROR, -1) | ||
WIN_SCRIPT_NAME = sys.argv[2] + WIN_SCRIPT_NAME | ||
LINUX_SCRIPT_NAME = sys.argv[2] + LINUX_SCRIPT_NAME | ||
else: | ||
print("Usage: {filename} [port] [session_name]" | ||
.format(filename=os.path.basename(sys.argv[0]))) | ||
exit(-1) | ||
|
||
if not Path(RUNNER_DIR).exists(): | ||
os.makedirs(RUNNER_DIR) | ||
|
||
|
||
def generateRunScript(name): | ||
if 'win' in sys.platform: | ||
with open(RUNNER_DIR + WIN_SCRIPT_NAME, 'w') as run_bat: | ||
run_bat.writelines('@title {name}\n'.format(name=name)) | ||
run_bat.writelines('cd ..\n') | ||
run_bat.writelines('{python_path} wfhelper.py {port} {config_path}\n' | ||
.format( | ||
python_path=VENV_PYTHON_PATH.replace('/', '\\'), | ||
port=sys.argv[1], | ||
config_path='configs/{name}.ini'.format(name=name) | ||
)) | ||
if 'linux' in sys.platform or 'mac' in sys.platform: | ||
with open(RUNNER_DIR + LINUX_SCRIPT_NAME, 'w') as run_sh: | ||
run_sh.writelines('#!/bin/bash\n') | ||
run_sh.writelines('cd ..\n') | ||
run_sh.writelines('{python_path} wfhelper.py {port} {config_path}\n' | ||
.format( | ||
python_path=VENV_PYTHON_PATH, | ||
port=sys.argv[1], | ||
config_path='configs/{name}.ini'.format(name=name) | ||
)) | ||
|
||
|
||
def removeOldRunScript(name): | ||
if Path(WIN_SCRIPT_NAME).exists(): | ||
os.remove(WIN_SCRIPT_NAME) | ||
if Path(LINUX_SCRIPT_NAME).exists(): | ||
os.remove(LINUX_SCRIPT_NAME) | ||
|
||
|
||
removeOldRunScript(sys.argv[2]) | ||
generateRunScript(sys.argv[2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,80 @@ | ||
import cv2 | ||
import numpy | ||
|
||
from lib.times import Time | ||
|
||
|
||
class Point: | ||
def __init__(self, x: float, y: float): | ||
self.x = x | ||
self.y = y | ||
|
||
def loadZoom(self, zoom: float): | ||
if zoom > 1.0: | ||
self.x = self.x * zoom | ||
self.y = self.y * zoom | ||
|
||
|
||
class Rect: | ||
def __init__(self, left_top: Point, right_bottom: Point): | ||
self.left_top = left_top | ||
self.right_bottom = right_bottom | ||
|
||
|
||
class Rgb: | ||
def __init__(self, r, g, b): | ||
self.red = r | ||
self.green = g | ||
self.blue = b | ||
|
||
@staticmethod | ||
def point2rgb(img: cv2.cv2, point: Point): | ||
return Rgb.pixel2rgb(img[point.y, point.x]) | ||
|
||
@staticmethod | ||
def pixel2rgb(pixel: numpy.ndarray): | ||
return Rgb(pixel[2], pixel[1], pixel[0]) | ||
|
||
|
||
class Color: | ||
def __init__(self, left: Rgb, right: Rgb): | ||
self.left = left | ||
self.right = right | ||
|
||
def isMatch(self, src: Rgb): | ||
return (self.left.red <= src.red <= self.right.red) and \ | ||
(self.left.green <= src.green <= self.right.green) and \ | ||
(self.left.blue <= src.blue <= self.right.blue) | ||
|
||
|
||
class Boss: | ||
BossLevels = { | ||
'prim': '初级', | ||
'mid': '中级', | ||
'high': '高级', | ||
'highp': '高级+', | ||
'super': '超级' | ||
} | ||
|
||
def __init__(self, item: dict): | ||
self.item = item | ||
|
||
def isAvailable(self) -> bool: | ||
end_time = Time.getTimeStampByStandardFormat(self.item['end']) | ||
now_time = Time.getTimeStampForNow() | ||
return end_time > now_time | ||
|
||
def getName(self) -> str: | ||
return self.item['name'] | ||
|
||
def getId(self) -> str: | ||
return self.item['id'] | ||
|
||
def getType(self) -> str: | ||
return self.item['type'] | ||
|
||
def getLevels(self) -> str: | ||
return self.item['levels'] | ||
|
||
def getMinLevel(self): | ||
return self.getLevels().split(' ')[0] | ||
import cv2 | ||
import numpy | ||
|
||
from lib.times import Time | ||
|
||
|
||
class Point: | ||
def __init__(self, x: float, y: float): | ||
self.x = x | ||
self.y = y | ||
|
||
def loadZoom(self, zoom: float): | ||
if zoom > 1.0: | ||
self.x = self.x * zoom | ||
self.y = self.y * zoom | ||
|
||
|
||
class Rect: | ||
def __init__(self, left_top: Point, right_bottom: Point): | ||
self.left_top = left_top | ||
self.right_bottom = right_bottom | ||
|
||
|
||
class Rgb: | ||
def __init__(self, r, g, b): | ||
self.red = r | ||
self.green = g | ||
self.blue = b | ||
|
||
@staticmethod | ||
def point2rgb(img: cv2.cv2, point: Point): | ||
return Rgb.pixel2rgb(img[point.y, point.x]) | ||
|
||
@staticmethod | ||
def pixel2rgb(pixel: numpy.ndarray): | ||
return Rgb(pixel[2], pixel[1], pixel[0]) | ||
|
||
|
||
class Color: | ||
def __init__(self, left: Rgb, right: Rgb): | ||
self.left = left | ||
self.right = right | ||
|
||
def isMatch(self, src: Rgb): | ||
return (self.left.red <= src.red <= self.right.red) and \ | ||
(self.left.green <= src.green <= self.right.green) and \ | ||
(self.left.blue <= src.blue <= self.right.blue) | ||
|
||
|
||
class Boss: | ||
BossLevels = { | ||
'prim': '初级', | ||
'mid': '中级', | ||
'high': '高级', | ||
'highp': '高级+', | ||
'super': '超级' | ||
} | ||
|
||
def __init__(self, item: dict): | ||
self.item = item | ||
|
||
def isAvailable(self) -> bool: | ||
end_time = Time.getTimeStampByStandardFormat(self.item['end']) | ||
now_time = Time.getTimeStampForNow() | ||
return end_time > now_time | ||
|
||
def getName(self) -> str: | ||
return self.item['name'] | ||
|
||
def getId(self) -> str: | ||
return self.item['id'] | ||
|
||
def getType(self) -> str: | ||
return self.item['type'] | ||
|
||
def getLevels(self) -> str: | ||
return self.item['levels'] | ||
|
||
def getMinLevel(self): | ||
return self.getLevels().split(' ')[0] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.