Commit graph

217 commits

Author SHA1 Message Date
546aeb83f6
reformat as poetry project 2023-08-31 22:15:04 -05:00
sparky8512
5cbc5b73dd Add configuration of sleep mode settings
Add ability to show, set, or disable the power save (sleep) configuration in the dish_control.py script and similar function in the core module.
2023-02-02 13:43:25 -08:00
sparky8512
955e2e0b5d Document recently added alerts 2023-02-02 08:55:41 -08:00
sparky8512
237cc349cf
Merge pull request #75 from sparky8512/protocol-robustness
Robustness against field removal in gRPC protocol

for issue #66
2023-02-02 08:49:34 -08:00
sparky8512
a8717d9549 Protect other usage vs grpc protocol changes
Change all uses of protobuf messages other than status and history data so that they will not crash the calling script in the case where the grpc protocol removes the message or field being accessed. Instead, they will return None for the affected field (which most calling scripts interpret as "no data") or raise the same error as when the dish is not reachable.

This is for issue #66.
2023-02-01 14:45:37 -08:00
sparky8512
2eebbfc366 Protect one more case of history usage 2023-02-01 14:26:24 -08:00
sparky8512
ab2bce59ca Protect history usage vs grpc protocol changes
Change all uses of history data protobuf messages so that they will not crash the calling script in the case where the grpc protocol removes the message or field being accessed. Instead, they will return None for the affected field (which most calling scripts interpret as "no data") or raise the same error as when the dish is not reachable.

Same caveats about code readability and adherence to the advertised type data as the change for protecting status usage.

This is for issue #66.
2023-02-01 14:19:17 -08:00
sparky8512
8b1d81b2bb Protect status usage vs grpc protocol changes
Change all uses of status data protobuf messages so that they will not crash the calling script in the case where the grpc protocol removes the message, field, or enum value being accessed. Instead, they will return None for the affected field (which most calling scripts interpret as "no data") or raise the same error as when the dish is not reachable.

This makes the code a little less readable, but it's better than breaking every time the protocol obsoletes fields.

mypy now complains about the return types for some fields that are now technically optional but are not marked as such in the type data, because the type data reflects what will currently be returned, not what may turn to None in the future if the protocol changes.

This is for issue #66.
2023-02-01 10:56:41 -08:00
sparky8512
0298ce2106 Remove a bunch of junk from the Docker image
Now, only the main Python scripts are copied into the Docker image, so none of the testing/example stuff or the auxiliary files that aren't relevant to running the Docker image.

This should address issue #74 by removing the script that would have required extra bits to run.
2022-12-28 09:33:03 -08:00
sparky8512
ad36e08451 Make Docker image work for 32-bit ARMv7
This should allow for a working image if built manually, but does not add it to the multi-arch package built for this project's package repository.

As discussed in issue #72, needed to work around some shared library issue between the binary wheel for one of the prerequisites published to PyPI and the base Docker image.
2022-12-24 09:19:39 -08:00
sparky8512
8cbab00517
Note the Docker image as multi-arch 2022-12-21 10:41:17 -08:00
sparky8512
b0e89990c6 Run through yapf 2022-12-21 10:32:56 -08:00
sparky8512
dc4ff85dbe A few tweaks to the Prometheus exporter script
Move the global state onto the http server object so it doesn't have to be accessed as module globals.

Limit the mode groups that can be selected via command line args to the ones that are actually parsed. There are a few other options added in dish_common that don't really apply to this script, but they are mostly harmless, whereas some of the other mode groups will cause this script to throw an exception.

Reject access to "/favicon.ico" path, so testing from a web browser does not result in running the dish queries twice, and thus confusing the global state a little.

Add a lock to serialize calls to dish_common.get_data. That function is not thread-safe, even with CPython's Global Interpreter Lock, because the starlink_grpc functions it calls block. This script is really not meant for concurrent HTTP access, given that the usage stats are reported as usage since last access (by default), but since it's technically supported, might as well have it work properly.

Add the same handling of keyboard interrupt (Ctrl-C) and SIGTERM signal as the other grpc scripts, along with proper shutdown.
2022-12-21 10:25:57 -08:00
sparky8512
ab9c26e517 Make dish_obstruction_map work in Docker image
As noted in issue #72, pypng was missing from the list of pip packages installed for the Docker image, which is required for dish_obstruction_map.

Without extraneous changes this time....
2022-12-01 17:53:15 -08:00
sparky8512
f23cf2d756 Revert "Make dish_obstruction_map work in Docker image"
This reverts commit 1545b0fcc9.
2022-12-01 17:51:24 -08:00
sparky8512
1545b0fcc9 Make dish_obstruction_map work in Docker image
As noted in issue #72, pypng was missing from the list of pip packages installed for the Docker image, which is required for dish_obstruction_map.
2022-12-01 17:50:29 -08:00
sparky8512
c97e6ad70e
Merge pull request #73 from sparky8512/docker-arm64
Add linux/arm64 docker image generation

This should address issue #72
2022-11-19 12:18:33 -08:00
sparky8512
ffd950c30c
Merge pull request #71 from luxifr/prom-exporter
add prometheus exporter
2022-11-18 14:57:11 -08:00
luxifer
d5f04c4999 ignore status_snr as it's deprecated 2022-11-18 22:26:28 +00:00
sparky8512
09b3120540 Update Docker pip package versions to current
They're still pinned to specific versions, just the newest ones as of right now. This should avoid the need for the ARM64 build to compile any wheels that need native code.

Also, reorder how the pip packages are listed for easier maintenance.
2022-11-16 11:46:43 -08:00
sparky8512
bd4a9c4605 Switch to multi-arch Docker image packaging
Add building of ARM64 Docker image (via QEMU and buildx) and publish it to GitHub Packages Repository along with the AMD64 image as a multi-arch package.
2022-11-16 11:35:05 -08:00
luxifer
40cd0127dc add prometheus exporter 2022-11-15 16:45:24 +00:00
sparky8512
5887eb9816
Remove incorrect env option
Per discussion on issue #68, setting INFLUXDB_SSL to "false" is not useful here. This was probably copied over from the MQTT example service conf file, where it is supported (although essentially ignored).
2022-11-11 13:13:41 -08:00
sparky8512
36f7b169a0
Correct another issue in the systemd instructions
As noted in issue #67.
2022-11-10 12:58:06 -08:00
sparky8512
7c46577743
Merge pull request #70 from jbuck2005/patch-2
fix mkdir starlink-grpc-tool (missing s)
2022-11-10 11:18:11 -08:00
jbuck2005
125e918aba
fix mkdir starlink-grpc-tool (missing s)
fix missing "s" in

mkdir starlink-grpc-tool
and
cd starlink-grpc-tool

install location pointed to by https://github.com/sparky8512/starlink-grpc-tools/blob/main/systemd/starlink-influx2.service shows WorkingDirectory=/opt/starlink-grpc-tools/
2022-11-10 12:56:10 -05:00
sparky8512
000e3a4a62 Stop using a couple recently-obsoleted attributes
The dish firmware stopped reporting the wedge fraction obstructed detail a few weeks ago, and now has apparently dropped it from the grpc protocol.

The core module now reports a sequence of None values for those fields, which is represented as "no data" in most of the database outputs. Without meaningful data in these fields, the obstruction_detail mode group is mostly useless, but the obstruction map was a much better representation of that data, anyway.

This should address issue #65.
2022-11-08 15:03:21 -08:00
sparky8512
5cc43f6e1d Address a bunch of pylint and yapf complaints
I don't necessarily think all of these make the code better or easier to read, but it's easier to just go along with what the tools want, since they do generally make things better.

There should be no functional changes here.
2022-09-14 12:55:50 -07:00
sparky8512
24b8f95792
Merge pull request #64 from boswelja/typing-extensions
Introduce typing-extensions for proper TypedDict support on Python 3.7
2022-09-12 07:51:28 -07:00
Jack Boswell (boswelja)
98adc879ae Only specify unwrapped in UnwrappedHistory 2022-09-12 16:11:03 +12:00
Jack Boswell
3deb015c0d
Pin typing-extensions for Dockerfile 2022-09-12 15:35:52 +12:00
Jack Boswell
2d35afd0da
Remove rogue import 2022-09-12 15:35:26 +12:00
Jack Boswell (boswelja)
e45daca3c4 Add typing-extensions to Dockerfile 2022-09-11 16:42:40 +12:00
Jack Boswell (boswelja)
c3272cf781 Add typing-extensions for proper TypedDict support
Also updated UnwrappedHistory to expose its types
2022-09-11 13:45:39 +12:00
sparky8512
6a186b6e3b Address remaining mypy complaints
Add type hints for the variable that mypy couldn't figure out by context.

Also, one more field should have been marked as Optional[].
2022-09-10 16:19:04 -07:00
sparky8512
8650687f69 Correct CSV and sqlite support for location group
Add CSV header and sqlite schema support for the newly added location group, along with the necessary functions in the starlink_grpc module to expose the field names and types for that group. This really should have gone in with the prior change.

Also, correct the order of the ping_latency and ping_loaded_latency groups in the CSV header, which was backwards. This would have resulted in an incorrect CSV header if both those groups were selected.
2022-09-10 16:12:05 -07:00
sparky8512
29699f0f59 Add data group for GPS location data
Add a new mode group, location, for physical location data. This requires access to the location data being enabled on the dish in order to return data; see README file for more details. At least for now, this functionality should be considered experimental.

This is being lumped into the "status" category for the purposes of database schema, but it's a separate grpc request from the other status data, and can fail at times when the other status request does not, so it has a separate function in the starlink_grpc module.
2022-09-10 14:43:50 -07:00
sparky8512
29c813b51a Correct a (harmless) typo 2022-09-09 15:39:33 -07:00
sparky8512
c37dbdfaa4
One more field that should be marked optional 2022-09-09 15:23:25 -07:00
sparky8512
ab0fba7b88 Document another recently added alert 2022-09-09 11:27:57 -07:00
sparky8512
f759e4cc3b
Merge pull request #62 from sparky8512/return-type-hints-2
Type hints for status and history return values
2022-09-09 11:13:34 -07:00
sparky8512
1167742f75 Correct Python 3.7 compatibility hack
mypy complained about the signature of conditional def of get_args not matching the one from typing module, so I made it match, but apparently hadn't actually tested it with Python 3.7. It was just the return type hint, but it sill needs to parse at run time.

Also, fix up a few other (non-error) gripes from pylint.
2022-09-09 11:01:53 -07:00
sparky8512
5ff207ed8c Type hints for status and history return values
Implement type hints for the data returned from status_data, history_stats, and history_bulk_data, and modify the *_field_names and *_field_types functions to make use of the same data.

This is complicated a little by the fact that the field names returned for sequences in the returned data are slightly different from those in *_field_names, for reasons that I'm sure made perfect sense to me at the time.

Should work with static type checkers on Python 3.8 and later. Python 3.7 is still supported for the run time, but possibly in a way that static type checking will not be able to understand.

This is for issue #57
2022-09-07 13:44:54 -07:00
sparky8512
0a4aae4ffb
Merge pull request #61 from boswelja/patch-1
Add return hint for get_id
2022-09-07 07:19:01 -07:00
Jack Boswell
18ced80c25
Add return hint for get_id 2022-09-07 13:18:43 +12:00
sparky8512
feccac23ee A few doc string updates
Reword the is_snr_above_noise_floor description to be more consistent with the rest of the field docs.

Correct the order the status field groups in the docs for the functions that return them to reflect the actual order in which they are returned.
2022-08-28 09:07:24 -07:00
sparky8512
40713e1426
Merge pull request #59 from DeanCording/is_snr_above_noise_floor
Added documentation for is_snr_above_noise_floor
2022-08-27 19:03:51 -07:00
Dean Cording
aad6ad9d2b
Added documentation for is_snr_above_noise_floor 2022-08-28 11:25:15 +10:00
sparky8512
3126e921d3
Merge pull request #58 from DeanCording/is_snr_above_noise_floor
Added is_snr_above_noise_floor flag
2022-08-27 07:27:39 -07:00
Dean Cording
f21ddd67e0
Added is_snr_above_noise_floor flag 2022-08-27 12:55:27 +10:00