-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #305 from Bristol-Braille/304-add-configuration
Add additional configuration for use on the canute console
- Loading branch information
Showing
11 changed files
with
183 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,39 @@ | ||
[files] | ||
# relative path to where log is kept | ||
log_file = canute.log | ||
# book directory | ||
log_file = 'canute.log' | ||
|
||
# where usb sticks and sd-cards will be automounted | ||
media_dir = /media | ||
# the exact sub mount-point directory name of the sd-card | ||
sd_card_dir = sd-card | ||
|
||
# Additional books made available on the USB ports will (for now at | ||
# least) be visible in the library. The current state will be written | ||
# to all mount points that are active, however the state file on the | ||
# SD card will take precedence, followed by lib_1 and finally lib_2. | ||
# These behaviours may change at any time so shouldn't be relied upon. | ||
# | ||
# These paths are relative to media_dir. | ||
# These config values are optional. | ||
additional_lib_1 = front-usb | ||
additional_lib_2 = back-usb | ||
media_dir = '/media' | ||
|
||
# Book Directories | ||
# Additional books made available on the USB ports will be made visible | ||
# in the library. The current state will be written to all mount points | ||
# that are active. The first state file found (based on the order in the | ||
# list) will take precedence if they differ. | ||
# These paths can be relative to media_dir or absolute. The mountpoint | ||
# flag should be used if they point to mountpoints that may not be present | ||
# and the swappable flag means USB media that is interchangeable. | ||
library = [ | ||
{ name = 'SD', path = 'sd-card', mountpoint = true }, | ||
{ name = 'USB1', path = 'front-usb', mountpoint = true, swappable = true }, | ||
{ name = 'USB2', path = 'back-usb', mountpoint = true, swappable = true } | ||
] | ||
|
||
# if required, a program to look for changes to removable media | ||
media_helper = './media.py' | ||
|
||
[comms] | ||
# serial timeout in seconds | ||
timeout = 1000 | ||
|
||
[hardware] | ||
# count row actuations (motor wear) when running on Canute 360 | ||
log_duty = true | ||
|
||
# minumum number of samples of button down to count as a press | ||
button_debounce = 1 | ||
|
||
# shutdown mode | ||
shutdown_on_exit = true | ||
|
||
# versions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import os.path | ||
from configparser import ConfigParser | ||
|
||
config_file = 'config.rc' | ||
import toml | ||
|
||
config_file = 'config.rc' | ||
|
||
def load(config_file=config_file): | ||
config = ConfigParser() | ||
c = config.read(config_file) | ||
if len(c) == 0: | ||
if not os.path.exists(config_file): | ||
raise ValueError('Please provide a config.rc') | ||
media_dir = config.get('files', 'media_dir') | ||
config.set('files', 'media_dir', os.path.expanduser(media_dir)) | ||
if not config.has_section('comms'): | ||
config.add_section('comms') | ||
if not config.has_option('comms', 'timeout'): | ||
config.set('comms', 'timeout', 60) | ||
|
||
config = toml.load(config_file) | ||
|
||
# expand any ~ home dirs in media_dir | ||
files_section = config.get('files', {}) | ||
media_dir = files_section.get('media_dir', '/media') | ||
files_section['media_dir'] = os.path.expanduser(media_dir) | ||
|
||
return config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.