Skip to main content

Terminal buddies to store and run python snippets

Project description

pypals: it really does nothing!
pypals
Turn python snippets into command line buddies!

Keeps your python scripts and snippets as command line pals.

PyPI version

Downloads

installation

Get the package from pypi i.e.

$ python3 -m pip install pypals

usage

Sometimes you write code maybe to do some random job or snippet, scrape something, send a tweet, whatever.

It's useful to keep those bits of odd code somewhere. pypals are easy to remember ages later.

$ python3 -m pypals sportsfan
$ sportsfan doesn't exist, create them now? yes or no
$ > yes
$ your name?
$ > mike
$ Hi my name is sportsfan, Thankyou for creating me!
$ I am listening...

sportsfan has been created for you in a /pypals directory. He can gather data about sports using any python commands you write and put in that folder

now try running this command...

$ hello

now look in pypals/sportsfan/hello/hello.py file to see an example of a command. Add as many commands as you like for your project.

To create commands try typing 'scrape somesite for images' at the prompt.

You will see it creates it for you. You can now just edit the file created and fill it in with your code.

Next try typing 'quit'

If you're editing a python command you don't need to restart pypal. It will reload the command. so just type 'r' to rerun it at the prompt.

  • parameters pass any words after your command it will pick them up as parameters.

when creating a command it will ask you what to type as a response, you can put any string. however if you try instead typing:

{args}

Now run your command and type some extra words after it. cool huh.

  • TODO - explain commands between bots / sharing commands you can import pypals into other pypals and share commands between them.

  • TODO - notes on logging. now off by default.

self.owner.nlg.log("command detected")

You can also call or execute any commands you created directly from the command line. i.e.

python3 -m pypals sportsfan hello

help

pypals has recently been updated to have a cli help system.

the following command might be useful...

--help $ python3 -m pypals -h

a list of all commands

--version $ python3 -m pypals -v

the version of pypals you are using.

--list $ python3 -m pypals -l

shows a list of all your pypals

more

cron notes

put in sometask.sh file chmod +x the file.

echo "do some job batch 1" | nohup python3 -m pypals jobs >/dev/null 2>&1 &
  • you may want those to self terminate *see 'quit'

makefile notes

something like this in your makefile to boot one or more faster

pypal:
	cd /home/ubuntu/Desktop/someapp/automate/; \
	python3 -m pypals myscraper somefunc

If you run several pypals simoultaneously you can trash them all easy by putting this in your makefile:

killall:
	pkill -9 python

documentation

  • note : you can't use package names for commands. i.e. builtins, test
  • note : use task manager to montior bots

the base path to a command is available if loading writing files to same folder:

o.context.COMMAND_PATH

shortcuts

while a pypal is running you can pass it the following commands as shortcuts

r - re-run previous command. (i.e. after editing the python file) h - history q - quit

Notes

https://medium.com/@joel.barmettler/how-to-upload-your-python-package-to-pypi-65edc5fe9c56

about

pypals was my first every python project written in python2 in about 2012. It is a useful way to organise code snippets and do research. In 2019 I ported it to python 3 while learning to make pip packages.

please use it responsibly and if you want to contribute, fork it and send me a pull request.

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

pypals-1.0.0.tar.gz (14.2 kB view details)

Uploaded Source

Built Distribution

pypals-1.0.0-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

Details for the file pypals-1.0.0.tar.gz.

File metadata

  • Download URL: pypals-1.0.0.tar.gz
  • Upload date:
  • Size: 14.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for pypals-1.0.0.tar.gz
Algorithm Hash digest
SHA256 08f980beb97d1a438f5a1e05163cab8f040b766db09b1925dde99572e1a6f11e
MD5 93eb75b4b6eea3a3c2e0687a235d16c2
BLAKE2b-256 0c85cce77cf99f9e3d3ede3c2aaac63c5e923389b86fbe78237728791c7e4dd5

See more details on using hashes here.

File details

Details for the file pypals-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: pypals-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for pypals-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 54c16f39c2ffcda086dc3eaf5575b72c776719a5b9e517b19c34246232116ca8
MD5 09512b2caee80182e011eb2da909f483
BLAKE2b-256 2bce428efa084f6e3e67cf323183cdd6608eabe71553d0e22ba04e5888856893

See more details on using hashes here.

Supported by

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