![WebScripts Logo](https://mauricelambert.github.io/info/python/code/WebScripts/small_logo.png "WebScripts logo")
# WebScriptsTools
## Description
This package implements tools for WebScripts Scripts.
## Requirements
This package require:
- python3
- python3 Standard Library
## Installation
```bash
pip install WebScriptsTools
```
## Usages
### Command line
#### Module
```bash
# These command lines should be launch in a WebScripts Scripts Environment !
python3 -m WebScriptsTools
python3 -m WebScriptsTools get_log_file
python3 -m WebScriptsTools get_upload_script
python3 -m WebScriptsTools get_webscripts_data_path
```
If you run these command lines outside the WebScripts scripting environment, you get this error:
```text
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
```
Example of usage in a script bash:
```bash
logfile=$(python3 -m WebScriptsTools get_log_file)
echo "DEBUG: Get log file from WebScriptsTools" > "${logfile}"
cat "$(python3 -m WebScriptsTools get_webscripts_data_path)/datafile.txt"
echo "INFO: print data using WebScripts data directory" > "${logfile}"
cat myfile.txt | "$(python3 -m WebScriptsTools get_upload_script)" uploaded_filename.txt
cat myfile.txt | "$(python3 -m WebScriptsTools get_upload_script)" -r 1000 -w 1000 -d 1000 -H -b -c -i uploaded_filename.txt
```
### Python script
```python
# To use this module you should be in a WebScripts Scripts Environment
from WebScriptsTools import *
set_excepthook() # manage exceptions without printing sensible informations
# Get the upload module, to read, delete or write a shared file
upload = get_upload_module()
upload.get_file("my_webscripts_shared_file.txt")
# Use the data path to change databases
with open(f"{get_webscripts_data_path()}/datafile.txt") as datafile:
print(datafile.read())
# Get the log file to configure your logger or read your logs
logs = open(get_log_file())
log = logs.readline()
while log:
print(log)
log = logs.readline()
# Get the user to check permission or get informations like ID or name
user = get_user()
print(f"You are named '{user['name']}' here !")
class ClassModule:
@module2to3
def method(
self,
environ,
user,
configuration,
filename,
commande,
inputs,
csrf_token: str = None,
) -> Tuple[str, Dict[str, str], bytes]:
return "200 OK", {}, b'data'
@module2to3
def function(
environ,
user,
configuration,
filename,
commande,
inputs,
csrf_token: str = None,
) -> Tuple[str, Dict[str, str], bytes]:
return "200 OK", {}, b'data'
```
## Links
- [Github Page](https://github.com/mauricelambert/WebScriptsTools/)
- [Documentation](https://mauricelambert.github.io/info/python/code/WebScriptsTools.html)
- [Pypi package](https://pypi.org/project/WebScriptsTools/)
## Licence
Licensed under the [GPL, version 3](https://www.gnu.org/licenses/).
Raw data
{
"_id": null,
"home_page": "https://github.com/mauricelambert/WebScriptsTools",
"name": "WebScriptsTools",
"maintainer": "Maurice Lambert",
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": "mauricelambert434@gmail.com",
"keywords": "WebScripts,Tools",
"author": "Maurice Lambert",
"author_email": "mauricelambert434@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/48/ed/4e2c45f7d7bb02da778d04ea94a295ab016b8bfdda3db08c7566cba8cc75/WebScriptsTools-0.1.0.tar.gz",
"platform": "Windows",
"description": "![WebScripts Logo](https://mauricelambert.github.io/info/python/code/WebScripts/small_logo.png \"WebScripts logo\")\n\n# WebScriptsTools\n\n## Description\n\nThis package implements tools for WebScripts Scripts.\n\n## Requirements\n\nThis package require:\n\n - python3\n - python3 Standard Library\n\n## Installation\n\n```bash\npip install WebScriptsTools\n```\n\n## Usages\n\n### Command line\n\n#### Module\n\n```bash\n# These command lines should be launch in a WebScripts Scripts Environment !\n\npython3 -m WebScriptsTools\npython3 -m WebScriptsTools get_log_file\npython3 -m WebScriptsTools get_upload_script\npython3 -m WebScriptsTools get_webscripts_data_path\n```\n\nIf you run these command lines outside the WebScripts scripting environment, you get this error:\n```text\nTypeError: the JSON object must be str, bytes or bytearray, not NoneType\n```\n\nExample of usage in a script bash:\n```bash\nlogfile=$(python3 -m WebScriptsTools get_log_file)\necho \"DEBUG: Get log file from WebScriptsTools\" > \"${logfile}\"\ncat \"$(python3 -m WebScriptsTools get_webscripts_data_path)/datafile.txt\"\necho \"INFO: print data using WebScripts data directory\" > \"${logfile}\"\ncat myfile.txt | \"$(python3 -m WebScriptsTools get_upload_script)\" uploaded_filename.txt\ncat myfile.txt | \"$(python3 -m WebScriptsTools get_upload_script)\" -r 1000 -w 1000 -d 1000 -H -b -c -i uploaded_filename.txt\n```\n\n### Python script\n\n```python\n# To use this module you should be in a WebScripts Scripts Environment\n\nfrom WebScriptsTools import *\n\nset_excepthook() # manage exceptions without printing sensible informations\n\n# Get the upload module, to read, delete or write a shared file\nupload = get_upload_module()\nupload.get_file(\"my_webscripts_shared_file.txt\")\n\n# Use the data path to change databases\nwith open(f\"{get_webscripts_data_path()}/datafile.txt\") as datafile:\n print(datafile.read())\n\n# Get the log file to configure your logger or read your logs\nlogs = open(get_log_file())\nlog = logs.readline()\nwhile log:\n print(log)\n log = logs.readline()\n\n# Get the user to check permission or get informations like ID or name\nuser = get_user()\nprint(f\"You are named '{user['name']}' here !\")\n\nclass ClassModule:\n @module2to3\n def method(\n self,\n environ,\n user,\n configuration,\n filename,\n commande,\n inputs,\n csrf_token: str = None,\n ) -> Tuple[str, Dict[str, str], bytes]:\n return \"200 OK\", {}, b'data'\n\n@module2to3\ndef function(\n environ,\n user,\n configuration,\n filename,\n commande,\n inputs,\n csrf_token: str = None,\n) -> Tuple[str, Dict[str, str], bytes]:\n return \"200 OK\", {}, b'data'\n```\n\n## Links\n\n - [Github Page](https://github.com/mauricelambert/WebScriptsTools/)\n - [Documentation](https://mauricelambert.github.io/info/python/code/WebScriptsTools.html)\n - [Pypi package](https://pypi.org/project/WebScriptsTools/)\n\n## Licence\n\nLicensed under the [GPL, version 3](https://www.gnu.org/licenses/).\n",
"bugtrack_url": null,
"license": "GPL-3.0 License",
"summary": "This package implements tools for WebScripts Scripts.",
"version": "0.1.0",
"project_urls": {
"Documentation": "https://mauricelambert.github.io/info/python/code/WebScriptsTools.html",
"Homepage": "https://github.com/mauricelambert/WebScriptsTools"
},
"split_keywords": [
"webscripts",
"tools"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "48ed4e2c45f7d7bb02da778d04ea94a295ab016b8bfdda3db08c7566cba8cc75",
"md5": "08c24ea3071757a3c991c700ffdf8e91",
"sha256": "0532f8c5dd93563923527087c6591c2e5d21c1043e4ed7c24024694e80663fc0"
},
"downloads": -1,
"filename": "WebScriptsTools-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "08c24ea3071757a3c991c700ffdf8e91",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 18157,
"upload_time": "2023-10-27T20:12:30",
"upload_time_iso_8601": "2023-10-27T20:12:30.225641Z",
"url": "https://files.pythonhosted.org/packages/48/ed/4e2c45f7d7bb02da778d04ea94a295ab016b8bfdda3db08c7566cba8cc75/WebScriptsTools-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-27 20:12:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mauricelambert",
"github_project": "WebScriptsTools",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "webscriptstools"
}