add config default files
This commit is contained in:
parent
1a2c82da33
commit
232ead8d4b
16
config.py
16
config.py
|
@ -2,9 +2,11 @@
|
|||
Presents an interface for yaml files as a dict-like object
|
||||
'''
|
||||
|
||||
import yaml
|
||||
import yaml, shutil, logging
|
||||
from threading import Lock
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class _ReadOnlyFile():
|
||||
'''
|
||||
Opens a yaml file for reading. Intended for config files.
|
||||
|
@ -33,5 +35,13 @@ class _ReadWriteFile(_ReadOnlyFile):
|
|||
with open(self._path, 'w') as f:
|
||||
yaml.dump(self._dict, f, default_flow_style=False)
|
||||
|
||||
configFile = _ReadOnlyFile('config/pyledriver.yaml')
|
||||
stateFile = _ReadWriteFile('config/state.yaml')
|
||||
def _openFile(cls, path):
|
||||
try:
|
||||
return cls(path)
|
||||
except:
|
||||
logger.warn('File %s not found. Copying example', path)
|
||||
shutil.copy(path + '.default', path)
|
||||
return cls(path)
|
||||
|
||||
configFile = _openFile(_ReadOnlyFile, 'config/pyledriver.yaml')
|
||||
stateFile = _openFile(_ReadWriteFile, 'config/state.yaml')
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
gmail:
|
||||
passwd: bwsasfxqjbookmed
|
||||
recipientList:
|
||||
- natedwarshuis@gmail.com
|
||||
username: natedwarshuis@gmail.com
|
|
@ -0,0 +1 @@
|
|||
state: disarmed
|
Loading…
Reference in New Issue