{ "info": { "author": "", "author_email": "", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License" ], "description": "Generate and Send Data\n============================\n\n## About\n\nSimple cli to send and retrieve data, kind of rough around the edges but it does provide a quick way to emulate random log messages to miscellaneous tcp/udp endpoints such as logstash or rsyslog.\n\n\n## IMPORTANT :: Security\nThe way gensend provides hooks to generate data makes it very unsafe to provide a generic interface to allow arbitrary input from untrusted sources. Don't do that, please.\n\n\n## Syntax\nSyntax is simple, each `pattern` is a string. You may use expressions anywhere within the string in the form of `%{api_call_name}` providing arguments is possible using `%{api_call_name:arg1,arg2}`.\n\nFor sending data use `gensend send` with the last argument expected to be a destination in the form of `scheme://netloc/path;parameters?query#fragment`. Currently only raw tcp/udp supported i.e.: tcp://127.0.0.1:8000, udp://127.0.0.1:8000.\n\n#### Why?\nThe pattern syntax was inspired from grok patterns, since that is what I was going to be modeling most the data I generated around. I found a couple cases where I wanted to nest an expression so I added support for that. I don't think I'll be adding much more because it might make more sense to just use python `ast` package and require actual python syntax and walk that, or use jinja2 templating with some wrappers for data providers if it gets much more complicated as the parser is an afternoon hack.\n\n\n## API\nAll of the api calls available in Faker for python at http://www.joke2k.net/faker/ are available as expressions %{faker_name} as well as some additional ones. Feel free to dig through gensend/providers/common for some additional functions.\n\nYou may also extend it using a providers file using the -l flag, gensend will exec the file (I know.. I know.., it's pretty convenient though) and slurp in anything that is a \"ProviderList\". Example file myproviders.py:\n\n ```python\n from gensend.providers import ProviderList, Provider\n\n\n class MyFirstProvider(Provider):\n def myhellofunc(self, *args):\n return 'myhellofunc'\n\n\n class MySecondProvider(Provider):\n def secondfunc(self, *args):\n return 'secondfunc: ' + str(args)\n\n\n MyProviderList = ProviderList([MyFirstProvider(), MySecondProvider()])\n ```\n\nNow you may call them from patterns:\n\n ```\n $ gensend --number 5 -l myproviders.py gen 'Func1: \"%{myhellofunc}\" Func2: \"%{secondfunc:foo,bar}'\n Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n ```\n\n\n## Examples\n\nBasic usage:\n\n ```\n $ gensend gen 'My name is %{name}. Hello.'\n My name is Sarita Ferry. Hello.\n ```\n\nRepeat output with `--number N` flag:\n\n ```\n $ gensend --number 5 gen 'My name is %{name}. Hello.'\n My name is Dwight Wisozk. Hello.\n My name is Jamil Abshire. Hello.\n My name is Helga Grant. Hello.\n My name is Ms. Jessie Abshire. Hello.\n My name is Zelma Ledner DVM. Hello.\n ```\n\nFormat the output in json with `--format, -f FMT` flag:\n\n ```\n $ gensend -f json --number 5 gen 'My name is %{name}. Hello.'\n [\n \"My name is Delos Rodriguez. Hello.\",\n \"My name is Roy White. Hello.\",\n \"My name is Mr. Montel O'Connell Sr.. Hello.\",\n \"My name is Zaniyah Hand. Hello.\",\n \"My name is Wyatt Beier. Hello.\"\n ]\n ```\n\nNested expressions:\n\n ```\n $ gensend --number 5 gen 'My choice is \"%{choice:%{address},%{name},%{ipv4},%{name}}\"'\n My choice is \"Evelena Predovic DDS\"\n My choice is \"Dr. Christoper Feeney\"\n My choice is \"28.139.1.107\"\n My choice is \"59303 Nobie Roads\n New Makailabury, MI 90325\"\n My choice is \"020 Rath Loop\n Kuhlmanside, SC 49924\"\n ```\n\nSend your data somewhere:\n\n ```\n $ netcat -t -v -l -p 50000|awk '{print \"[TCP] \" $0}'&\n [1] 90965\n $ gensend --number 5 -l myproviders.py send 'Func1: \"%{myhellofunc}\" Func2: \"%{secondfunc:foo,bar}%{LF}' 'tcp://127.0.0.1:50000'\n Connection from 127.0.0.1:55490\n Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n\n [TCP] Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n\n [TCP] Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n\n [TCP] Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n\n [TCP] Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n\n [TCP] Func1: \"myhellofunc\" Func2: \"secondfunc: ('foo', 'bar')\n [1]+ Done netcat -t -v -l -p 50000 | awk '{print \"[TCP] \" $0}'\n ```\n\n\n## Help Text\n\n```\nusage: gensend [-h] [--load-providers PROVIDERS] [--patterns PATTERNS]\n [--format FORMAT] [--debug] [--number NUMBER] [--persistent]\n [--noseed | --seed SEED]\n {info,gen,send} ...\n\noptional arguments:\n -h, --help show this help message and exit\n --load-providers PROVIDERS, -l PROVIDERS\n an optional file path or importable module name that\n may be included and added to the list of default\n providers.\n --patterns PATTERNS, -p PATTERNS\n optional file containing pattern strings separated by\n new lines when .txt, or a json array of patterns when\n .json\n --format FORMAT, -f FORMAT\n format for output data, one of txt, json or csv\n default: txt\n --debug, -d debug flag for additional troubleshooting information\n --number NUMBER number of times to generate pattern, default: 1\n --persistent when sending multiple message keep the connection\n open. note when using this option you should terminate\n your pattern if needed. default: true\n --noseed do not seed the pseudo-random number generator to\n produce non-deterministic data\n --seed SEED seed the pseudo-random number generator, default: 1\n\ncommands:\n {info,gen,send}\n gen ex: gensend gen pattern1 ... patternN\n send ex: gensend send pattern1 ... patternN\n scheme://netloc/path;parameters?query#fragment\n```\n\n\n## Installation\n\nWith Pip:\n\n ```\n $ pip install https://github.com/cstockton/py-gensend.git\n ```\n\n\nManual Install:\n\n ```\n $ cd /tmp\n $ git clone https://github.com/cstockton/py-gensend.git\n $ cd ./py-gensend\n $ make install\n ```\n\n\nDev Install:\n\n ```\n $ cd /tmp\n $ git clone https://github.com/cstockton/py-gensend.git\n $ make build && make test\n ```\n", "description_content_type": null, "docs_url": null, "download_url": "https://github.com/cstockton/py-gensend/archive/master.zip", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/cstockton/py-gensend", "keywords": "generate, fake, data, send, tcp, udp, logstash, testing", "license": "", "maintainer": "", "maintainer_email": "", "name": "gensend", "package_url": "https://pypi.org/project/gensend/", "platform": "", "project_url": "https://pypi.org/project/gensend/", "project_urls": { "Download": "https://github.com/cstockton/py-gensend/archive/master.zip", "Homepage": "https://github.com/cstockton/py-gensend" }, "release_url": "https://pypi.org/project/gensend/0.0.1/", "requires_dist": null, "requires_python": null, "summary": "", "version": "0.0.1" }, "last_serial": 1804610, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "49127f1980f259ae021c5cbb32325944", "sha256": "7f1f8a36e1c62901dec1b4952c4c980669aa3c25d1b9cc32138057053994a644" }, "downloads": -1, "filename": "gensend-0.0.1.tar.gz", "has_sig": false, "md5_digest": "49127f1980f259ae021c5cbb32325944", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13332, "upload_time": "2015-11-06T15:17:33", "url": "https://files.pythonhosted.org/packages/2a/ae/84b69d64ca8275f1c21c4073d460530e6a0fe431a017aae2a328261e172a/gensend-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "49127f1980f259ae021c5cbb32325944", "sha256": "7f1f8a36e1c62901dec1b4952c4c980669aa3c25d1b9cc32138057053994a644" }, "downloads": -1, "filename": "gensend-0.0.1.tar.gz", "has_sig": false, "md5_digest": "49127f1980f259ae021c5cbb32325944", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13332, "upload_time": "2015-11-06T15:17:33", "url": "https://files.pythonhosted.org/packages/2a/ae/84b69d64ca8275f1c21c4073d460530e6a0fe431a017aae2a328261e172a/gensend-0.0.1.tar.gz" } ] }