Skip to main content

![pytrol](./docs/pytrol.png)

## What is pytrol

pytrol is a helper for subprocess and allows easy process management.

## Installation

#### Automatic (recommended)

` $ pip install pytrol `

#### Manual

` $ git clone git@github.com:daehruoydeef/pytrol.git # moving pytrol into your projects lib folder assuming you are cloning it in the same directory $ cd myProject # create a lib folder inside your python project folder $ mkdir lib # move the cloned repository inside you lib folder $ mv ../pytrol/ ./lib `

## Overview

  • start

  • startAndWait

  • restart

  • restartAndWait

  • kill

  • isRunning

  • playSound

  • getUser

  • getUserPath

  • notify

## Documentation

#### import

import pytrol

from pytrol import start

#### start(process)

> starts a process by name. It will not wait for the output and will continue to run, it will not block the current used Thread. The Method Start will append the Process to the system Processes instead of waiting for its output or blocking the thread.

Example

start(“firefox”)

start(“telegram-desktop”)

—

#### startAndWait(process)

> starts a process by name. It will wait for the output and will not continue to run, it will block the current used Thread until the process finishes. Finally if the process finishes the method will return the exit code and output.

Example

startAndWait(“kate”)

output = startAndWait(“tree”)

—

#### restart(process)

> restarts process and does not wait on return used start() internally.

Example

restart(“telegram-desktop”)

restart(“telegram-desktop”)

—

restartAndWait(process)

> restarts process and does wait on return used startAndWait() internally.

Example

startAndWait(“kate”)

output = startAndWait(“tree”)

—

#### kill(process)

> kills the process and does not wait for return

Example

kill(“firefox”)

kill(“telegram-desktop”)

—

#### isRunning(process)

> return true or false wether the process is running or not

Example

isRunning(“firefox”) -> false

isRunning(“brave-browser”) -> true

—

#### playSound(sound)

> plays sound given by path. Will play mp3, wav, flac … with pulseaudio. If you do not use pulseaudio you might run into troubles.

Example

playSound(“click.wav”)

playSound(“./sounds/toks/tok.flac”)

—

#### getUser()

> returns the username that called the script. Note: If you call this script as root you will get “root” as username which is probably not intended.

Example

getUser() -> daeh

—

#### getUserPath()

> return the path to the users home directory. Note: If you run this with root privileges you will get the root path

Example

getUserPath() -> /home/daeh/

—

#### notify(“message”)

> sends system notification to the native system notify service

Example

notify(“Process terminated”)

notify(“update available”)

Release files for pytrol 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pytrol 0.1.1
File Size Uploaded
pytrol-0.1.1.tar.gz 3.2 kB Details

Release files / pytrol-0.1.1.tar.gz

Download URL pytrol-0.1.1.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
16029493961ea1aeccf4cb0a3bf02a0cfd01c4949fd89044620f919203a460e0
BLAKE2b-256 checksum
How to use checksums
c1fe4a5bffe8521f479e93b4694e07d08822f0002139faef2d9c85d58383e4a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via Python-urllib/2.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page