mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
improve serial hotplug (#389)
* - disable device when error indecates that the problem is not solvable on reconnect
- introduce a preOpenDelay of 2 seconds (currently value is hardcoded)
* rs232:
- make preOpenDelay available via webui
- fix preOpenDelay
- add basic usb serial detection
* - revert 3819ae7
- fix schema files
* make json checks compat with utf8+bom
* make shutdown effect a bit more flexible
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
import simplejson, sys, glob
|
||||
import json, sys, glob
|
||||
from os import path
|
||||
from jsonschema import Draft3Validator
|
||||
|
||||
@@ -12,14 +12,14 @@ retval = 0
|
||||
total = 0
|
||||
errors = 0
|
||||
with open("libsrc/effectengine/EffectDefinition.schema.json") as baseSchemaFile:
|
||||
baseSchema = simplejson.load(baseSchemaFile)
|
||||
baseSchema = json.loads(baseSchemaFile.read().decode('utf-8-sig'))
|
||||
baseValidator = Draft3Validator(baseSchema)
|
||||
for filename in glob.glob(jsonFiles+'/*.json'):
|
||||
with open(filename) as f:
|
||||
total += 1
|
||||
msg = " check effect %s ... " % filename
|
||||
try:
|
||||
effect = simplejson.load(f)
|
||||
effect = json.loads(f.read().decode('utf-8-sig'))
|
||||
script = path.basename(effect['script'])
|
||||
if not path.exists(jsonFiles+'/'+script):
|
||||
raise ValueError('script file: '+script+' not found.')
|
||||
@@ -31,7 +31,7 @@ with open("libsrc/effectengine/EffectDefinition.schema.json") as baseSchemaFile:
|
||||
|
||||
# validate against schema
|
||||
with open(schema) as s:
|
||||
effectSchema = simplejson.load(s)
|
||||
effectSchema = json.loads(s.read().decode('utf-8-sig'))
|
||||
Draft3Validator.check_schema(effectSchema)
|
||||
validator = Draft3Validator(effectSchema)
|
||||
baseValidator.validate(effect)
|
||||
|
@@ -11,10 +11,10 @@ for filename in sys.argv[1:]:
|
||||
total += 1
|
||||
msg = " check json %s ... " % filename
|
||||
try:
|
||||
json.load(f)
|
||||
json.loads(f.read().decode('utf-8-sig'))
|
||||
#print(msg + "ok")
|
||||
except ValueError as e:
|
||||
print(msg + 'invalid')
|
||||
print(msg + 'invalid ('+str(e)+')')
|
||||
retval = 1
|
||||
errors += 1
|
||||
|
||||
|
@@ -11,10 +11,10 @@ schemaFileName = sys.argv[2]
|
||||
try:
|
||||
with open(schemaFileName) as schemaFile:
|
||||
with open(jsonFileName) as jsonFile:
|
||||
j = json.load(jsonFile)
|
||||
validator = Draft3Validator(json.load(schemaFile))
|
||||
j = json.loads(jsonFile.read().decode('utf-8-sig'))
|
||||
validator = Draft3Validator(json.loads(schemaFile.read().decode('utf-8-sig')))
|
||||
validator.validate(j)
|
||||
except Exception as e:
|
||||
except Exception as e:
|
||||
print('validation error: '+jsonFileName + ' '+schemaFileName+' ('+str(e)+')')
|
||||
sys.exit(1)
|
||||
|
||||
|
Reference in New Issue
Block a user