Skip to main content

A command line tool used to automate the Bobcat miner. This project also offers a robust python SDK's for interacting with the Bobcat miner.

Project description

PyPI Dockerhub Release Tests Lint Code style: black

bobcat miner python

A command line tool used to automate the Bobcat miner. This project also offers a robust python SDK's for interacting with the Bobcat miner.

Install

$ pipx install bobcat-miner

Please see this guide for more information about installing stand alone command line tools with pipx.

Quick Start

The bobcat autopilot command will automatically diagnose and repair the Bobcat miner!

$ bobcat autopilot
✅ Sync Status: Synced (gap:-1) ✨
✅ Relay Status: Not Relayed ✨
✅ Network Status: Good 📶
✅ Temperature Status: Good (38°C) ☀️

or run with the offical Docker container

$ docker run --rm -it aidanmelen/bobcat autopilot

Run bobcat --help to learn about the available commands and options.

Monitoring with Discord

Send events to a Discord channel using a webhook URL

$ bobcat --discord-webhook-url https://discord.com/api/webhooks/xxx autopilot
✅ Sync Status: Synced (gap:0) ✨
⚠️ Relay Status: Relayed
✅ Network Status: Good 📶
❌ Temperature Status: Hot (78°C) 🌋

By default, all events WARNING or higher (i.e. ERROR and CRITICAL) will be sent to the Discord channel. This can be configured to include DEBUG and INFO events as well.

drawing

Finding your Bobcat

Manually Specify the Hostname / IP Address

By default, the Bobcat Autopilot will search the common 192.168.0.0/24 and 10.0.0.0/24 local networks and try to establish a Bobcat connection.

Otherwise, you can follow these instructions to find your Bobcats's ip address and manually specify it with:

$ bobcat --hostname 192.168.0.10 -C DEBUG autopilot
🐛 Connected to Bobcat: 192.168.0.10
🐛 The Bobcat Autopilot is starting 🚀 🚀 🚀

Search for Bobcat by Animal Name

This will connect to the Bobcat on your network that matches the animal name.

$ bobcat --animal "Fancy Awesome Bobcat" -C DEBUG autopilot
🐛 Connected to Bobcat: 192.168.0.10
🐛 Refresh: Miner Data
🐛 Verified Bobcat Animal: fancy-awesome-bobcat
🐛 The Bobcat Autopilot is starting 🚀 🚀 🚀

Bobcat Dry Run

This example is admittedly contrived, but it demonstrates how a dry run can show what actions would normally be performed against the bobcat.

$ bobcat --dry-run reboot
Do you want to reboot the Bobcat? [y/N]: y
⚠️ Dry run is enabled: Reboot Skipped

Bobcat SDK Usage

import bobcat_miner

bobcat = bobcat_miner.Bobcat("192.168.1.10")

# refresh
bobcat.refresh_status()
bobcat.refresh_miner()
bobcat.refresh_speed()
bobcat.refresh_temp()
bobcat.refresh_dig()
bobcat.refresh() # all endpoints

# properties
bobcat.status
bobcat.gap
bobcat.blockchain_height
bobcat.epoch
bobcat.tip
bobcat.ota_version
bobcat.region
bobcat.frequency_plan
bobcat.animal
bobcat.helium_animal
bobcat.pubkey
bobcat.state
bobcat.miner_status
bobcat.miner_height
bobcat.miner_alert
bobcat.miner_desc
bobcat.names
bobcat.image
bobcat.created
bobcat.p2p_status
bobcat.ports_desc
bobcat.ports
bobcat.private_ip
bobcat.public_ip
bobcat.peerbook
bobcat.timestamp
bobcat.error
bobcat.temp0
bobcat.temp1
bobcat.coldest_temp
bobcat.hottest_temp
bobcat.temp0_c
bobcat.temp1_c
bobcat.temp0_f
bobcat.temp1_f
bobcat.download_speed
bobcat.upload_speed
bobcat.latency
bobcat.dig_name
bobcat.dig_message
bobcat.dig_dns
bobcat.dig_records

# actions
bobcat.reboot()
bobcat.reset()
bobcat.resync()
bobcat.fastsync()

Development

The containerized development environment can be spun up with docker compose.

$ docker compose up --detach
[+] Running 3/3
  Network bobcat-miner-python_default  Created
  Container bobcat-miner-python-dev    Started
  Container fancy-awesome-bobcat       Started 

Then get a shell in the bobcat-miner-python-dev container.

$ docker-compose exec bobcat-miner-python-dev poetry run /bin/bash
root@bobcat-miner-python-dev:/app#

This dev container is networked with the fake bobcat service call fancy-awesome-bobcat.

$ docker-compose exec bobcat-miner-python-dev poetry run bobcat autopilot
🐛 Connected to Bobcat: fancy-awesome-bobcat
🐛 Refresh: Miner Data
🐛 Verified Bobcat Animal: fancy-awesome-bobcat
🐛 The Bobcat Autopilot is starting 🚀 🚀 🚀
🐛 Lock Acquired: /etc/bobcat/autopilot.lock
🐛 Checking: Relay Status
✅ Relay Status: Not Relayed ✨
🐛 Checking: Sync Status
🐛 Refresh: Status Data
✅ Sync Status: Synced (gap:0) ✨
🐛 Checking: Network Status
🐛 Refresh: Network Speed Data
✅ Network Status: Good 📶
🐛 Checking: Temperature Status
🐛 Refresh: Temperature Data
✅ Temperature Status: Good (38°C) ☀️
🐛 Checking: OTA Version Change
🐛 Checking: Down or Error Status
🐛 Checking: Height API Error Status
🐛 Lock Released: /etc/bobcat/autopilot.lock
🐛 The Bobcat Autopilot is finished ✨ 🍰 ✨

and bring the development environment down.

docker compose down
[+] Running 3/2
  Container bobcat-miner-python-dev
  Container fancy-awesome-bobcat
  Network bobcat-miner-python_default  Removed 

Please see the docker-compose.yml for more information.

Tests

Run unittests

docker build . -t bobcat-miner-python-test --target test
docker run --rm -it -v $(pwd):/app bobcat-miner-python-test

and run the linter

docker run --rm --volume $(pwd):/src --workdir /src pyfound/black:latest_release black --line-length 100 .

Release

Read the version from poetry, tag, and push.

$ git checkout main
$ git pull

$ git tag $(poetry version -s)
$ git push --tags

This will trigger the Release Github Action.

Troubleshooting

Please see No Witness's Troubleshooting Guide for more information.

Donations

Donations are welcome and appreciated! :gift:

HNT: 14HmckNU4WHDDtGH29FMqVENzZAYh5a9XRiLfY2AN6ghfHMvAuR

HNT: 14HmckNU4WHDDtGH29FMqVENzZAYh5a9XRiLfY2AN6ghfHMvAuR

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bobcat-miner-0.14.3.tar.gz (27.0 kB view hashes)

Uploaded Source

Built Distribution

bobcat_miner-0.14.3-py3-none-any.whl (27.5 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page