Skip to main content

Mock package that auto-closes the League client

Project description

Auto League Closer™

The program moving the cursor to the X button, then the exit button

Tired of procrastinating on homework all day while still being hardstuck Bronze? Suffering from a bad case of League withdrawal?

Well, I've got a solution for you! Install the Auto League Closer™!

This handy program will automatically close the League of Legends client whenever it's running, so you can get back to binging YouTube videos - uh, I mean doing homework :)

About

This is a mock application - complex enough to run into many common issues, but simple enough to quickly understand. The goal is to serve as a reference for best practices by using a clean project structure and handling packaging/distribution methods.

Installation

Run the installer. (This app only works on Windows.)

How It Works

  1. Repeatedly checks if League is open using psutil.
  2. Closes League in a ~fancy~ way using SikuliX.

Using the Python Module

This module is just like any other Python module! See its PyPi page, or just install it with:

$ pip install leaguecloser

Example usage (also what the installable app does):

import leaguecloser
import time

print("Searching for League...")
while True:
    if leaguecloser.is_league_running():
        print("\nNO LEAGUE ALLOWED!")
        if leaguecloser.close_league():
            print("\nThat's right... now get back to work!")
    time.sleep(3)

Best Practices

Makefile

The Makefile contains good practice methods for the common tasks below:

$ make run  # Runs the file
$ make test  # Runs all tests
$ make package_create  # Creates (or updates) the leaguecloser package
$ make package_upload  # Uploads the leaguecloser package to PyPi
$ make build_app  # Builds the app into a standalone folder with an executable ("freezes" the app)

The purpose of a Makefile is to simplify repetitive tasks. It's basically multiple shell scripts, but combined into one file with a simple command for each task.

Building (EXEs) and Packaging (PyPi)

For building and packaging, these files must be configured per project (this repo serves as a good reference for how to do this!):

Handling Data Files

Since this app uses both static and dynamic data files (the SikuliX script folder, along with a large JAR file that is downloaded on the first run), the above files and some special code were required. Actually, the module, albeit small, follows best practices:

  • __init__.py only exposes things that are meant to be public and has a docstring describing the module with a copyright footer
  • computer.py keeps large code organized through code reuse, clear sections using comments, and Google docstrings for variables and functions.
  • league.py exists to ensure each file serves a specific purpose (separation of concerns), rather than bunching this short piece of code into another file.
  • sikuli.py treats frozen and non-frozen environments differently, and demonstrates how to handle program data files. (Data that's unique per computer user should be stored in %APPDATA% instead.)

Development Setup

Run the development environment setup script to create a virtual environment and install dependencies:

> & '.\misc\Dev Setup.ps1'

Publishing a New Version

Here are the steps:

  • Change the project version in pyproject.toml.

  • Delete the dist/package directory.

  • Run make package_create package_upload and `make package_upload

$ make build_app
$ make package_create
$ make package_upload
  • Compile the Inno Setup script.

  • Create a new release on Github with the generated installer attached as a binary.

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

leaguecloser-1.0.5.tar.gz (32.6 kB view details)

Uploaded Source

Built Distribution

leaguecloser-1.0.5-py3-none-any.whl (29.4 kB view details)

Uploaded Python 3

File details

Details for the file leaguecloser-1.0.5.tar.gz.

File metadata

  • Download URL: leaguecloser-1.0.5.tar.gz
  • Upload date:
  • Size: 32.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for leaguecloser-1.0.5.tar.gz
Algorithm Hash digest
SHA256 23fc6339fe8607c5ae0b7204e81a8260b27d0af9be05dd77780b8446aeba8d35
MD5 e2b4c1db1df9851f01790cc120b658e7
BLAKE2b-256 6dbc54d76d239cc822018a187038bca01c8b748b5cac2ae061378c1abf3bcf24

See more details on using hashes here.

File details

Details for the file leaguecloser-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: leaguecloser-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 29.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.8

File hashes

Hashes for leaguecloser-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 59badadb0256b8feef62df619bbabdacd1f83003976f3578803aca95cbdac2c9
MD5 60de564be3f77c7728e9b165c9d7fa18
BLAKE2b-256 6fe70c8950d20f3dfe8ba0de0a8fb064a229c485372a2abce2914a142e6145b9

See more details on using hashes here.

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