Skip to content
Open
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
74 changes: 74 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: CI

on:
push:
branches: [ main, master ]
pull_request:
branches: [ main, master ]

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v4

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

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Install dependencies
run: |
uv venv
uv pip install -e ".[dev,plot]"

- name: Run linter
run: |
uv run ruff check . --ignore N806,N999

- name: Run tests
run: |
uv run pytest --cov=byfly --cov=byflyuser --cov=database --cov=plotinfo --cov-report=xml

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
file: ./coverage.xml
fail_ci_if_error: false

lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'

- name: Install uv
uses: astral-sh/setup-uv@v3
with:
version: "latest"

- name: Install dependencies
run: |
uv venv
uv pip install -e ".[dev]"

- name: Run linter
run: |
uv run ruff check . --ignore N806,N999

- name: Check formatting
run: |
uv run ruff format . --check
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@
*.png
.idea/
.coverage
coverage.xml
coverage.xml
*.egg-info/
__pycache__/
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.PHONY: help install test check

help: ## Show this help message
@echo "Available commands:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-10s\033[0m %s\n", $$1, $$2}'

install: ## Install development dependencies
uv pip install -e ".[dev,plot]"

test: ## Run tests
uv run pytest --cov=src --cov-report=term-missing

check: ## Run linter
@echo "Running linter..."
uv run ruff check . --ignore N806,N999
@echo "\nAll checks passed!"
147 changes: 129 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,141 @@
ByFlyPy
================
[![Build Status](https://travis-ci.org/peleccom/ByFlyPy.svg?branch=master)](https://travis-ci.org/peleccom/ByFlyPy)
[![codecov](https://codecov.io/gh/peleccom/ByFlyPy/branch/master/graph/badge.svg)](https://codecov.io/gh/peleccom/ByFlyPy)
# ByFlyPy

Tiny program and class to check ByFly (*The belarus biggest ICS provider*) account balance, get user information, plot some information
[![CI](https://github.com/anomalyco/ByFlyPy/actions/workflows/ci.yml/badge.svg)](https://github.com/anomalyco/ByFlyPy/actions/workflows/ci.yml)
[![Python 3.9+](https://img.shields.io/badge/python-3.9+-blue.svg)](https://www.python.org/downloads/)
[![Code style: ruff](https://img.shields.io/badge/code%20style-ruff-000000.svg)](https://github.com/astral-sh/ruff)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

Маленькая программа и класс для проверки баланса аккаунта ByFly, получения информации и построения некоторых графиков
ByFlyPy is a Python console application for checking account balance and statistics from ByFly (Belarusian ISP) personal cabinet.

Class usage:
## Features

from byflyuser import ByFlyUser
- Check account balance and tariff plan
- View traffic and time statistics
- Generate graphs (traffic and time allocation)
- Support for multiple accounts
- SQLite database for storing credentials
- Interactive and non-interactive modes

user = ByFlyUser("login", "password")
## Installation

# connect to server and login
user.login()
### Requirements

info = user.get_account_info_page()
- Python 3.9+
- uv (recommended) or pip

# print account info
print(info.full_name)
print(info.balance)

### Install from source

CLI usage:
```bash
# Clone the repository
git clone https://github.com/anomalyco/ByFlyPy.git
cd ByFlyPy

python byfly.py -l <your_login_number> -p <your_password>
# Install with uv (recommended)
make install

# Or with pip
pip install -e ".[dev,plot]"
```

## Usage

### Command Line

```bash
# Check balance
python byfly.py -l YOUR_LOGIN -p YOUR_PASSWORD

# Interactive mode
python byfly.py -i

# Generate traffic graph
python byfly.py -l YOUR_LOGIN -p YOUR_PASSWORD -g traf

# Generate time graph
python byfly.py -l YOUR_LOGIN -p YOUR_PASSWORD -g time

# Save graph to file
python byfly.py -l YOUR_LOGIN -p YOUR_PASSWORD -g traf -s graph.png

# Check multiple accounts from file
python byfly.py --list accounts.txt
```

### Python API

```python
from byflyuser import ByFlyUser

# Create user instance
user = ByFlyUser("login", "password")

# Login
user.login()

# Get account info
info = user.get_account_info_page()
print(f"Balance: {info.balance}")
print(f"Plan: {info.plan}")

# Get statistics sessions
sessions = user.get_log()
for session in sessions:
print(f"{session.begin} - {session.end}: {session.ingoing} MB")
```

## Development

```bash
# Run tests
make test

# Run linter
make check

# Install development dependencies
make install
```

## Database

Store credentials securely in SQLite database:

```bash
# Create database with interactive mode
python database.py users.db

# Use database with byfly
python byfly.py -l login --db users.db
```

## Project Structure

```
ByFlyPy/
├── byfly.py # Main CLI application
├── byflyuser.py # ByFly API client
├── database.py # SQLite database manager
├── plotinfo.py # Matplotlib plotting utilities
├── tests.py # pytest test suite
├── pyproject.toml # Project configuration
├── Makefile # Development commands
└── testdata/ # Test fixtures
```

## Contributing

1. Fork the repository
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
3. Run tests and linter (`make test && make check`)
4. Commit your changes (`git commit -m 'Add amazing feature'`)
5. Push to the branch (`git push origin feature/amazing-feature`)
6. Open a Pull Request

## License

This project is licensed under the MIT License.

## Acknowledgments

- Original author: Александр
- Created: 28.10.2011
1 change: 0 additions & 1 deletion __init__.py

This file was deleted.

Loading
Loading