All Projects → timofurrer → Shellfuncs

timofurrer / Shellfuncs

Licence: mit
Python API to execute shell functions as they would be Python functions

Programming Languages

python
139335 projects - #7 most used programming language
shell
77523 projects
bash
514 projects

Projects that are alternatives of or similar to Shellfuncs

purescript-ffi-utils
A utility library for the purescript foreign function interface
Stars: ✭ 22 (-77.08%)
Mutual labels:  interface, function
Dm env
A Python interface for reinforcement learning environments
Stars: ✭ 127 (+32.29%)
Mutual labels:  api, interface
Wiki
Wikipedia Interface for Node.js
Stars: ✭ 180 (+87.5%)
Mutual labels:  api, interface
Gomonkey
gomonkey is a library to make monkey patching in unit tests easy
Stars: ✭ 473 (+392.71%)
Mutual labels:  function, interface
Rapid.js
An ORM-like Interface and a Router For Your API Requests
Stars: ✭ 700 (+629.17%)
Mutual labels:  api, interface
Ara
ARA Records Ansible and makes it easier to understand and troubleshoot.
Stars: ✭ 1,176 (+1125%)
Mutual labels:  api, interface
Opensourcetest
OpenSourceTest由自动化测试-夜行者社区维护,提供的是更多地灵活性和可配置性
Stars: ✭ 37 (-61.46%)
Mutual labels:  api, interface
Async Gamequery Lib
A high-performance java game query library designed for steam/source based games and others
Stars: ✭ 88 (-8.33%)
Mutual labels:  api, source
Telebot.nim
Async client for Telegram Bot API in pure Nim [Bot API 5.1]
Stars: ✭ 93 (-3.12%)
Mutual labels:  api
Api Restful Con Laravel Guia Definitiva
Repositorio para el código base del curso "API RESTful con Laravel - Guía Definitiva"
Stars: ✭ 95 (-1.04%)
Mutual labels:  api
Discord.jl
The Julia Discord API Wrapper
Stars: ✭ 93 (-3.12%)
Mutual labels:  api
X
新生命X组件,数据中间件XCode、日志、网络、RPC、序列化、缓存、Windows服务
Stars: ✭ 1,322 (+1277.08%)
Mutual labels:  api
Envh
Go helpers to manage environment variables
Stars: ✭ 95 (-1.04%)
Mutual labels:  environment
Pragma
An expressive, opinionated ecosystem for building beautiful RESTful APIs with Ruby.
Stars: ✭ 93 (-3.12%)
Mutual labels:  api
Python Binance Chain
Binance Chain Exchange API python implementation for automated trading
Stars: ✭ 96 (+0%)
Mutual labels:  api
Tutorialdb
A search 🔎 engine for programming/dev tutorials, See it in action 👉
Stars: ✭ 93 (-3.12%)
Mutual labels:  api
Tesla Api
🚘 A Ruby gem and unofficial documentation of Tesla's JSON API for the Model S, 3, X, and Y.
Stars: ✭ 1,317 (+1271.88%)
Mutual labels:  api
Bbc Fdc
Floppy disk interface for Raspberry Pi
Stars: ✭ 96 (+0%)
Mutual labels:  interface
Google Translate Api Browser
A free and unlimited API for Google Translate
Stars: ✭ 96 (+0%)
Mutual labels:  api
Soundcloud
Soundcloud.com API wrapper written in PHP with OAuth2 support.
Stars: ✭ 94 (-2.08%)
Mutual labels:  api

shellfuncs

Build Status PyPI package version PyPI python versions

Python API to execute functions written in shell script.

Let's assume you have a shell script counters.sh like this:

count_python_imports() {
    find -name '*.py' | xargs grep -e '^import os$' -e '^import sys$' -e '^import re$' | cut -d: -f2 | sort | uniq -c
}

And you want to execute the count_python_imports function within Python. Instead of using cumbersome subprocess wouldn't it be awesome to do something like this:

import shellfuncs

from counters import count_python_imports

returncode, stdout, stderr = count_python_imports()

Yeah, yeah, I know about easier ways of achieving the above, too. Thanks.

Why should I use that?

  • use existing shell scripts in a pythonic way
  • complex piping stuff might be easier to implement in shell script
  • testing shell scripts is a pain in the a** - with Python it'll be easier

Installation

The recommended way to install shellfuncs is to use pip:

pip install shellfuncs

Usage

shellfuncs can be configured on different levels.

The following configuration variables are available:

  • shell (defaults to /bin/sh)
  • env (defaults to os.environ)

Configuration via environment variables

Set the default shell via SHELLFUNCS_DEFAULT_SHELL environment variable:

export SHELLFUNCS_DEFAULT_SHELL=/bin/bash

Configuration via context manager

Set the configuration block-wise with a context manager:

import shellfuncs

with shellfuncs.config(shell='/bin/bash'):
    from counters import count_python_imports

count_python_imports()  # the shell used will be /bin/bash

Configuration for specific function call

Set the configuration when function is executed:

import shellfuncs

from counters import count_python_imports

count_python_imports(shell='/bin/bash')

This project is published under MIT.
A Timo Furrer project.
- 🎉 -

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].