{"id":22298851,"url":"https://github.com/ailisp/python-rc","last_synced_at":"2025-06-15T02:32:48.629Z","repository":{"id":50180938,"uuid":"220399340","full_name":"ailisp/python-rc","owner":"ailisp","description":"a python remote control library","archived":false,"fork":false,"pushed_at":"2021-06-02T00:45:22.000Z","size":165,"stargazers_count":1,"open_issues_count":6,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-05T20:49:38.660Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ailisp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-08T06:14:15.000Z","updated_at":"2020-05-28T18:23:23.000Z","dependencies_parsed_at":"2022-09-03T00:00:16.690Z","dependency_job_id":null,"html_url":"https://github.com/ailisp/python-rc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ailisp/python-rc","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ailisp%2Fpython-rc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ailisp%2Fpython-rc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ailisp%2Fpython-rc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ailisp%2Fpython-rc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ailisp","download_url":"https://codeload.github.com/ailisp/python-rc/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ailisp%2Fpython-rc/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259912480,"owners_count":22931072,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-03T18:02:16.453Z","updated_at":"2025-06-15T02:32:48.605Z","avatar_url":"https://github.com/ailisp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# python-rc\n[![PyPI version](https://badge.fury.io/py/python-rc.svg)](https://pypi.org/project/python-rc/)\n\nPython remote control library for programmatically control remote machines of mutliple cloud providers. Currently support gcloud, azure and digitalocean.\n\n## Usage\npython-rc consists of python-rc lib and python-rc cli.\n\n### python-rc cli\n```\nrc \u003cgroup name\u003e command ...: execute command non interactively in group of machines\nrc \u003cgroup name\u003e/name_pattern1,... command ...: execute command non interactively in group of machines, but only subset that match pattern \nrc \u003cgroup name\u003e @file: execute content of local file in group of machines\nrc tmux \u003cgroup name\u003e: launch a tmux that ssh to every instance in group of machines, input to one machine will be replicate to the group\nrc edit \u003cgroup name\u003e: create or edit machines in group\nrc cat \u003cgroup name\u003e: show machines in group\nrc ls: show defined groups\nrc rm \u003cgroup name\u003e: delete group definition (does not delete machines)\nrc rsync: parallel rsync\nrc ssh-config: generate ~/.ssh/config that can be used with ssh machine_name, scp, rsync, mosh, etc.\n```\nIn python-rc tmux, you can use `C-b a` to toggle input to all machines and input into single machine.\n\n### python-rc lib\nImport one of provider module: gcloud, digitalocean and azure to get or create a machine. Use machine methods to execute shell commands, execute background task, edit file, etc on the machine. Example:\n```\nfrom rc import gcloud\nm = gcloud.get('instance1')\n# run a single line command\np = m.run('ls')\nprint(p.stdout)\n\n# run a multiline command\nm.bash('''\ncd workspace/proj\nmake -j 4\n''')\n\n# run a muliline commands as root\nm.sudo('''\napt update\napt install -y jq\n''')\n\n# edit a file, as user `ubuntu`:\nm.edit('~/a.txt', '''\nfile line1\nfile line2\n''', user='ubuntu')\n\n# run a server process in background\nm.run_bg('''\ncd workspace/someserver\nnpm i\nnpm run\n''')\n\n# run a python snippet on a server\np = m.python('''\nimport json\nj = json.load(open('foo.json'))\nprint(j['key'])\n''')\n\n# Useful utility example:\n# parallel run tasks on each machine\nfrom rc import pmap\ndef task(machine, script_path):\n    machine.bootup()\n    machine.upload(f'~/local/path/{script_path}', f'~/remote/path/script_path}')\n    machine.run(f'bash remote/path/{script_path}')\n\npmap(lambda i: task(machines[i], tasks[i]), range(n))\n```\n\n## Documentation\nTODO. See `rc/test/` for example usages for now\n\n## Test\nTo run gcloud part test, `gcloud` cli needs to be installed and logged in.\n```\npipenv sync -d\npipenv run pytest -s\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Failisp%2Fpython-rc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Failisp%2Fpython-rc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Failisp%2Fpython-rc/lists"}