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 hashes)

Uploaded Source

Built Distribution

leaguecloser-1.0.5-py3-none-any.whl (29.4 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