-
Notifications
You must be signed in to change notification settings - Fork 15
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 #202 from NTIA/preselector
Preselector
- Loading branch information
Showing
50 changed files
with
1,526 additions
and
1,219 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 |
---|---|---|
@@ -0,0 +1 @@ | ||
{} |
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
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,48 +0,0 @@ | ||
import copy | ||
|
||
from sensor import settings | ||
from sensor.settings import SENSOR_DEFINITION_FILE | ||
|
||
|
||
def load_from_json(fname): | ||
import json | ||
import logging | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
try: | ||
with open(fname) as f: | ||
return json.load(f) | ||
except Exception: | ||
logger.exception("Unable to load JSON file {}".format(fname)) | ||
|
||
|
||
def get_sigmf_location(): | ||
from status.models import Location | ||
|
||
try: | ||
db_location = Location.objects.get(active=True) | ||
return { | ||
"x": db_location.longitude, | ||
"y": db_location.latitude, | ||
"z": db_location.height, | ||
"description": db_location.description, | ||
} | ||
except Location.DoesNotExist: | ||
return None | ||
|
||
|
||
_capabilities = {} | ||
_capabilities["sensor"] = load_from_json(SENSOR_DEFINITION_FILE) | ||
_capabilities["sensor"]["id"] = settings.FQDN | ||
|
||
|
||
def get_capabilities(): | ||
capabilities = copy.deepcopy(_capabilities) | ||
location = get_sigmf_location() | ||
if location: | ||
capabilities["sensor"]["location"] = location | ||
else: | ||
if "location" in capabilities['sensor']: | ||
del capabilities["sensor"]["location"] | ||
return capabilities | ||
Oops, something went wrong.