Skip to main content

do automate things on Linux

Project description

auto_everything

Linux(mainly ubuntu) automation

Donation

Installation

sudo pip3 install auto_everything

or

wget https://github.com/yingshaoxo/auto_everything/raw/master/env_setup.sh
sudo bash env_setup.sh

Magic

wget https://github.com/yingshaoxo/auto_everything/raw/master/demo/install_YouCompleteMe.py
python3 install_YouCompleteMe.py

Docs

https://yingshaoxo.github.io/auto_everything


Basic API

Import

from auto_everything.base import Terminal
t = Terminal()

Run a command and get reply

reply = t.run_command('uname -a')
print(reply)

Run commands and get direct screen output

commands = """
sudo apt update
uname -a
"""
t.run(commands)

Run a program

t.run_program('firefox')

Run a python script

t.run_py('your_file.py')

Run a bash script

t.run_sh('your_file.sh')

Detect if a program or script is running

status = t.is_running('terminal')
print(status)

Kill it

t.kill('terminal')

For simplify Python development

Import

from auto_everything.base import Python
py = Python()

Turn Python Class into a Command Line Program

py.fire(your_class_name)

Make it global executable:

py.make_it_global_runnable(executable_name="Tools")

Example

Let's assume you have a file named Tools.py:

from auto_everything.base import Python
py = Python()

class Tools():
    def push(self, comment):
        t.run('git add .')
        t.run('git commit -m "{}"'.format(comment))
        t.run('git push origin')

    def pull(self):
        t.run("""
git fetch --all
git reset --hard origin/master
""")

    def undo(self):
        t.run("""
git reset --mixed HEAD~1
""")

    def reset(self):
        t.run("""
git reset --hard HEAD^
""")

    def hi(self):
        print("Hi, Python!")

py.fire(Tools)
py.make_it_global_runnable(executable_name="MyTools")

After the first running of this script by python3 Tools.py hi, you would be able to use MyTools to run this script at anywhere within your machine:

yingshaoxo@pop-os:~$ MyTools hi
Hi, Python!

Others

Web automation

from auto_everything.web import Selenium
from time import sleep

my_selenium = Selenium("https://www.google.com", headless=False)
d = my_selenium.driver

# get input box
xpath = '//*[@id="lst-ib"]'
elements = my_selenium.wait_until_exists(xpath)

# text inputing
elements[0].send_keys('\b' * 20, "yingshaoxo")

# click search button
elements = my_selenium.wait_until_exists('//input[@value="Google Search"]')
if len(elements):
    elements[0].click() # d.execute_script("arguments[0].click();", elements[0])

# exit
sleep(30)
d.quit()

Simpler IO

from auto_everything.base import IO
io = IO()

io.write("hi.txt", "Hello, world!")
print(io.read("hi.txt"))

io.append("hi.txt", "\n\nI'm yingshaoxo.")
print(io.read("hi.txt"))

Quick File Operation

from auto_everything.disk import Disk
from pprint import pprint
disk = Disk()

files = disk.get_files(".")
files = disk.sort_files_by_time(files)
pprint(files)

Easy Store

from auto_everything.disk import Store
store = Store("test")

store.set("author", "yingshaoxo")
store.set("author", {"email": "yingshaoxo@gmail.com", "name": "yingshaoxo"})
print(store.get_items())

print(store.has_key("author"))
print(store.get("author", ""))
print(store.get("whatever", default_value="alsjdasdfasdfsakfla"))

store.reset()
print(store.get_items())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

auto_everything-3.8.tar.gz (33.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

auto_everything-3.8-py3-none-any.whl (43.1 kB view details)

Uploaded Python 3

File details

Details for the file auto_everything-3.8.tar.gz.

File metadata

  • Download URL: auto_everything-3.8.tar.gz
  • Upload date:
  • Size: 33.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.8.0 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for auto_everything-3.8.tar.gz
Algorithm Hash digest
SHA256 ef9c2d47417e5587fe4c6bff051bb9ee53c6970eee281e27849fa3550ce52c30
MD5 bd18d0b39b64030d0dde32f523c590cd
BLAKE2b-256 55946d533c6710f10fbaf86108833bb72d58a04bfbb1985189bc544d6d89f743

See more details on using hashes here.

File details

Details for the file auto_everything-3.8-py3-none-any.whl.

File metadata

  • Download URL: auto_everything-3.8-py3-none-any.whl
  • Upload date:
  • Size: 43.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.8.0 tqdm/4.50.2 CPython/3.8.5

File hashes

Hashes for auto_everything-3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f4b96814963884ae5e343369e2ed1a6d343046bb7faab6d2d7ca4c1c30599622
MD5 0510cd3292ff40ba75662265e5293726
BLAKE2b-256 cc41efcfa571f8add9be49b17efc34f7eec6e9add17068ed0b8b41e6e514c998

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page