Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge main to pypi-packaging #3

Merged
merged 14 commits into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Upload Python Package to PyPI

on:
release:
types: [created]

jobs:
build-and-publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'

- name: Install build dependencies
run: |
python -m pip install --upgrade pip
pip install build twine

- name: Build the package
run: python -m build

- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: python -m twine upload dist/*
40 changes: 40 additions & 0 deletions .github/workflows/python-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: Python test

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi

- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics

- name: Test with pytest
run: |
pytest
106 changes: 88 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,105 @@
# Fetchtastic Termux Setup

This repository contains a set of scripts to download the latest Meshtastic Android app and Firmware releases to your phone via Termux. It also provides optional notifications via a NTFY server. Follow the steps below to set up and run the script.
Fetchtastic is a tool to download the latest Meshtastic Android app and Firmware releases to your phone via Termux. It also provides optional notifications via an NTFY server. This guide will help you set up and run Fetchtastic on your device.

## Setup Steps
## Prerequisites

### Step 1: Install **Termux** and addons.
### Install Termux and Add-ons

1. Install Termux: Download and install [Termux](https://f-droid.org/en/packages/com.termux/) from F-Droid.
2. Install Termux Boot: Download and install [Termux Boot](https://f-droid.org/en/packages/com.termux.boot/) from F-Droid.
3. Install Termux API: Download and install [Termux API](https://f-droid.org/en/packages/com.termux.api/) from F-Droid.
4. (Optional) Install ntfy: Download and install [ntfy](https://f-droid.org/en/packages/io.heckel.ntfy/) from F-Droid.
1. **Install Termux**: Download and install [Termux](https://f-droid.org/en/packages/com.termux/) from F-Droid.
2. **Install Termux Boot**: Download and install [Termux Boot](https://f-droid.org/en/packages/com.termux.boot/) from F-Droid.
3. **Install Termux API**: Download and install [Termux API](https://f-droid.org/en/packages/com.termux.api/) from F-Droid.
4. *(Optional)* **Install ntfy**: Download and install [ntfy](https://f-droid.org/en/packages/io.heckel.ntfy/) from F-Droid.

### Step 2: Request storage access for Termux API
### Request Storage Access for Termux

Open Termux and run this command, allowing Termux API storage access:
```
Open Termux and run the following command to grant storage access:

```bash
termux-setup-storage
```
## Installation

### Step 1: Install Python

```bash
pkg install python -y
```

### Step 2: Install Fetchtastic

```bash
pip install fetchtastic
```

## Usage

### Run the Setup Process

Run the setup command and follow the proompts to configure Fetchtastic:

```bash
fetchtastic setup
```

During setup, you will be able to:

- Choose whether to download APKs, firmware, or both.
- Select specific assets to download.
- Set the number of versions to keep.
- Configure automatic extraction of firmware files. (Optional)
- Set up notifications via NTFY. (Optional)
- Add a cron job to run Fetchtastic regularly. (Optional)

### Perform Downloads

### Step 3: Install Git and Clone the Repository
To manually start the download process, run:

Next run these commands to install git and clone the repository:
```bash
fetchtastic download
```
pkg install git -y
git clone https://github.com/jeremiah-k/fetchtastic.git
cd fetchtastic

This will download the latest versions of the selected assets and store them in the specified directories.

### Help and Reconfiguration

To view help and usage instructions, run:

```bash
fetchtastic --help
```

### Step 3: Run the Setup Script
If you need to reconfigure Fetchtastic, run:

Run setup.sh and follow the prompts to complete the setup.
```bash
fetchtastic setup
```
sh setup.sh

### Files and Directories

By default, Fetchtastic saves files and configuration in the `Downloads/Fetchtastic` directory:

- **Configuration File**: `Downloads/Fetchtastic/fetchtastic.yaml`
- **Log File**: `Downloads/Fetchtastic/fetchtastic.log`
- **APKs**: `Downloads/Fetchtastic/apks`
- **Firmware**: `Downloads/Fetchtastic/firmware`

You can manually edit the configuration file to change the settings.


### Scheduling with Cron

During setup, you have the option to add a cron job that runs Fetchtastic daily at 3 AM.

To modify cron job, you can run:
```bash
crontab -e
```

### Notifications via NTFY

If you choose to set up notifications, Fetchtastic will send updates to your specified NTFY topic.

### Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.
Empty file added app/__init__.py
Empty file.
53 changes: 53 additions & 0 deletions app/cli.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# app/cli.py

import argparse
from . import downloader
from . import setup_config

def main():
parser = argparse.ArgumentParser(description="Fetchtastic - Meshtastic Firmware and APK Downloader")
subparsers = parser.add_subparsers(dest='command')

# Command to run setup
parser_setup = subparsers.add_parser('setup', help='Run the setup process')

# Command to download firmware and APKs
parser_download = subparsers.add_parser('download', help='Download firmware and APKs')

# Command to display NTFY topic
parser_topic = subparsers.add_parser('topic', help='Display the current NTFY topic')

# Command to clean/remove Fetchtastic files and settings
parser_clean = subparsers.add_parser('clean', help='Remove Fetchtastic configuration, downloads, and cron jobs')

args = parser.parse_args()

if args.command == 'setup':
# Run the setup process
setup_config.run_setup()
elif args.command == 'download':
# Check if configuration exists
if not setup_config.config_exists():
print("No configuration found. Running setup.")
setup_config.run_setup()
# Run the downloader
downloader.main()
elif args.command == 'topic':
# Display the NTFY topic
config = setup_config.load_config()
if config and config.get('NTFY_SERVER'):
print(f"Current NTFY topic URL: {config['NTFY_SERVER']}")
else:
print("Notifications are not set up. Run 'fetchtastic setup' to configure notifications.")
elif args.command == 'clean':
# Run the clean process
setup_config.run_clean()
elif args.command is None:
# No command provided
print("No command provided.")
print("For help and available commands, run 'fetchtastic --help'.")
else:
parser.print_help()

if __name__ == "__main__":
main()
Loading
Loading