ipylivebash


Nameipylivebash JSON
Version 0.2.2 PyPI version JSON
download
home_pagehttps://github.com/benlau/ipylivebash
SummaryRun shell script in Jupyter with live output
upload_time2023-08-20 02:36:58
maintainer
docs_urlNone
authorBen lau
requires_python>=3.6
licenseBSD
keywords jupyter widgets ipython
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # ipylivebash

The ipylivebash library is a shell script runner that enhances Jupyter's capabilities, transforming it into an valuable tool within the context of DevOps.

Features:
- Live Magic: Added "%%livebash" live magic command to run shell script in Jupyter.
- Execution Confirmation UI: Avoid accidental execution
- Notification: Send a notification when the script finishes
- Background Process Management: Show and kill background process
- Logging: Log output to a file with/without timestamp information
- Python API: For running script easily

## Screenshots

![screenshot1.png](https://raw.githubusercontent.com/benlau/ipylivebash/main/docs/img/screenshot1.png)

Execution Confirmation

![ask_confirm.png](https://raw.githubusercontent.com/benlau/ipylivebash/main/docs/img/ask_confirm.png)

## Example

```
%%livebash --save log.txt --save-timestamp

find .
```

Run `find .` and show the output in the Jupyter notebook, and also save it to log-${current_timestamp}.txt.


```
%%livebash --ask-confirm --notify
set -e
deploy_script
```

Before running the `deploy_script`, show a panel to ask for confirmation. Once it is finished, inform the user with a browser notification.

# Usage

```
usage: livebash [-h] [-ps] [--save OUTPUT_FILE] [--save-timestamp]
                [--line-limit LINE_LIMIT] [--height HEIGHT] [--ask-confirm]
                [--notify]

options:
  -h, --help
  -ps, --print-sessions
  --save OUTPUT_FILE    Save output to a file
  --save-timestamp      Add timestamp to the output file name
  --line-limit LINE_LIMIT
                        Restrict the no. of lines to be shown
  --height HEIGHT       Set the height of the output cell (no. of line)
  --ask-confirm         Ask for confirmation before execution
  --notify              Send a notification when the script finished
```

## Options

**--save OUTPUT_FILE**

Save the output to a file. 

If the file name already exists, it will add a suffix to avoid overriding the original file.

**--save-timestamp**

Add timestamp to the output file name.

**--line-limit LINE_LIMIT**

If the no. of line output exceed the limit, it may be truncated. 
It will show the last 5 lines only.

**--height HEIGHT**

Set the height of the output cell

**--ask-confirm**
 
Ask for confirmation before execution

![ask_confirm.png](https://raw.githubusercontent.com/benlau/ipylivebash/main/docs/img/ask_confirm.png)

**--notify**
  
Send a notification when the script finished

## Installation

You can install using `pip`:

```bash
pip install ipylivebash
```

Remarks: If you are using Jupyter Notebook 5.2 or earlier, you may also need to enable
the nbextension:

```bash
jupyter nbextension enable --py [--sys-prefix|--user|--system] ipylivebash
```

## Development Installation

Create a dev environment:
```bash
conda create -n ipylivebash-dev -c conda-forge nodejs yarn python jupyterlab
conda activate ipylivebash-dev
```

Install the python. This will also build the TS package.
```bash
pip install -e ".[test, examples]"
```

When developing your extensions, you need to manually enable your extensions with the
notebook / lab frontend. For lab, this is done by the command:

```
jupyter labextension develop --overwrite .
yarn run build
```

For classic notebook, you need to run:

```
jupyter nbextension install --sys-prefix --symlink --overwrite --py ipylivebash
jupyter nbextension enable --sys-prefix --py ipylivebash
```

Note that the `--symlink` flag doesn't work on Windows, so you will here have to run
the `install` command every time that you rebuild your extension. For certain installations
you might also need another flag instead of `--sys-prefix`, but we won't cover the meaning
of those flags here.

### How to see your changes
#### Typescript:
If you use JupyterLab to develop then you can watch the source directory and run JupyterLab at the same time in different
terminals to watch for changes in the extension's source and automatically rebuild the widget.

```bash
# Watch the source directory in one terminal, automatically rebuilding when needed
yarn run watch
# Run JupyterLab in another terminal
jupyter lab
```

After a change wait for the build to finish and then refresh your browser and the changes should take effect.

#### Python:
If you make a change to the python code then you will need to restart the notebook kernel to have it take effect.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/benlau/ipylivebash",
    "name": "ipylivebash",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "Jupyter,Widgets,IPython",
    "author": "Ben lau",
    "author_email": "xbenlau@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/64/62/6bc61dfb2a812d9872adb6908660e80ee5b862808aa170257e9eb6292e37/ipylivebash-0.2.2.tar.gz",
    "platform": "Linux",
    "description": "# ipylivebash\n\nThe ipylivebash library is a shell script runner that enhances Jupyter's capabilities, transforming it into an valuable tool within the context of DevOps.\n\nFeatures:\n- Live Magic: Added \"%%livebash\" live magic command to run shell script in Jupyter.\n- Execution Confirmation UI: Avoid accidental execution\n- Notification: Send a notification when the script finishes\n- Background Process Management: Show and kill background process\n- Logging: Log output to a file with/without timestamp information\n- Python API: For running script easily\n\n## Screenshots\n\n![screenshot1.png](https://raw.githubusercontent.com/benlau/ipylivebash/main/docs/img/screenshot1.png)\n\nExecution Confirmation\n\n![ask_confirm.png](https://raw.githubusercontent.com/benlau/ipylivebash/main/docs/img/ask_confirm.png)\n\n## Example\n\n```\n%%livebash --save log.txt --save-timestamp\n\nfind .\n```\n\nRun `find .` and show the output in the Jupyter notebook, and also save it to log-${current_timestamp}.txt.\n\n\n```\n%%livebash --ask-confirm --notify\nset -e\ndeploy_script\n```\n\nBefore running the `deploy_script`, show a panel to ask for confirmation. Once it is finished, inform the user with a browser notification.\n\n# Usage\n\n```\nusage: livebash [-h] [-ps] [--save OUTPUT_FILE] [--save-timestamp]\n                [--line-limit LINE_LIMIT] [--height HEIGHT] [--ask-confirm]\n                [--notify]\n\noptions:\n  -h, --help\n  -ps, --print-sessions\n  --save OUTPUT_FILE    Save output to a file\n  --save-timestamp      Add timestamp to the output file name\n  --line-limit LINE_LIMIT\n                        Restrict the no. of lines to be shown\n  --height HEIGHT       Set the height of the output cell (no. of line)\n  --ask-confirm         Ask for confirmation before execution\n  --notify              Send a notification when the script finished\n```\n\n## Options\n\n**--save OUTPUT_FILE**\n\nSave the output to a file. \n\nIf the file name already exists, it will add a suffix to avoid overriding the original file.\n\n**--save-timestamp**\n\nAdd timestamp to the output file name.\n\n**--line-limit LINE_LIMIT**\n\nIf the no. of line output exceed the limit, it may be truncated. \nIt will show the last 5 lines only.\n\n**--height HEIGHT**\n\nSet the height of the output cell\n\n**--ask-confirm**\n \nAsk for confirmation before execution\n\n![ask_confirm.png](https://raw.githubusercontent.com/benlau/ipylivebash/main/docs/img/ask_confirm.png)\n\n**--notify**\n  \nSend a notification when the script finished\n\n## Installation\n\nYou can install using `pip`:\n\n```bash\npip install ipylivebash\n```\n\nRemarks: If you are using Jupyter Notebook 5.2 or earlier, you may also need to enable\nthe nbextension:\n\n```bash\njupyter nbextension enable --py [--sys-prefix|--user|--system] ipylivebash\n```\n\n## Development Installation\n\nCreate a dev environment:\n```bash\nconda create -n ipylivebash-dev -c conda-forge nodejs yarn python jupyterlab\nconda activate ipylivebash-dev\n```\n\nInstall the python. This will also build the TS package.\n```bash\npip install -e \".[test, examples]\"\n```\n\nWhen developing your extensions, you need to manually enable your extensions with the\nnotebook / lab frontend. For lab, this is done by the command:\n\n```\njupyter labextension develop --overwrite .\nyarn run build\n```\n\nFor classic notebook, you need to run:\n\n```\njupyter nbextension install --sys-prefix --symlink --overwrite --py ipylivebash\njupyter nbextension enable --sys-prefix --py ipylivebash\n```\n\nNote that the `--symlink` flag doesn't work on Windows, so you will here have to run\nthe `install` command every time that you rebuild your extension. For certain installations\nyou might also need another flag instead of `--sys-prefix`, but we won't cover the meaning\nof those flags here.\n\n### How to see your changes\n#### Typescript:\nIf you use JupyterLab to develop then you can watch the source directory and run JupyterLab at the same time in different\nterminals to watch for changes in the extension's source and automatically rebuild the widget.\n\n```bash\n# Watch the source directory in one terminal, automatically rebuilding when needed\nyarn run watch\n# Run JupyterLab in another terminal\njupyter lab\n```\n\nAfter a change wait for the build to finish and then refresh your browser and the changes should take effect.\n\n#### Python:\nIf you make a change to the python code then you will need to restart the notebook kernel to have it take effect.\n",
    "bugtrack_url": null,
    "license": "BSD",
    "summary": "Run shell script in Jupyter with live output",
    "version": "0.2.2",
    "project_urls": {
        "Homepage": "https://github.com/benlau/ipylivebash"
    },
    "split_keywords": [
        "jupyter",
        "widgets",
        "ipython"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "393ff41c3c6c53dc21daf38def2ede293c4a6f5271d7025570f75ee4d8a46294",
                "md5": "237d8ac34fa05ee14e278a151a45fd11",
                "sha256": "3e9f968edff5d02fb2142e653d33a6814388551125e1313e78ea2451f35aa859"
            },
            "downloads": -1,
            "filename": "ipylivebash-0.2.2-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "237d8ac34fa05ee14e278a151a45fd11",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.6",
            "size": 990230,
            "upload_time": "2023-08-20T02:36:55",
            "upload_time_iso_8601": "2023-08-20T02:36:55.674115Z",
            "url": "https://files.pythonhosted.org/packages/39/3f/f41c3c6c53dc21daf38def2ede293c4a6f5271d7025570f75ee4d8a46294/ipylivebash-0.2.2-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "64626bc61dfb2a812d9872adb6908660e80ee5b862808aa170257e9eb6292e37",
                "md5": "cf55b501c4e77192cb072a0a1edb6539",
                "sha256": "8d6a3105524e8fe1ae660817f8e7e8b6ac9a042b9b5994a834357a270b81508f"
            },
            "downloads": -1,
            "filename": "ipylivebash-0.2.2.tar.gz",
            "has_sig": false,
            "md5_digest": "cf55b501c4e77192cb072a0a1edb6539",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 693829,
            "upload_time": "2023-08-20T02:36:58",
            "upload_time_iso_8601": "2023-08-20T02:36:58.827222Z",
            "url": "https://files.pythonhosted.org/packages/64/62/6bc61dfb2a812d9872adb6908660e80ee5b862808aa170257e9eb6292e37/ipylivebash-0.2.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-20 02:36:58",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "benlau",
    "github_project": "ipylivebash",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "ipylivebash"
}
        
Elapsed time: 0.17090s