A Cli tool for Grepsr Developers
Reason this release was yanked:
not master branch, but multiproc-server branch
Project description
A Cli tool for Grepsr Developers
Installation
$ pip install grepsr-cli
Usage
passing parameters to amazon_com
service.
gcli crawler test -s amazon_com -p '{"urls":["https://amazon.com/VVUH4HJ","https://amazon.com/FV4434"]}'
if JSON is complex, use file instead
# contents of /tmp/amazon_params.json
{"urls": ["https://amazon.com/VV%20UH4HJ"], "strip": ["'", "\"", "\\"]}
gcli crawler test -s amazon_com --params-file '/tmp/amazon_params.json'
Hacks Used.
If the json parameter has a space, it might break parameter parsing. If the json parameter has a dash
-
and any character after it has a space, it will break parameter parsing. Cause: no double quoting around $@ inrun_service.php:5:49
here This is fixed hackily by replacing string with its unicode \u0020 sequence. This works beacause $@ does not split on \u0020.
inject custom command.
Say, for example you wanted to a inject a php function so that it could be called from inside you service_code when testing locally.
Note: All these files should only be created inside ~/.grepsr/tmp
. Creating it outside will not work.
- Create a file called
inject.php
inside~/.grepsr/tmp/
- Implement your function inside
~/.grepsr/tmp/inject.php
function addRowLocal($arr) {
...
...
}
- Create a file called
inject.sh
inside~/.grepsr/tmp/
- inside inject.sh add:
alias php='php -d auto_prepend_file=/tmp/inject.php'
Note: the file location is /tmp/inject.php
instead of ~/.grepsr/tmp/inject.php
.
This is because, the local path ~/.grepsr/tmp
gets mapped to /tmp
in the docker container.
And inject.sh
runs inside docker, instead of the local filesystem.
5. Add an entry in ~/.grepst/config.yml
like so:
php:
...
sdk_image: ...
pre_entry_run_file: inject.sh # relative and limited to the tmp/ dir
- Now you can use
addRowLocal()
in your any of your files.
public function main($params) {
...
$arr = $this->dataSet->getEmptyRow();
addRowLocal($arr); // won't throw error
...
}
Development
Be sure to uninstall gcli first, with
pip uninstall grepsr-cli
git clone git@bitbucket.org:zznixt07/gcli.git grepsrcli
cd grepsrcli
pip install -e .
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file grepsr-cli-0.7.4.tar.gz
.
File metadata
- Download URL: grepsr-cli-0.7.4.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 05eca2a5787aa5285d07d15ad6486a7575be04a7a155fa9a9a5505f277c68c80 |
|
MD5 | 22ef446fd32898ebcf42ad5d114e7763 |
|
BLAKE2b-256 | e9a8b3c5511f74dafb2d4fae785c2599b5ddacba8eb80d28cfde217f7c66d952 |
File details
Details for the file grepsr_cli-0.7.4-py3-none-any.whl
.
File metadata
- Download URL: grepsr_cli-0.7.4-py3-none-any.whl
- Upload date:
- Size: 31.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ffcab0a0d1fbbd34cf74e12cc0afeadde7dd4c97d9bc02c8011139a15d3c29c0 |
|
MD5 | f4539e6322e053df0e026f1beeb6058b |
|
BLAKE2b-256 | a6380b4b23f2dba1152f478d614c95e6deeb98378126aafe04e265a75babf8f6 |