-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
JSON config support, improved logging
- Loading branch information
cceremuga
committed
Apr 18, 2017
1 parent
166c408
commit 84e2c72
Showing
6 changed files
with
80 additions
and
35 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
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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"radio": { | ||
"frequency": "144390000", | ||
"gain": "49.6" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import json | ||
|
||
class Configuration: | ||
CONFIG_FILE_NAME = 'config/configuration.json' | ||
|
||
def __init__(self): | ||
self.data = {} | ||
self.load() | ||
self.validate() | ||
|
||
def load(self): | ||
with open(self.CONFIG_FILE_NAME) as json_data_file: | ||
self.data = json.load(json_data_file) | ||
|
||
def frequency(self): | ||
return self.data['radio']['frequency'] | ||
|
||
def gain(self): | ||
return self.data['radio']['gain'] | ||
|
||
def validate(self): | ||
pass | ||
# TODO: Validate configuration. |
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