mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2026-01-29 00:51:53 +08:00
Merge remote-tracking branch 'upstream/master'
This commit is contained in:
57
testenv/linters/eslintrc.js
Normal file
57
testenv/linters/eslintrc.js
Normal file
@@ -0,0 +1,57 @@
|
||||
const js = require("/usr/lib/node_modules/eslint/node_modules/@eslint/js/src/index.js");
|
||||
const globals = require("/usr/lib/node_modules/eslint/node_modules/@eslint/eslintrc/node_modules/globals/index.js");
|
||||
const parser = require("/usr/lib/node_modules/@babel/eslint-parser/lib/index.cjs");
|
||||
|
||||
module.exports = [
|
||||
js.configs.recommended,
|
||||
|
||||
{
|
||||
files: ["**/*.js"],
|
||||
languageOptions: {
|
||||
globals: globals.browser,
|
||||
ecmaVersion: 2015,
|
||||
parser: parser,
|
||||
parserOptions: {
|
||||
ecmaVersion: 2025,
|
||||
sourceType: "module",
|
||||
allowImportExportEverywhere: true,
|
||||
requireConfigFile: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
rules: {
|
||||
indent: [
|
||||
"error",
|
||||
"tab",
|
||||
{SwitchCase: 1},
|
||||
],
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix",
|
||||
],
|
||||
quotes: [
|
||||
"error",
|
||||
"double",
|
||||
],
|
||||
"quote-props": [
|
||||
"error",
|
||||
"always",
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always",
|
||||
],
|
||||
"comma-dangle": [
|
||||
"error",
|
||||
"always-multiline",
|
||||
],
|
||||
"no-unused-vars": [
|
||||
"error",
|
||||
{vars: "local", args: "after-used"},
|
||||
],
|
||||
},
|
||||
},
|
||||
|
||||
];
|
||||
@@ -1,36 +0,0 @@
|
||||
env:
|
||||
browser: true
|
||||
es6: true
|
||||
|
||||
extends: "eslint:recommended"
|
||||
|
||||
parser: "/usr/lib/node_modules/@babel/eslint-parser"
|
||||
parserOptions:
|
||||
ecmaVersion: 6
|
||||
sourceType: module
|
||||
allowImportExportEverywhere: true
|
||||
requireConfigFile: false
|
||||
|
||||
rules:
|
||||
indent:
|
||||
- error
|
||||
- tab
|
||||
- SwitchCase: 1
|
||||
linebreak-style:
|
||||
- error
|
||||
- unix
|
||||
quotes:
|
||||
- error
|
||||
- double
|
||||
quote-props:
|
||||
- error
|
||||
- always
|
||||
semi:
|
||||
- error
|
||||
- always
|
||||
comma-dangle:
|
||||
- error
|
||||
- always-multiline
|
||||
no-unused-vars:
|
||||
- error
|
||||
- {vars: local, args: after-used}
|
||||
@@ -1,8 +1,9 @@
|
||||
[flake8]
|
||||
inline-quotes = double
|
||||
max-line-length = 160
|
||||
ignore = W503, E227, E241, E252, Q003
|
||||
ignore = W503, E221, E227, E241, E252, Q003
|
||||
# W503 line break before binary operator
|
||||
# E221 multiple spaces before operator
|
||||
# E227 missing whitespace around bitwise or shift operator
|
||||
# E241 multiple spaces after
|
||||
# E252 missing whitespace around parameter equals
|
||||
|
||||
@@ -38,6 +38,7 @@ disable =
|
||||
unspecified-encoding,
|
||||
consider-using-f-string,
|
||||
unnecessary-lambda-assignment,
|
||||
too-many-positional-arguments,
|
||||
# https://github.com/PyCQA/pylint/issues/3882
|
||||
|
||||
[CLASSES]
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
python-periphery
|
||||
pyserial-asyncio
|
||||
pyghmi
|
||||
spidev
|
||||
pyrad
|
||||
types-PyYAML
|
||||
types-aiofiles
|
||||
luma.oled
|
||||
|
||||
@@ -32,10 +32,10 @@ from . import get_configured_auth_service
|
||||
|
||||
|
||||
# =====
|
||||
async def _handle_auth(request: aiohttp.web.BaseRequest) -> aiohttp.web.Response:
|
||||
async def _handle_auth(req: aiohttp.web.BaseRequest) -> aiohttp.web.Response:
|
||||
status = 400
|
||||
if request.method == "POST":
|
||||
credentials = (await request.json())
|
||||
if req.method == "POST":
|
||||
credentials = (await req.json())
|
||||
if credentials["user"] == "admin" and credentials["passwd"] == "pass":
|
||||
status = 200
|
||||
return aiohttp.web.Response(text=str(status), status=status)
|
||||
|
||||
@@ -40,14 +40,14 @@ async def test_ok__region__access_one() -> None:
|
||||
|
||||
async def func() -> None:
|
||||
assert not region.is_busy()
|
||||
async with region:
|
||||
with region:
|
||||
assert region.is_busy()
|
||||
assert not region.is_busy()
|
||||
|
||||
await func()
|
||||
|
||||
assert not region.is_busy()
|
||||
await region.exit()
|
||||
region.exit()
|
||||
assert not region.is_busy()
|
||||
|
||||
|
||||
@@ -57,16 +57,16 @@ async def test_fail__region__access_one() -> None:
|
||||
|
||||
async def func() -> None:
|
||||
assert not region.is_busy()
|
||||
async with region:
|
||||
with region:
|
||||
assert region.is_busy()
|
||||
await region.enter()
|
||||
region.enter()
|
||||
assert not region.is_busy()
|
||||
|
||||
with pytest.raises(RegionIsBusyError):
|
||||
await func()
|
||||
|
||||
assert not region.is_busy()
|
||||
await region.exit()
|
||||
region.exit()
|
||||
assert not region.is_busy()
|
||||
|
||||
|
||||
@@ -76,21 +76,21 @@ async def test_ok__region__access_two() -> None:
|
||||
region = AioExclusiveRegion(RegionIsBusyError)
|
||||
|
||||
async def func1() -> None:
|
||||
async with region:
|
||||
with region:
|
||||
await asyncio.sleep(1)
|
||||
print("done func1()")
|
||||
|
||||
async def func2() -> None:
|
||||
await asyncio.sleep(2)
|
||||
print("waiking up func2()")
|
||||
async with region:
|
||||
with region:
|
||||
await asyncio.sleep(1)
|
||||
print("done func2()")
|
||||
|
||||
await asyncio.gather(func1(), func2())
|
||||
|
||||
assert not region.is_busy()
|
||||
await region.exit()
|
||||
region.exit()
|
||||
assert not region.is_busy()
|
||||
|
||||
|
||||
@@ -99,13 +99,13 @@ async def test_fail__region__access_two() -> None:
|
||||
region = AioExclusiveRegion(RegionIsBusyError)
|
||||
|
||||
async def func1() -> None:
|
||||
async with region:
|
||||
with region:
|
||||
await asyncio.sleep(2)
|
||||
print("done func1()")
|
||||
|
||||
async def func2() -> None:
|
||||
await asyncio.sleep(1)
|
||||
async with region:
|
||||
with region:
|
||||
await asyncio.sleep(1)
|
||||
print("done func2()")
|
||||
|
||||
@@ -114,7 +114,7 @@ async def test_fail__region__access_two() -> None:
|
||||
assert type(results[1]) is RegionIsBusyError # pylint: disable=unidiomatic-typecheck
|
||||
|
||||
assert not region.is_busy()
|
||||
await region.exit()
|
||||
region.exit()
|
||||
assert not region.is_busy()
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
[tox]
|
||||
envlist = flake8, pylint, mypy, vulture, pytest, htmlhint, shellcheck
|
||||
#envlist = flake8, pylint, mypy, vulture, pytest, eslint, htmlhint, shellcheck
|
||||
envlist = flake8, pylint, mypy, vulture, pytest, eslint, htmlhint, shellcheck
|
||||
skipsdist = true
|
||||
|
||||
[testenv]
|
||||
@@ -55,7 +54,7 @@ deps =
|
||||
|
||||
[testenv:eslint]
|
||||
allowlist_externals = eslint
|
||||
commands = eslint --cache-location=/tmp --config=testenv/linters/eslintrc.yaml --color --ext .js web/share/js
|
||||
commands = eslint --cache-location=/tmp --config=testenv/linters/eslintrc.js --color web/share/js
|
||||
|
||||
[testenv:htmlhint]
|
||||
allowlist_externals = htmlhint
|
||||
|
||||
Reference in New Issue
Block a user