Skip to main content

Launchpad represents a small factory and a distinct abstract for defining actionable items

Project description

Overview

Launchpad represents a small factory and a distinct abstract for defining actionable items. This is particularly useful when creating libraries of tools or processes which need to be exposed and invokable.

Each action contains general details such as name, description etc as well as some richer functionality to invoke the action or for the action to expose further sub-actions or properties.

As the LaunchPad class is just a factory its population is dynamic based upon the paths your feed it (or expose through the LAUNCHPAD_PLUGIN_PATHS variable).

An example of use might be...

import launchpad

# -- Instance launchpad, this gives access to all the
# -- actions
lp = launchpad.LaunchPad('/usr/my_actions')

# -- We can cycle over all the actions
for action in lp.identifiers():
    print(action)

    # -- We can get an action and run it
    lp.request(action).run()

# -- We can access actions direclty too
action = lp.request('My Action Name')
action.run()

Installation

If you use pip, you can simply run pip install launchpad. That will pull down the required dependencies (scribble & factories) automatically.

Note: If you install launchpanel this module will be pulled down automatically as a dependency. Therefore you only need to pull down this module explicitly if you do not plan to utilise the launchpanel ui.

The Abstract

To define an action you must implement a Launch Action. The process of implementing an action is just a case of creating a python file and inheriting from the LaunchAction object, like this:

import launchpad

# ------------------------------------------------------------------------------
class MyAction(launchpad):
    Name = ''
    Description = __doc__
    Icon = ''
    Groups = []

    @classmethod
    def run(cls):
        pass

    @classmethod
    def actions(cls):
        return dict()

    @classmethod
    def properties(cls):
        return dict()

    @classmethod
    def viability(cls):
        return cls.VALID

The properties are very much about giving descriptive information about your action. Description, Icon and Groups are all optional and can be left out entirely if desired - but Name must always be filled in.

run() is where you perform the default action for this action.

actions() allows you to return a dictionary of key value pairs where the key is the action label and the value is the function/callable. This allows you to give your action variations or extended behaviour which is accessible in a consistent way.

viability() is the mechanism to give an indiciation as to whether your action is valid within the current environment. For example, if your action relies on paths existing, or environment variables being set, you can run those tests there are return the Action Viability (VALID, INVALID, DISABLED).

properties() is a mechanism for storing blind data. It should always return a dictionary but there is not formal structure for that dictionary. This is implemented to give you the oppotunity to store tool specific data within the action depending upon your needs.

Credits & Collaboration

This module was inspired by some excellent collaborative projects with a fantastic tech-artist called Toby Harrison-Banfield.

I am always open to collaboration, so if you spot bugs lets me know, or if you would like to contribute or get involved just shout!

Compatibility

Launchpad has been tested under Python 2.7 and Python 3.7 on Windows and Ubuntu.

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

launchpad-1.1.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

launchpad-1.1.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file launchpad-1.1.0.tar.gz.

File metadata

  • Download URL: launchpad-1.1.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.7.0 requests/2.25.1 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/2.7.13

File hashes

Hashes for launchpad-1.1.0.tar.gz
Algorithm Hash digest
SHA256 d6f852da23abb60cc1b3a44e7fbb34eb3bb62dc059c31fcbee249eea94bfd1b3
MD5 7fbbe4a67f2a02c422d95c3ef1e9f6f6
BLAKE2b-256 b90962f40272f934d1ac3eb3632dd01fece0e8e55a049a80901adba03e576a75

See more details on using hashes here.

File details

Details for the file launchpad-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: launchpad-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.7.0 requests/2.25.1 setuptools/28.8.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/2.7.13

File hashes

Hashes for launchpad-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ddb303e1274a5e413224a785af2817ac2946822ac9225360f3aee0313b3bcb37
MD5 c7b924cfa7cc2ccbf8a2b74baa43b221
BLAKE2b-256 a790c0388a91ab6207ff721c8325da4cb4cee94b2060d95a14fe128ba5dccdfd

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