forked from labgrid-project/labgrid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This class also parses the new tools and images sections (with relative path support). Also rename the remaining .env files .yaml. Signed-off-by: Jan Luebbe <[email protected]>
- Loading branch information
Showing
15 changed files
with
141 additions
and
106 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,12 @@ | ||
targets: | ||
main: | ||
resources: | ||
USBSerialPort: | ||
match: | ||
ID_SERIAL_SHORT: 'P-00-01084' | ||
drivers: | ||
ManualPowerDriver: | ||
name: "example" | ||
SerialDriver: {} | ||
BareboxDriver: | ||
prompt: 'barebox@[^:]+:[^ ]+ ' |
This file was deleted.
Oops, something went wrong.
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,11 @@ | ||
targets: | ||
main: | ||
resources: | ||
RawSerialPort: | ||
port: "/dev/ttyUSB0" | ||
drivers: | ||
ManualPowerDriver: | ||
name: "example" | ||
SerialDriver: {} | ||
BareboxDriver: | ||
prompt: 'barebox@[^:]+:[^ ]+ ' |
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,6 +1,7 @@ | ||
main: | ||
resources: | ||
RawSerialPort: { 'port': '/dev/ttyUSB0' } | ||
drivers: | ||
SerialDriver: { } | ||
ShellDriver: { 'prompt': 'root@DistroKit:~ ', 'login_prompt': 'DistroKit login: ', 'username': 'root', 'keyfile': 'riot.pub'} | ||
targets: | ||
main: | ||
resources: | ||
RawSerialPort: { 'port': '/dev/ttyUSB0' } | ||
drivers: | ||
SerialDriver: { } | ||
ShellDriver: { 'prompt': 'root@DistroKit:~ ', 'login_prompt': 'DistroKit login: ', 'username': 'root', 'keyfile': 'riot.pub'} |
This file was deleted.
Oops, something went wrong.
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,13 @@ | ||
targets: | ||
main: | ||
resources: | ||
RawSerialPort: | ||
port: "/dev/ttyUSB0" | ||
drivers: | ||
ManualPowerDriver: | ||
name: "example" | ||
SerialDriver: {} | ||
ShellDriver: | ||
prompt: 'root@\w+:[^ ]+ ' | ||
login_prompt: ' login: ' | ||
username: 'root' |
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
targets: | ||
main: | ||
resources: | ||
RawSerialPort: | ||
port: "/dev/ttyUSB0" | ||
drivers: | ||
ManualPowerDriver: | ||
name: "example" | ||
SerialDriver: {} | ||
BareboxDriver: | ||
prompt: 'barebox@[^:]+:[^ ]+ ' | ||
ShellDriver: | ||
prompt: 'root@\w+:[^ ]+ ' | ||
login_prompt: ' login: ' | ||
username: 'root' | ||
BareboxStrategy: {} |
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,16 +1,17 @@ | ||
main: | ||
resources: | ||
RawSerialPort: | ||
port: '/dev/ttyUSB0' | ||
NetworkService: | ||
address: '192.168.24.75' | ||
username: 'root' | ||
drivers: | ||
SerialDriver: {} | ||
ShellDriver: | ||
prompt: 'root@DistroKit:~ ' | ||
login_prompt: 'DistroKit login: ' | ||
username: 'root' | ||
keyfile: 'riot.pub' | ||
SSHDriver: | ||
keyfile: 'riot' | ||
targets: | ||
main: | ||
resources: | ||
RawSerialPort: | ||
port: '/dev/ttyUSB0' | ||
NetworkService: | ||
address: '192.168.24.75' | ||
username: 'root' | ||
drivers: | ||
SerialDriver: {} | ||
ShellDriver: | ||
prompt: 'root@DistroKit:~ ' | ||
login_prompt: 'DistroKit login: ' | ||
username: 'root' | ||
keyfile: 'riot.pub' | ||
SSHDriver: | ||
keyfile: 'riot' |
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,27 +1,58 @@ | ||
from collections import OrderedDict | ||
|
||
import yaml | ||
|
||
|
||
def _dict_representer(dumper, data): | ||
return dumper.represent_dict(data.items()) | ||
import attr | ||
import os | ||
|
||
|
||
def _dict_constructor(loader, node): | ||
return OrderedDict(loader.construct_pairs(node)) | ||
|
||
|
||
yaml.add_representer(OrderedDict, _dict_representer) | ||
yaml.add_constructor( | ||
yaml.SafeLoader.add_constructor( | ||
yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, _dict_constructor | ||
) | ||
|
||
|
||
def load_config(filename): | ||
try: | ||
with open(filename) as file: | ||
return yaml.load(file) | ||
except FileNotFoundError: | ||
raise NoConfigFoundError( | ||
"{} could not be found".format(self.config_file) | ||
) | ||
@attr.s | ||
class Config: | ||
filename = attr.ib(validator=attr.validators.instance_of(str)) | ||
|
||
def __attrs_post_init__(self): | ||
self.base = os.path.dirname(self.filename) | ||
try: | ||
with open(self.filename) as file: | ||
self.data = yaml.load(file, yaml.SafeLoader) | ||
except FileNotFoundError: | ||
raise NoConfigFoundError( | ||
"{} could not be found".format(self.filename) | ||
) | ||
|
||
def resolve_path(self, path): | ||
if os.path.isabs(path): | ||
return path | ||
else: | ||
return os.path.join(self.base, path) | ||
|
||
def get_tool(self, tool): | ||
try: | ||
path = str(self.data['tools'][tool]) | ||
return self.resolve_path(path) | ||
except KeyError: | ||
return None | ||
|
||
def get_image_path(self, kind): | ||
try: | ||
path = str(self.data['images'][kind]) | ||
return self.resolve_path(path) | ||
except KeyError: | ||
logging.exception("no path configured for image {}".format(kind)) | ||
raise | ||
|
||
def get_option(self, name): | ||
try: | ||
return str(self.data['options'][name]) | ||
except KeyError: | ||
logging.exception("no such option {}".format(name)) | ||
raise | ||
|
||
def get_targets(self): | ||
return self.data.get('targets', {}) |
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