-
Notifications
You must be signed in to change notification settings - Fork 0
/
constant.py
61 lines (53 loc) · 2.63 KB
/
constant.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env python3
# encoding: utf-8
import os
import platform
import subprocess
from pathlib import Path
class PROJ:
PLATFORM = platform.system().lower()
SYS_OS = "windows" if PLATFORM.startswith('windows') else "mac" if PLATFORM.startswith('darwin') else 'linux'
HOME_DIR = os.getenv("HOME") if os.getenv("HOME") else ""
# 目录结构
PROJECT_DIR = Path(os.path.dirname(__file__))
CONFIG_DIR = PROJECT_DIR
SCRIPT_DIR = PROJECT_DIR / Path('tests')
RESULT_DIR = PROJECT_DIR / Path('result')
REPORT_DIR = PROJECT_DIR / Path('result/reports')
LOG_DIR = PROJECT_DIR / Path('result/logs')
# 配置和数据文件
GLOBAL_FILE = 'global.yml'
GLOBAL = str(CONFIG_DIR / Path(GLOBAL_FILE))
DEVICE_FILE = 'device.yml'
DEVICE = str(CONFIG_DIR / Path(DEVICE_FILE))
CAPS = str(PROJECT_DIR/Path('capabilities.yml'))
TEST_CASE_FILE = ''
TEST_CASE = str(PROJECT_DIR / Path(TEST_CASE_FILE))
DATA_FILE = ''
DATA = str(PROJECT_DIR / Path(DATA_FILE))
# 日志
LOGGER = 'pyauto'
LOG_LEVEL = 'DEBUG'
LOG_PATH = str(LOG_DIR / Path('app.log'))
DEVICE_LOG = str(PROJECT_DIR / Path('result/logs/{0}.log'))
ERROR_LOG = str(PROJECT_DIR / Path('result/logs/error.log'))
DEVICE_ERROR_LOG = str(PROJECT_DIR / Path('result/logs/{0}_error.log'))
# Appium
WIN_PREFIX = os.getenv("Appdata")[:-8] if os.getenv("Appdata") else ""
APPIUM_WIN = [
WIN_PREFIX + "/Local/Programs/Appium/resources/app/node_modules/appium/build/lib/main.js",
WIN_PREFIX + "/Local/Programs/appium-desktop/resources/app/node_modules/appium/build/lib/main.js",
"C:/\"Program Files (x86)\"/Appium/resources/app/node_modules/appium/build/lib/main.js",
"C:/\"Program Files\"/Appium/resources/app/node_modules/appium/build/lib/main.js",
# str(subprocess.getoutput('npm root -g')) + "/appium/build/lib/main.js",
# str(subprocess.getoutput('npm root')) + "/appium/build/lib/main.js",
]
APPIUM_MAC = [
"/Applications/Appium.app/Contents/Resources/app/node_modules/appium/build/lib/main.js",
# str(subprocess.getoutput('npm root -g')) + "/appium/build/lib/main.js",
# str(subprocess.getoutput('npm root')) + "/appium/build/lib/main.js",
]
APPIUM_LINUX = [
str(subprocess.getoutput('npm root -g')) + "/appium/build/lib/main.js",
str(subprocess.getoutput('npm root')) + "/appium/build/lib/main.js",
]