Skip to content

Commit be018bd

Browse files
author
jax
committed
init Linux FactoryTest tools
0 parents  commit be018bd

12 files changed

Lines changed: 912 additions & 0 deletions

File tree

.gitignore

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Created by .ignore support plugin (hsz.mobi)
2+
### Python template
3+
# Byte-compiled / optimized / DLL files
4+
__pycache__/
5+
*.py[cod]
6+
*$py.class
7+
8+
# C extensions
9+
*.so
10+
11+
# Distribution / packaging
12+
.Python
13+
build/
14+
develop-eggs/
15+
dist/
16+
downloads/
17+
eggs/
18+
.eggs/
19+
lib/
20+
lib64/
21+
parts/
22+
sdist/
23+
var/
24+
wheels/
25+
share/python-wheels/
26+
*.egg-info/
27+
.installed.cfg
28+
*.egg
29+
MANIFEST
30+
31+
# PyInstaller
32+
# Usually these files are written by a python script from a template
33+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
34+
*.manifest
35+
*.spec
36+
37+
# Installer logs
38+
pip-log.txt
39+
pip-delete-this-directory.txt
40+
41+
# Unit test / coverage reports
42+
htmlcov/
43+
.tox/
44+
.nox/
45+
.coverage
46+
.coverage.*
47+
.cache
48+
nosetests.xml
49+
coverage.xml
50+
*.cover
51+
*.py,cover
52+
.hypothesis/
53+
.pytest_cache/
54+
cover/
55+
56+
# Translations
57+
*.mo
58+
*.pot
59+
60+
# Django stuff:
61+
*.log
62+
local_settings.py
63+
db.sqlite3
64+
db.sqlite3-journal
65+
66+
# Flask stuff:
67+
instance/
68+
.webassets-cache
69+
70+
# Scrapy stuff:
71+
.scrapy
72+
73+
# Sphinx documentation
74+
docs/_build/
75+
76+
# PyBuilder
77+
.pybuilder/
78+
target/
79+
80+
# Jupyter Notebook
81+
.ipynb_checkpoints
82+
83+
# IPython
84+
profile_default/
85+
ipython_config.py
86+
87+
# pyenv
88+
# For a library or package, you might want to ignore these files since the code is
89+
# intended to run in multiple environments; otherwise, check them in:
90+
# .python-version
91+
92+
# pipenv
93+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
94+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
95+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
96+
# install all needed dependencies.
97+
#Pipfile.lock
98+
99+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
100+
__pypackages__/
101+
102+
# Celery stuff
103+
celerybeat-schedule
104+
celerybeat.pid
105+
106+
# SageMath parsed files
107+
*.sage.py
108+
109+
# Environments
110+
.env
111+
.venv
112+
env/
113+
venv/
114+
ENV/
115+
env.bak/
116+
venv.bak/
117+
118+
# Spyder project settings
119+
.spyderproject
120+
.spyproject
121+
122+
# Rope project settings
123+
.ropeproject
124+
125+
# mkdocs documentation
126+
/site
127+
128+
# mypy
129+
.mypy_cache/
130+
.dmypy.json
131+
dmypy.json
132+
133+
# Pyre type checker
134+
.pyre/
135+
136+
# pytype static type analyzer
137+
.pytype/
138+
139+
# Cython debug symbols
140+
cython_debug/
141+

ConfigOptions.py

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# -*- coding: utf-8 -*-
2+
# !/usr/bin/env python
3+
import configparser
4+
import os
5+
from datetime import datetime
6+
7+
from constant import const
8+
9+
10+
class ConfigOptions:
11+
"""
12+
配置选项
13+
"""
14+
15+
def __init__(self):
16+
self.config_file_path = '/tmp/config.ini'
17+
self.log_file_path = '/tmp/{}_log.txt'.format(datetime.now().strftime("%Y%m%d%H%M%S"))
18+
self.config = configparser.ConfigParser()
19+
20+
self._init_config()
21+
22+
def _init_config(self):
23+
"""
24+
初始化配置文件
25+
"""
26+
if not os.path.exists(self.config_file_path):
27+
self.config[const.TEST_CASE_PATH] = {
28+
const.RTC: '/dev/rtc1',
29+
const.RELAY54: '54',
30+
const.RELAY55: '55',
31+
const.LED_R: '32',
32+
const.LED_G: '33',
33+
const.LED_B: '45',
34+
const.VL53L1X: '/dev/vl53l1x-dev',
35+
const.XM132: '/dev/xm132-dev',
36+
const.MAX44009: '/sys/bus/iio/devices/iio:device2/in_illuminance_input',
37+
const.HUMIDITY: '/sys/bus/iio/devices/iio:device1/in_humidityrelative_input',
38+
const.TEMPERATURE: '/sys/bus/iio/devices/iio:device*/in_temp_input',
39+
const.PRESSURE: '/sys/bus/iio/devices/iio:device*/in_pressure_input',
40+
}
41+
self.config[const.TEST_CASE] = {
42+
const.WIFI_BT: '1',
43+
const.RTC: '1',
44+
const.RELAY: '1',
45+
const.SOUND: '1',
46+
const.NFC: '1',
47+
const.CAMERA: '1',
48+
const.RGB: '1',
49+
const.SENSOR: '1',
50+
const.AUTO_TEST: '0',
51+
}
52+
self.config[const.TEST_CASE_LIST] = {
53+
const.TEST_CASE_LIST: ' '.join([
54+
const.WIFI_BT,
55+
const.RTC,
56+
const.RELAY,
57+
const.SOUND,
58+
const.NFC,
59+
const.CAMERA,
60+
const.RGB,
61+
const.SENSOR,
62+
const.AUTO_TEST])
63+
}
64+
self.save_config()
65+
else:
66+
with open(self.config_file_path, 'r', encoding='utf-8') as f:
67+
self.config.read_file(f)
68+
69+
def save_config(self):
70+
with open(self.config_file_path, 'w', encoding='utf-8') as f:
71+
self.config.write(f)
72+
73+
def save_log(self, message):
74+
"""
75+
将测试结果写入到文件中
76+
"""
77+
with open(self.log_file_path, 'a', encoding='utf-8') as f:
78+
f.write(message)

0 commit comments

Comments
 (0)