tues


Nametues JSON
Version 3.1.1 PyPI version JSON
download
home_pageNone
SummaryEasy remote command execution
upload_time2024-03-21 12:27:21
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseThe MIT License (MIT) Copyright (c) 2014-2023, Michael van Bracht and contributors. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords ssh remote shell sudo
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # tues

Run any remote command via ssh and sudo

## Install

 * Run `pip install tues`

## Getting Started


### As a commandline tool

Tues expects a command to execute, followed by the name of a hostname provider and its arguments.

Run `id` on localhost as user root, using the IPv4/IPv6 adresses is not required, just passing localhost three times would work as well, you are only prompted for a password once and the original sudo prompt is stripped from the output.
The login user will be derived from your ssh configuration (or if you really need to, manually with the `--login-user`/`-l` switch), while the user specified by `-u` is the user to run the command as on the remote host.

```
$ tues -u root id cl localhost 127.0.0.1 [::1]
[::1/stdout]: uid=0(root) gid=0(root) groups=0(root)
[127.0.0.1/stdout]: uid=0(root) gid=0(root) groups=0(root)
[localhost/stdout]: uid=0(root) gid=0(root) groups=0(root)
$
```

There are switches to send output to a directory, one file per host (`-d <dir>`), run on multiple hosts at a time `-n <num>`, upload files to the remote host before executing the command `-f <file>` and also a mechanic to treat the executed command as a local script in `TUES_PATH` that needs to be uploaded to the host first.

```
$ echo 'ls "$@"' > myls
$ chmod +x myls
$ echo foo > myfile
$ mkdir output
$ tues --path=. -d output -f myfile -s 'myls -la $TUES_FILE1' localhost 127.0.0.1
Starting localhost
Finished localhost
Starting 127.0.0.1
Finished 127.0.0.1
$ cat output/*
[127.0.0.1/stdout]: -rw-rw-r-- 1 mvb mvb 4 Jul 26 12:59 myfile
[localhost/stdout]: -rw-rw-r-- 1 mvb mvb 4 Jul 26 12:59 myfile
$
```

Running with an output directory automatically enables verbose mode to show at least a bit of progress, while disabling prefixing because with one file per host, you probably won't need the prefix.
For this simple example, we set `TUES_PATH` to `.` on the commandline, by default, scripts should be placed in `$HOME/.config/tues/scripts/`.

### From Python

When running from python, tues will behave mostly the same, with slight differences where it makes sense. In Python mode, we need to explicitly request output prefixing for example:

```python
import tues

tues.run(
    ["localhost", "127.0.0.1", "[::1]"],
    "id",
    user="root",
    prefix=True,
)
```

```$ python3 tues.py
Your remote sudo password:
[localhost/stdout]: uid=0(root) gid=0(root) groups=0(root)
[127.0.0.1/stdout]: uid=0(root) gid=0(root) groups=0(root)
[::1/stdout]: uid=0(root) gid=0(root) groups=0(root)
$
```

Output is usually kept "clean" (except for the sudo output of course) for later processing:

```python
import sys

import tues

runs = tues.run(
    ["localhost", "127.0.0.1", "[::1]"],
    "id",
    user="root",
    text=True,
    capture_output=True,
)

for run in runs:
    sys.stdout.write(run.stdout)
```

The interface tries to mimic `subprocess.run` where possible, the fact that it can run a command on multiple hosts will always require details to be handle diffrently though.


```
$ python3 tues.py
Your remote sudo password:
uid=0(root) gid=0(root) groups=0(root)
uid=0(root) gid=0(root) groups=0(root)
uid=0(root) gid=0(root) groups=0(root)
$
```

For a detailed description of the `run` Arguments, please [check out the docstring](https://github.com/wontfix-org/tues/blob/master/tues/__init__.py#L800) for now, while I procastinate on creating proper docs. :-(

## Providers

### File

The `file` provider assumes all files passed on the commandline contain one host per line.

### Commandline

The `cl` provider assumes all arguments passed on the commandline are hosts to connect to.

### Foreman

Execute on all hosts matching a certain foreman expression.

```
export FOREMAN_URL="https://user:password@foreman.domain/"
tues "ls" fm "class = my::class"
```

### Custom Providers

New providers may be added by putting a new executable with a name like "tues-provider-<name>"
on your PATH. A provider is expected to return a newline seperated list of hosts.

If the provider returns with an error, the output is considered to be an error message and/or
it's help output. If '--help' is passed through to the provider the output is displayed no matter
what exit code is used.

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "tues",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "ssh, remote, shell, sudo",
    "author": null,
    "author_email": "Michael van Bracht <michael@wontfix.org>, Marc Schmitzer <marc@solute.de>, Roland Sommer <rol@ndsommer.de>",
    "download_url": "https://files.pythonhosted.org/packages/fa/c4/c996bfdb04d47119ef1434541bc19b8bfc580e57e014464f4d9502ca4330/tues-3.1.1.tar.gz",
    "platform": null,
    "description": "# tues\n\nRun any remote command via ssh and sudo\n\n## Install\n\n * Run `pip install tues`\n\n## Getting Started\n\n\n### As a commandline tool\n\nTues expects a command to execute, followed by the name of a hostname provider and its arguments.\n\nRun `id` on localhost as user root, using the IPv4/IPv6 adresses is not required, just passing localhost three times would work as well, you are only prompted for a password once and the original sudo prompt is stripped from the output.\nThe login user will be derived from your ssh configuration (or if you really need to, manually with the `--login-user`/`-l` switch), while the user specified by `-u` is the user to run the command as on the remote host.\n\n```\n$ tues -u root id cl localhost 127.0.0.1 [::1]\n[::1/stdout]: uid=0(root) gid=0(root) groups=0(root)\n[127.0.0.1/stdout]: uid=0(root) gid=0(root) groups=0(root)\n[localhost/stdout]: uid=0(root) gid=0(root) groups=0(root)\n$\n```\n\nThere are switches to send output to a directory, one file per host (`-d <dir>`), run on multiple hosts at a time `-n <num>`, upload files to the remote host before executing the command `-f <file>` and also a mechanic to treat the executed command as a local script in `TUES_PATH` that needs to be uploaded to the host first.\n\n```\n$ echo 'ls \"$@\"' > myls\n$ chmod +x myls\n$ echo foo > myfile\n$ mkdir output\n$ tues --path=. -d output -f myfile -s 'myls -la $TUES_FILE1' localhost 127.0.0.1\nStarting localhost\nFinished localhost\nStarting 127.0.0.1\nFinished 127.0.0.1\n$ cat output/*\n[127.0.0.1/stdout]: -rw-rw-r-- 1 mvb mvb 4 Jul 26 12:59 myfile\n[localhost/stdout]: -rw-rw-r-- 1 mvb mvb 4 Jul 26 12:59 myfile\n$\n```\n\nRunning with an output directory automatically enables verbose mode to show at least a bit of progress, while disabling prefixing because with one file per host, you probably won't need the prefix.\nFor this simple example, we set `TUES_PATH` to `.` on the commandline, by default, scripts should be placed in `$HOME/.config/tues/scripts/`.\n\n### From Python\n\nWhen running from python, tues will behave mostly the same, with slight differences where it makes sense. In Python mode, we need to explicitly request output prefixing for example:\n\n```python\nimport tues\n\ntues.run(\n    [\"localhost\", \"127.0.0.1\", \"[::1]\"],\n    \"id\",\n    user=\"root\",\n    prefix=True,\n)\n```\n\n```$ python3 tues.py\nYour remote sudo password:\n[localhost/stdout]: uid=0(root) gid=0(root) groups=0(root)\n[127.0.0.1/stdout]: uid=0(root) gid=0(root) groups=0(root)\n[::1/stdout]: uid=0(root) gid=0(root) groups=0(root)\n$\n```\n\nOutput is usually kept \"clean\" (except for the sudo output of course) for later processing:\n\n```python\nimport sys\n\nimport tues\n\nruns = tues.run(\n    [\"localhost\", \"127.0.0.1\", \"[::1]\"],\n    \"id\",\n    user=\"root\",\n    text=True,\n    capture_output=True,\n)\n\nfor run in runs:\n    sys.stdout.write(run.stdout)\n```\n\nThe interface tries to mimic `subprocess.run` where possible, the fact that it can run a command on multiple hosts will always require details to be handle diffrently though.\n\n\n```\n$ python3 tues.py\nYour remote sudo password:\nuid=0(root) gid=0(root) groups=0(root)\nuid=0(root) gid=0(root) groups=0(root)\nuid=0(root) gid=0(root) groups=0(root)\n$\n```\n\nFor a detailed description of the `run` Arguments, please [check out the docstring](https://github.com/wontfix-org/tues/blob/master/tues/__init__.py#L800) for now, while I procastinate on creating proper docs. :-(\n\n## Providers\n\n### File\n\nThe `file` provider assumes all files passed on the commandline contain one host per line.\n\n### Commandline\n\nThe `cl` provider assumes all arguments passed on the commandline are hosts to connect to.\n\n### Foreman\n\nExecute on all hosts matching a certain foreman expression.\n\n```\nexport FOREMAN_URL=\"https://user:password@foreman.domain/\"\ntues \"ls\" fm \"class = my::class\"\n```\n\n### Custom Providers\n\nNew providers may be added by putting a new executable with a name like \"tues-provider-<name>\"\non your PATH. A provider is expected to return a newline seperated list of hosts.\n\nIf the provider returns with an error, the output is considered to be an error message and/or\nit's help output. If '--help' is passed through to the provider the output is displayed no matter\nwhat exit code is used.\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) 2014-2023, Michael van Bracht and contributors.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Easy remote command execution",
    "version": "3.1.1",
    "project_urls": {
        "homepage": "https://github.com/wontfix-org/tues/",
        "repository": "https://github.com/wontfix-org/tues/"
    },
    "split_keywords": [
        "ssh",
        " remote",
        " shell",
        " sudo"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e69ee8ba7103d11f4229cf2e8f7f1a5644df684c565e9dd34c3a8b9413e1db94",
                "md5": "bb7b320d49cb8938f5805b9ab8d4c6a5",
                "sha256": "17ee2aecbd2e394885bfaa7bd1d09189d7aa7e491df42908219e0858ac23a8fe"
            },
            "downloads": -1,
            "filename": "tues-3.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bb7b320d49cb8938f5805b9ab8d4c6a5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 21994,
            "upload_time": "2024-03-21T12:27:19",
            "upload_time_iso_8601": "2024-03-21T12:27:19.642964Z",
            "url": "https://files.pythonhosted.org/packages/e6/9e/e8ba7103d11f4229cf2e8f7f1a5644df684c565e9dd34c3a8b9413e1db94/tues-3.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fac4c996bfdb04d47119ef1434541bc19b8bfc580e57e014464f4d9502ca4330",
                "md5": "a773a8a759dc472093e0c487d1cb7b31",
                "sha256": "045ab0de56ddf1d22fcc07ee0cc122f5e3039f9e16bd99119b6f80d5c27269aa"
            },
            "downloads": -1,
            "filename": "tues-3.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a773a8a759dc472093e0c487d1cb7b31",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 25635,
            "upload_time": "2024-03-21T12:27:21",
            "upload_time_iso_8601": "2024-03-21T12:27:21.026236Z",
            "url": "https://files.pythonhosted.org/packages/fa/c4/c996bfdb04d47119ef1434541bc19b8bfc580e57e014464f4d9502ca4330/tues-3.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-21 12:27:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wontfix-org",
    "github_project": "tues",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "tox": true,
    "lcname": "tues"
}
        
Elapsed time: 0.21568s