{ "info": { "author": "Alfredo Deza, Paulius Sukys", "author_email": "contact@deza.pe, paul.sukys@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: MacOS :: MacOS X", "Operating System :: POSIX", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.3", "Topic :: Utilities" ], "description": "remoto\n======\nA very simplistic remote-command-executor using ``ssh`` and Python in the\nremote end.\n\nAll the heavy lifting is done by execnet, while this minimal API provides the\nbare minimum to handle easy logging and connections from the remote end.\n\n``remoto`` is a bit opinionated as it was conceived to replace helpers and\nremote utilities for ``ceph-deploy`` a tool to run remote commands to configure\nand setup the distributed file system Ceph.\n\n\nExample Usage\n-------------\nThe usage aims to be extremely straightforward, with a very minimal set of\nhelpers and utilities for remote processes and logging output.\n\nThe most basic example will use the ``run`` helper to execute a command on the\nremote end. It does require a logging object, which needs to be one that, at\nthe very least, has both ``error`` and ``debug``. Those are called for\n``stderr`` and ``stdout`` respectively.\n\nThis is how it would look with a basic logger passed in::\n\n >>> import logging\n >>> logging.basicConfig(level=logging.DEBUG)\n >>> logger = logging.getLogger('hostname')\n >>> conn = remoto.Connection('hostname', logger=logger)\n >>> run(conn, ['ls', '-a'])\n INFO:hostname:Running command: ls -a\n DEBUG:hostname:.\n DEBUG:hostname:..\n DEBUG:hostname:.bash_history\n DEBUG:hostname:.bash_logout\n DEBUG:hostname:.bash_profile\n DEBUG:hostname:.bashrc\n DEBUG:hostname:.gem\n DEBUG:hostname:.lesshst\n DEBUG:hostname:.pki\n DEBUG:hostname:.puppet\n DEBUG:hostname:.ssh\n DEBUG:hostname:.vim\n DEBUG:hostname:.viminfo\n\nThe ``run`` helper will display the ``stderr`` and ``stdout`` as ``ERROR`` and\n``DEBUG`` respectively.\n\nFor other types of usage (like checking exit status codes, or raising upon\nthem) ``remoto`` does provide them too.\n\n\nRemote Commands\n===============\n\n``process.run``\n---------------\nCalling remote commands can be done in a few different ways. The most simple\none is with ``process.run``::\n\n >>> from remoto.process import run\n >>> from remoto import Connection\n >>> logger = logging.getLogger('myhost')\n >>> conn = Connection('myhost', logger=logger)\n >>> run(conn, ['whoami'])\n INFO:myhost:Running command: whoami\n DEBUG:myhost:root\n\nNote however, that you are not capturing results or information from the remote\nend. The intention here is only to be able to run a command and log its output.\nIt is a *fire and forget* call.\n\n\n``process.check``\n-----------------\nThis callable, allows the caller to deal with the ``stderr``, ``stdout`` and\nexit code. It returns it in a 3 item tuple::\n\n >>> from remoto.process import check\n >>> check(conn, ['ls', '/nonexistent/path'])\n ([], ['ls: cannot access /nonexistent/path: No such file or directory'], 2)\n\nNote that the ``stdout`` and ``stderr`` items are returned as lists with the ``\\n``\ncharacters removed.\n\nThis is useful if you need to process the information back locally, as opposed\nto just firing and forgetting (while logging, like ``process.run``).\n\n\nRemote Functions\n================\n\nTo execute remote functions (ideally) you would need to define them in a module\nand add the following to the end of that module::\n\n if __name__ == '__channelexec__':\n for item in channel:\n channel.send(eval(item))\n\n\nIf you had a function in a module named ``foo`` that looks like this::\n\n import os\n\n def listdir(path):\n return os.listdir(path)\n\nTo be able to execute that ``listdir`` function remotely you would need to pass\nthe module to the connection object and then call that function::\n\n >>> import foo\n >>> conn = Connection('hostname')\n >>> remote_foo = conn.import_module(foo)\n >>> remote_foo.listdir('.')\n ['.bash_logout',\n '.profile',\n '.veewee_version',\n '.lesshst',\n 'python',\n '.vbox_version',\n 'ceph',\n '.cache',\n '.ssh']\n\nNote that functions to be executed remotely **cannot** accept objects as\narguments, just normal Python data structures, like tuples, lists and\ndictionaries. Also safe to use are ints and strings.\n\n\nAutomatic detection for remote connections\n------------------------------------------\nThere is automatic detection for the need to connect remotely (via SSH) or not\nthat it is infered by the hostname of the current host (vs. the host that is\nconnecting to).\n\nIf the local host has the same as the remote hostname, a local connection (via\n`Popen`) will be opened and that will be used instead of `ssh`, and avoiding\nthe issues of being able to ssh into the same host.\n\nAutomatic detection for using `sudo`\n------------------------------------\nThis magical detection can be enabled by using the `detect_sudo` flag in the\n`Connection` class. It is disabled by default.\n\nWhen enabled, it will prefix any command with `sudo`. This is useful for\nlibraries that need super user permissions and want to avoid passing `sudo`\neverywhere, which can be non-trivial if dealing with `root` users that are\nconnecting via SSH.\n", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/psukys/remoto", "keywords": "remote", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "psukys-remoto", "package_url": "https://pypi.org/project/psukys-remoto/", "platform": "", "project_url": "https://pypi.org/project/psukys-remoto/", "project_urls": { "Homepage": "http://github.com/psukys/remoto" }, "release_url": "https://pypi.org/project/psukys-remoto/0.0.31/", "requires_dist": null, "requires_python": "", "summary": "Execute remote commands or processes. Fork with changes to allow continuous output for remote functions", "version": "0.0.31" }, "last_serial": 3847996, "releases": { "0.0.30": [ { "comment_text": "", "digests": { "md5": "53471bccef8bf0c53b7cc823dcdd1067", "sha256": "bcda0f49f89afec3006999adfa957b401cfae972bcfb44f443fe8becf83f84fa" }, "downloads": -1, "filename": "psukys-remoto-0.0.30.tar.gz", "has_sig": false, "md5_digest": "53471bccef8bf0c53b7cc823dcdd1067", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13645, "upload_time": "2018-05-03T09:41:45", "url": "https://files.pythonhosted.org/packages/fe/03/28e05c9e1e8288d715b55b99fe3162b4991e89b6122390bad0238fa46d39/psukys-remoto-0.0.30.tar.gz" } ], "0.0.31": [ { "comment_text": "", "digests": { "md5": "f43c21466102111e42e241ae618c7746", "sha256": "eb40b137c34079c49e68b89973f990b0f598d3afabde86bc70a051eb8fe96773" }, "downloads": -1, "filename": "psukys-remoto-0.0.31.tar.gz", "has_sig": false, "md5_digest": "f43c21466102111e42e241ae618c7746", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13633, "upload_time": "2018-05-09T16:12:58", "url": "https://files.pythonhosted.org/packages/48/40/8955a7e80eb5f5d12439d386e634f82ad9dcaf2337b20ebb63413daa808e/psukys-remoto-0.0.31.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f43c21466102111e42e241ae618c7746", "sha256": "eb40b137c34079c49e68b89973f990b0f598d3afabde86bc70a051eb8fe96773" }, "downloads": -1, "filename": "psukys-remoto-0.0.31.tar.gz", "has_sig": false, "md5_digest": "f43c21466102111e42e241ae618c7746", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13633, "upload_time": "2018-05-09T16:12:58", "url": "https://files.pythonhosted.org/packages/48/40/8955a7e80eb5f5d12439d386e634f82ad9dcaf2337b20ebb63413daa808e/psukys-remoto-0.0.31.tar.gz" } ] }