feat: add standalone capability-based cooling plugin
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
"""Explicit one-time migration; runtime never reads the monitor configuration."""
|
||||
import argparse
|
||||
import configparser
|
||||
from pathlib import Path
|
||||
from settings import SCHEMA,load,validated,check,save
|
||||
|
||||
|
||||
def migrate(source):
|
||||
c=configparser.ConfigParser()
|
||||
if not c.read(source):raise ValueError('monitor config missing')
|
||||
result={s:{k:v['default'] for k,v in spec.items()} for s,spec in SCHEMA.items()}
|
||||
for section,old in (('fan','fan'),('rgb','led')):
|
||||
if c.has_section(old):
|
||||
values={k:v for k,v in c.items(old) if k in SCHEMA[section]}
|
||||
result[section].update(validated({section:values})[section])
|
||||
for old,key in (('oled_refresh_interval','refresh_seconds'),('page_interval','page_seconds')):
|
||||
if c.has_option('timing',old):result['oled'].update(validated({'oled':{key:c.get('timing',old)}})['oled'])
|
||||
check(result)
|
||||
return result
|
||||
|
||||
if __name__=='__main__':
|
||||
p=argparse.ArgumentParser();p.add_argument('source');p.add_argument('--check',action='store_true');p.add_argument('--output');a=p.parse_args()
|
||||
result=migrate(a.source)
|
||||
if a.output:save(a.output,result)
|
||||
else:print('migration valid; no files changed')
|
||||
Reference in New Issue
Block a user