Welcome to PWBS’s documentation!¶
Indices and tables¶
PAiP Web Build System¶
Documented Version : v.0.4.0-dev0¶
PWBS is Build System for easy automation process. This project makes one command for all what you can’t remember or it’s just too long to rewrite all over every time.
- PyPi Package: https://pypi.org/project/pwbs/
Features¶
- Single Tasks -
pwbs task
executes one command - NOT_IMPLEMENTED: Multi Tasks -
pwbs task
executes other tasks - MultiCommand Tasks -
pwbs task
executes multiple commands - NOT_IMPLEMENTED: Watcher Tasks -
pwbs task
starting watcher which watching specified files for changes and executing specified commands on file modification - NOT_IMPLEMENTED: Scheduler Tasks -
pwbs task
starting scheduler which executing commands on specified schedule - NOT_IMPLEMENTED: Argumented Tasks -
pwbs task "Hello World"
starting specified commands and/or tasks with special argument (This task have to be used alone in execution of pwbs)
Credits¶
Development Lead¶
- Patryk Adamczyk <patrykadamczyk@patrykadamczyk.net>
Contributors¶
None yet. Why not be the first?
PWBS CLI Usage¶
Quickstart¶
Install Python 3 [>3.5]
Install PWBS [
pip install pwbs
ORpip3 install pwbs
(Platform Depending)]Go to your project where you want to use pwbs
Create
pwbs.json
file [FUTURE:pwbs --new-config
]Create in that file that structure:
{ "commands" : { } }
Add your tasks to
pwbs.json
file [Just add normal json key:value pair where key is taskname and value is command]Run you tasks
pwbs <task>
Full CLI Usage Documentation¶
Special Tasks¶
-
-v
{0,1,2,3,255}
,
--verbose
{0,1,2,3,255}
¶ Changing Verbosity
- No Information about running
- Normal Information about running [Default Level]
- More Information about running
- More Information about running and work behind the scenes
- Debug Verbosity Mode
-
--debug
¶
Debug Mode
Debug Mode is turned off by default.
-
--version
¶
Showing Version of PWBS
-
--new-config
¶
[FUTURE:]
Creating Blank Configuration File from basic template
-
-l
,
--log
¶
Enabling Active Logging
-
-lf
LOGFILE
,
--logfile
LOGFILE
,
--log-file
LOGFILE
¶ Specifying Log File
Default Log File: ./pwbs.log
-
-c
CONFIGFILE
,
--configfile
CONFIGFILE
,
--config-file
CONFIGFILE
¶ Specifying Configuration File
Default Configuration File: ./pwbs.json
-
--test-mode
¶
Enabling Test Mode
What it doing behind the scenes? Changing Verbosity to: 255. Changing to Debug Mode.
-
--run-tests
¶
Starting PWBS Test Runner
PWBS Installation Guide¶
Stable Release from PyPi¶
Install Python>3.6 from here Python Downloads Website (if it’s not already installed)
Install PWBS
Windows
In CMD or other Command Line Interpreter execute:
pip install pwbs
Linux and others
In Command Line execute:
pip3 install pwbs
Latest Development Release¶
Install Python>3.6 from here Python Downloads Website (if it’s not already installed)
Install Git (if it’s not already installed)
In CMD or other Command Line Interpreter execute:
git clone https://gitlab.com/paip-web/pwbs.git
cd pwbs
pip install -e .
or linux:pip3 install -e .
pwbs.json Configuration File¶
Tasks¶
Single Task¶
Reimplemented in v.0.4.0dev0
Description
Maps task name to one command.
When you run this task you execute exactly one command which specified.
Example pwbs.json
{
"commands" : {
"task" : "command"
}
}
Example Description
task - Task Name
command - Command which you want to run when you run this task
MultiCommand Task¶
Reimplemented in v.0.4.0dev0
Description
Maps task name to commands.
When you run this task you execute all commands which you specified you want to run with this task.
Example pwbs.json
{
"commands" : {
"task" : {
"mode" : "mc",
"commands" : [
"command1",
"command2"
]
}
}
}
Example Description
task - Task Name
command1, command2 - Command which you want to run when you run this task [For sure you can to specify more than 2]
Multi Task¶
Not implemented in v.0.4.0dev0
Description
Maps task name to other tasks.
When you run this task you execute commands from the tasks you specified.
Example pwbs.json
{
"commands" : {
"task" : [
"task1",
"task2"
]
}
}
Example Description
task - Task Name
task1, task2 - Tasks which you want to run when you run this task [For sure you can to specify more than 2]
Watcher¶
Not implemented in v.0.4.0dev0
Description
Maps task name to watcher task.
When you run this task it waits (or execute commands and waits) for changes in specified directories and after change it executes commands.
Example pwbs.json
{
"commands" : {
"task-1" : {
"mode" : "wc0",
"context" : [
"path/to/watch/*"
],
"commands" : [
"command1"
]
},
"task-2" : {
"mode" : "wc",
"context" : [
"path/to/watch/*"
],
"commands" : [
"command1"
]
}
}
}
Example Description
task-1 is example of the Run, Execute, Watch Task
task-2 is example of the Run, Watch Task
task-1, task-2 - Task Name
path/to/watch/* - Path you want to watch [You can specify more than one]
command1 - Commands you want to execute when context is changed
Scheduler¶
Not implemented in v.0.4.0dev0
Description
Maps task name to scheduler task.
When you run this task it waits (or execute commands and waits) until every specified time.
Example pwbs.json
{
"commands" : {
"task-1" : {
"mode" : "sc0",
"context" : 00000000000,
"commands" : [
"command1"
]
},
"task-2" : {
"mode" : "sc",
"context" : 00000000000,
"commands" : [
"command1"
]
}
}
}
Example Description
task-1 is example of the Run, Execute, Wait Task
task-2 is example of the Run, Wait Task
task-1, task-2 - Task Name
00000000000 - Time you want to wait until execute [Time specify in seconds] [You can specify more time than one]
command1 - Commands you want to execute when context is changed
JSON Schemas¶
PWBS Local Configuration File [It’s schemas with not implemented features too]
PWBS_LCF-pwbs.json Working Draft¶
"$schema" : "https://gitlab.com/paip-web/pwbs/raw/develop/docs/source/schema/PWBS_LCF_WD.json"
{ "$schema": "http://json-schema.org/draft-07/schema#", "description": "PAiP Web Build System - LCF Working Draft [Last-Modified: 03.09.2018] [PWBS Local Configuration File] [Filename: pwbs.json]", "type": "object", "definitions": { "command" : { "type" : "array", "items": { "anyOf": [ { "type" : "string" }, { "type" : "object", "additionalProperties": false, "properties": { "task" : { "type" : "string" }, "args" : { "type" : ["array", "object"] }, "context" : { "type" : "array" }, "comment" : { "type" : "string" } } } ] } } }, "properties": { "commands" : { "description": "Place for all definitions of Tasks", "type" : "object", "additionalProperties": false, "patternProperties" : { "^.+$": { "anyOf": [ { "description": "Advanced Task", "type" : "object", "additionalProperties": false, "properties" : { "mode" : { "description": "Task Mode:\nst - Single Task\nmt - Multi Task\nmc - MultiCommand Task\nwc0 - Watcher (Run,Execute,Wait)\nwc - Watcher (Run, Wait)\nsc0 - Scheduler (Run,Execute,Wait)\nsc - Scheduler (Run,Wait)", "type" : "string" }, "commands" : { "description": "Commands of Task", "anyOf" : [ { "type" : "array", "$ref": "#/definitions/command" }, { "type" : "object", "additionalProperties": false, "properties": { "windows" : { "type" : "array", "$ref": "#/definitions/command" }, "win" : { "type" : "array", "$ref": "#/definitions/command" }, "linux" : { "type" : "array", "$ref": "#/definitions/command" }, "lin" : { "type" : "array", "$ref": "#/definitions/command" }, "macos" : { "type" : "array", "$ref": "#/definitions/command" }, "macosx" : { "type" : "array", "$ref": "#/definitions/command" }, "mac" : { "type" : "array", "$ref": "#/definitions/command" }, "other" : { "type" : "array", "$ref": "#/definitions/command" }, "any" : { "type" : "array", "$ref": "#/definitions/command" }, "Windows" : { "type" : "array", "$ref": "#/definitions/command" }, "Win" : { "type" : "array", "$ref": "#/definitions/command" }, "Linux" : { "type" : "array", "$ref": "#/definitions/command" }, "Lin" : { "type" : "array", "$ref": "#/definitions/command" }, "Macos" : { "type" : "array", "$ref": "#/definitions/command" }, "Macosx" : { "type" : "array", "$ref": "#/definitions/command" }, "Mac" : { "type" : "array", "$ref": "#/definitions/command" }, "Other" : { "type" : "array", "$ref": "#/definitions/command" }, "Any" : { "type" : "array", "$ref": "#/definitions/command" }, "WINDOWS" : { "type" : "array", "$ref": "#/definitions/command" }, "WIN" : { "type" : "array", "$ref": "#/definitions/command" }, "LINUX" : { "type" : "array", "$ref": "#/definitions/command" }, "LIN" : { "type" : "array", "$ref": "#/definitions/command" }, "MACOS" : { "type" : "array", "$ref": "#/definitions/command" }, "MACOSX" : { "type" : "array", "$ref": "#/definitions/command" }, "MAC" : { "type" : "array", "$ref": "#/definitions/command" }, "OTHER" : { "type" : "array", "$ref": "#/definitions/command" }, "ANY" : { "type" : "array", "$ref": "#/definitions/command" } } } ] }, "task" : { "type" : "string" }, "args" : { "type" : ["array", "object"] }, "context" : { "type" : "array" }, "comment" : { "type" : "string" } } }, { "description": "Single Task", "type" : "string" }, { "description": "Multi Task", "type" : "array" } ] } } }, "config" : { "type" : "object", "additionalProperties": false, "properties": { "settings" : { "description": "Settings of PWBS", "type" : "object", "additionalProperties": false, "properties": { "json-plugins" : { "type" : "boolean" }, "py-plugins" : { "type" : "boolean" }, "verbose-mode" : { "type" : "integer" }, "os-tasks" : { "type" : "boolean" }, "debug-mode" : { "type" : "boolean" }, "test-mode" : { "type" : "boolean" }, "pwbs-integrated-tasks" : { "type" : "boolean" }, "pwbs-integrated-plugins" : { "type" : "boolean" }, "lcf-plugins" : { "type" : "boolean" } } }, "use" : { "description": "Define what plugins you want to use", "type" : "object", "additionalProperties": false, "properties": { "py-plugins" : { "type" : "array" }, "json-plugins" : { "type" : "array" }, "lcf-plugins" : { "type" : "array" } } } } } }, "additionalProperties": false }
PWBS_LCF-pwbs.json v.0.3¶
"$schema" : "https://gitlab.com/paip-web/pwbs/raw/develop/docs/source/schema/PWBS_LCF_v_0_3.json"
{ "$schema": "http://json-schema.org/draft-07/schema#", "description": "PAiP Web Build System - LCF v.0.2 [Used in PWBS E2 to and with v.0.3.0dev1] [Filename: pwbs.json]", "type": "object", "definitions": { "command" : { "type" : "array", "items": { "anyOf": [ { "type" : "string" }, { "type" : "object", "additionalProperties": false, "properties": { "task" : { "type" : "string" }, "args" : { "type" : "array" } } } ] } } }, "properties": { "commands" : { "description": "Place for all definitions of Tasks", "type" : "object", "additionalProperties": false, "patternProperties" : { "^.+$": { "anyOf": [ { "description": "Advanced Task", "type" : "object", "additionalProperties": false, "properties" : { "mode" : { "description": "Task Mode:\nst - Single Task\nmt - Multi Task\nmc - MultiCommand Task\nwc0 - Watcher (Run,Execute,Wait)\nwc - Watcher (Run, Wait)\nsc0 - Scheduler (Run,Execute,Wait)\nsc - Scheduler (Run,Wait)", "type" : "string" }, "commands" : { "description": "Commands of Task", "anyOf" : [ { "type" : "array", "$ref": "#/definitions/command" }, { "type" : "object", "additionalProperties": false, "properties": { "windows" : { "type" : "array", "$ref": "#/definitions/command" }, "win" : { "type" : "array", "$ref": "#/definitions/command" }, "linux" : { "type" : "array", "$ref": "#/definitions/command" }, "lin" : { "type" : "array", "$ref": "#/definitions/command" }, "macos" : { "type" : "array", "$ref": "#/definitions/command" }, "macosx" : { "type" : "array", "$ref": "#/definitions/command" }, "mac" : { "type" : "array", "$ref": "#/definitions/command" }, "other" : { "type" : "array", "$ref": "#/definitions/command" }, "any" : { "type" : "array", "$ref": "#/definitions/command" }, "Windows" : { "type" : "array", "$ref": "#/definitions/command" }, "Win" : { "type" : "array", "$ref": "#/definitions/command" }, "Linux" : { "type" : "array", "$ref": "#/definitions/command" }, "Lin" : { "type" : "array", "$ref": "#/definitions/command" }, "Macos" : { "type" : "array", "$ref": "#/definitions/command" }, "Macosx" : { "type" : "array", "$ref": "#/definitions/command" }, "Mac" : { "type" : "array", "$ref": "#/definitions/command" }, "Other" : { "type" : "array", "$ref": "#/definitions/command" }, "Any" : { "type" : "array", "$ref": "#/definitions/command" }, "WINDOWS" : { "type" : "array", "$ref": "#/definitions/command" }, "WIN" : { "type" : "array", "$ref": "#/definitions/command" }, "LINUX" : { "type" : "array", "$ref": "#/definitions/command" }, "LIN" : { "type" : "array", "$ref": "#/definitions/command" }, "MACOS" : { "type" : "array", "$ref": "#/definitions/command" }, "MACOSX" : { "type" : "array", "$ref": "#/definitions/command" }, "MAC" : { "type" : "array", "$ref": "#/definitions/command" }, "OTHER" : { "type" : "array", "$ref": "#/definitions/command" }, "ANY" : { "type" : "array", "$ref": "#/definitions/command" } } } ] }, "context" : { "type" : "array" }, "comment" : { "type" : "string" }, "arg" : { "type" : "object" } } }, { "description": "Single Task", "type" : "string" }, { "description": "Multi Task", "type" : "array" } ] } } }, "config" : { "type" : "object", "additionalProperties": false, "properties": { "settings" : { "description": "Settings of PWBS", "type" : "object", "additionalProperties": false, "properties": { "json-plugins" : { "type" : "boolean" }, "py-plugins" : { "type" : "boolean" }, "verbose-mode" : { "type" : "integer" }, "os-tasks" : { "type" : "boolean" }, "debug-mode" : { "type" : "boolean" }, "test-mode" : { "type" : "boolean" }, "pwbs-integrated-tasks" : { "type" : "boolean" }, "pwbs-integrated-plugins" : { "type" : "boolean" }, "lcf-plugins" : { "type" : "boolean" } } }, "use" : { "description": "Define what plugins you want to use", "type" : "object", "additionalProperties": false, "properties": { "py-plugins" : { "type" : "array" }, "json-plugins" : { "type" : "array" }, "lcf-plugins" : { "type" : "array" } } } } } }, "additionalProperties": false }
PWBS_LCF-pwbs.json v.0.2¶
"$schema" : "https://gitlab.com/paip-web/pwbs/raw/develop/docs/source/schema/PWBS_LCF_v_0_2.json"
{ "$schema": "http://json-schema.org/draft-07/schema#", "description": "PAiP Web Build System - LCF v.0.2 [Used in PWBS E2 to and with v.0.3.0dev1] [Filename: pwbs.json]", "type": "object", "properties": { "commands" : { "type" : "object", "properties": { "^.+$": { "anyOf": [ { "type" : "string" }, { "type" : "array" }, { "type" : "object", "properties" : { "mode" : { "type" : "string" }, "commands" : { "type" : "array" }, "context" : { "type" : "array" } } } ] } } }, "config" : { "type" : "object", "properties": { "json-mods" : { "type" : "boolean" }, "py-mods" : { "type" : "boolean" }, "verbose-mode" : { "type" : "integer" }, "os-commands" : { "type" : "boolean" }, "detailos-commands" : { "type" : "boolean" } } }, "mods" : { "type" : "array" }, "json-mods" : { "type" : "array" }, "py-mods" : { "type" : "array" }, "os-commands" : { "type" : "object", "properties": { "linux" : { "type" : "object" }, "windows" : { "type" : "object" }, "macos" : { "type" : "object" }, "other" : { "type" : "object" } } } }, "patternProperties": { "^.+$": { "$id": "/properties/any", "anyOf": [ { "type" : "string" }, { "type" : "array" }, { "type" : "object" } ] } }, "additionalProperties": false }
PWBS_LCF-commands.json v.0.1¶
"$schema" : "https://gitlab.com/paip-web/pwbs/raw/develop/docs/source/schema/PWBS_LCF_v_0_1.json"
{ "$schema": "http://json-schema.org/draft-07/schema#", "description": "PAiP Web Build System - LCF v.0.1 [Used in PWBS E1 to and with v.0.9.1.0] [Filename: pwbs.commands.json]", "type": "object", "patternProperties": { "^.+$": { "anyOf": [ { "type" : "string" }, { "type" : "array" }, { "type" : "object" } ] } }, "additionalProperties": false }
FUTURE: Full PWBS pwbs.json Config File¶
Not implemented [additional features] in any way in v.0.4.0dev0
Full Example pwbs.json
/* PWBS Local Configuration File
* pwbs.json
* PWBS_LCF-pwbs.json v.0.3
*/
{
"config" : {
"settings" : {
"json-plugins" : true, // Enabling JSON Plugins [Default False]
"py-plugins" : true, // Enabling Python Plugins [Default False]
"verbose-mode" : 255, // Changing Verbose Mode [Default 1] (This setting can be overwrited in the run of pwbs by the --verbose flag)
"os-tasks" : true, // Enabling Operating System Specific Tasks [Default False]
"debug-mode" : true, // Enabling Debug Mode [Default False] (This setting can be overwrited in the run of pwbs by the --debug flag)
"test-mode" : true, // Enabling Test Mode [Default False] (This setting can be overwrited in the run of pwbs by the --test-mode flag)
"pwbs-integrated-tasks" : true, // Enabling PWBS Integrated Tasks [Default False]
"pwbs-integrated-plugins" : true, // Enabling PWBS Integrated Plugins [Default False]
"lcf-plugins" : true // Enabling PWBS Local Configuration File - Plugins [Default False] (This option is like importing tasks from another pwbs.json)
},
"use" : {
"py-plugins" : [ // Python Plugins
"coffeescript",
"stylus",
"concatenate",
"git"
],
"json-plugins" : [ // JSON Plugins
"test"
],
"lcf-plugins" : [ // Local Configuration File - Plugins
"test.pwbs.json"
]
}
},
"commands" : {
"deps-install" : {
"mode" : "st", // Single Task
"commands" : { // Commands
"windows" : { // Commands for Windows
"pip install -r requirements.txt"
},
"other" : { // Commands for everything else
"pip3 install -r requirements.txt"
}
},
"comment" : "Installs Dependencies" // Comment
},
"compile" : {
"mode" : "wc0", // Watcher Task
"context" : [ // Watcher Context
"website/blog/static/blog/stylus",
"website/blog/static/blog/coffee"
],
"comment" : "Compiling your files to normal static files.", // Comment
"arg" : { // Arguments to be used in this task (used from template language)
"tmpdir" : "compiled_tmpdir",
"compileddir" : "website/blog/static/blog/res"
},
"commands" : [
{ // Argumented Task
"task" : "--git--add",
"args" : [
"all"
]
},
{
"task" : "--git--commit",
"args" : [
{
"message" : "$(%tl->>date('d-m-Y H:M:s')) - PWBS Auto Compiler Task" // Argument with template language interpolatation
}
]
}
"--coffeescript--init", // Normal task
"--stylus--init",
{
"task" : "--coffeescript--compile",
"args" : [
"$(%this->>context)", // Argument with template language interpolation using task arguments and task context
"$(%this->>arg->tmpdir)",
[
"bare",
"map"
]
]
},
{
"task" : "--stylus--compile",
"args" : [
"$(%this->>context)",
"$(%this->>arg->tmpdir)",
[
"compress",
"map",
"autoprefix"
]
]
},
{
"task" : "--concatenate--compile",
"args" : [
"$(%this->>arg->tmpdir)",
"$(%this->>arg->compileddir)",
[
"main.css",
"main.js"
]
]
},
"--test--testcompiled",
"--lcf--cleanup"
]
}
}
}
Contribution Guide¶
Welcome in our Contribution Guide¶
Contributions are welcome, and they are greatly appreciated!
Every little bit helps a lot, and credit will always be given.
How can i contribute?¶
You can contribute and help in many ways.
Types of Contributions¶
Submit Feedback¶
The best way to send feedback is to file an issue at https://gitlab.com/paip-web/pwbs/issues .
Issue template is in another section of that document.
If you are proposing a feature explain in detail how it would work.
Write Documentation¶
PWBS (PAiP Web Build System) could always use more documentation and always can have better constructed documentation. Whether as part of official PWBS docs, in docstrings, or even on the web in blog posts, articles, and such.
If you find mistyped word then file an issue or change and submit merge request.
Report Bugs¶
Report bugs at https://gitlab.com/paip-web/pwbs/issues .
Issue template is in another section of that document.
If you are reporting a bug, please include:
- Your operating system name and version
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce bug.
Fix Bugs¶
Look through the GitLab issues for bugs. Anything tagged with “bug” is open to whoever wants to implement it.
Implement Features¶
Look through the Roadmap in documentation and check what wasn’t done. Everything what will be there is open to whoever wants to implement it.
Rules and Additional Information¶
Rules¶
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
The pull request should include tests.
Add your changes to ChangeLogs
- docs/source/n_changelog.rst (Every even small change)
- HISTORY.rst (For every big change in functionality)
The pull request should work for Python >= 3.6 and be OS independent.
Tests¶
To run tests run any of these:
pytest
pwbs --run-tests
python -m pwbs --run-tests
If you make tests keep ordering don’t fillout missing numbers. Last Documented Test is 5? Then make test 6 not 4 because it’s missing number.
Templates¶
Feedback Issue Template¶
There where in this template is <Something> that means your data.
Issue
Title | Feedback: <Name or Nick>
Description | <Your Feedback and/or Your Feature Proposal>
Milestone | NEXT
Label | FEEDBACK
Bug Report Issue Template¶
There where in this template is <Something> that means your data.
Issue
Title | BUG: <Name of Bug>
Description | <Your Information about the bug>
Milestone | BUG
Label | BUG
License¶
License Text¶
The MIT License (MIT)
Copyright (c) 2019 Patryk Adamczyk
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
CHANGELOG¶
Branch v.0.5.X¶
Description:
# This version was:
# - changes in code style
# - Quality of Life improvements
# - Upgrades to newer versions of dependendencies
0.5.0-dev2¶
Relative imports changed to absolute imports
Added more information on Error Dumping
It’s for better understanding errors on Sentry
0.5.0-dev0¶
- Code Style changes
- Sentry Error Tracking
- Help on no arguments
- PWBS Event Manager (deprecated)
- PWBS LCF Schema v.0.4
- Deleted old PWBS used for automation
- Stopped handling STDOUT of Commands
- Base ChangeLog Format Changed
- Some rephrase of Documentation
Branch v.0.4.X¶
Description:
# This version branch was:
# - complete rewrite of the project
0.4.0-alpha0¶
- First alpha version
0.4.0-dev0¶
Rewrite of the project:
# Too much to write all details here # In the easy words of this version: # - I deleted pwbs 0.3.0-dev1 code # - I wrote pwbs code from zero again
Branch v.0.3.X¶
Description:
# This version branch was:
# - adding multi tasking
0.3.0-dev1 (22.12.2017)¶
- Release 8 on PyPi
- Added Multi Tasking
Branch v.0.2.X¶
Description:
# This version branch was:
# - Adding first mode of tasks
# - Fixing some RST errors again
# - Fixing some bugs [Hardcoded path and wrong default for one function]
0.2.0-dev3 (20.12.2017)¶
- Repaired Code Errors (Showing when using OS other then Windows)
- Repaired 4 Tests Failed on Linux
- Repaired pwbs.pwm.pwm_json (Wrong Default | Now Default is dict not list)
0.2.0-dev2 (16.12.2017)¶
- Release 7 on PyPi
- Repaired RST Errors
0.2.0-dev1 (16.12.2017)¶
- Release 6 on PyPi
- Added Single Tasking
Branch v.0.1.X¶
Description:
# This version branch was:
# - fixing some errors in repository and package basic documentation
# - added some tests
# - added some cli options
0.1.0-dev2 (13.12.2017-16.12.2017)¶
- Release 5 on PyPi
- Added –new-config option as Working
- Added –config <file> option as Working
0.1.0-dev1 (12.12.2017-13.12.2017)¶
- Release 4 on PyPi
- Added collective.checkdocs as setup requirement
- Repaired RST Errors
- Tests for pwm submodule and for pwbs module
Branch v.0.0.X¶
Description:
# This Version Branch was first version of project PAiP Web Build System Edition 2
# This was as Edition 2 by existance of my own PWBS project
# I wanted to rewrite it to be more readable and better as well as add it to PyPi
0.0.1-dev4 (09.12.2017-12.12.2017)¶
- Release 3 on PyPi
- Adding Command Interpreter
- Repairing setup.py Script
- Added Tox as Test Runner for checking with which version pwbs is compatible
- Added Command –help
- Added Command –verbose <mode>
0.0.1-dev3 (09.12.2017)¶
- Release 2 on PyPi
- Adding Baner
0.0.1-dev2 (09.12.2017)¶
- First Release in PyPi
0.0.1-dev0 (09.12.2017)¶
- First packaging
PWBS Code Documentation¶
Basic Informations¶
Documentation Version: v.0.4.0-dev0+documentation-1
Documented PWBS Repository Version: v.0.4.0-dev0
Documented PWBS PyPi Release: <NOT PUBLISHED> [TO BE PUBLISHED as v.0.4.0-dev1]
Documentation Convention¶
Convention of this documentation:
# Every function and module have own RST file in DOCUMENTATION_ROOT/code_docs/ folder
Code Documentation: Modules¶
pwbs¶
This module is package of PWBS.
pwbs.api¶
This module is place for future api to make plugins for PWBS.
pwbs.command¶
This module is place for Commands Classes. Commands classes are used to interpret config into objects and by that they can invoke run method which runs commands which was specified in config file.
pwbs.config¶
This module is place of configuration classes and loading configuration classes.
pwbs.core¶
This module is place for core PWBS features.
pwbs.lib¶
This module is place for all dependencies which are made as part of PWBS for no dependencies version complications. This module will not be ever well documented here because of type of files it has.
pwbs.log¶
This module is place for Logger Classes and everything related to logging (to file and stdout).
pwbs.tests¶
This module is place for tests. This module will be documented together (In 2 parts: first about test runner and second about all tests).
Code Documentation: Submodules¶
pwbs¶
This module is place for running pwbs and package initialization.
pwbs.__init__¶
Place for initialization of the package.
Here is script for running this script by python pwbs/__init__.py
.
-
pwbs.__init__.
main
()¶ Main function of PWBS
-
pwbs.
__version__
¶ Version of the PWBS
pwbs.__main__¶
Place for running the package.
Here is script for running this script by python -m pwbs
and pwbs
.
pwbs.command.command¶
This module is place for main PWBS Program Class.
-
class
pwbs.command.command.
CommandType
¶ This class is Enum of Task Types.
-
NullTask = 0x000
This type is Null Task (Special type to make null type task).
-
InitialNullTask = 0x001
This type is Null Task type that are used to initialize CommandType Object in Command Class.
-
SpecialTask = 0x101
This type is Special Task type.
-
SingleTask = 0x201
This type is Single Task type.
-
MultiTask = 0x202
This type is Multi Task type.
-
MultiCommandTask = 0x203
This type is Multi Command Task type.
-
WatcherTask = 0x204
This type is Watcher Task type. [FUTURE:]
-
SchedulerTask = 0x205
This type is Scheduler Task type. [FUTURE:]
-
TestTask = 0xFF0
This type is Test Task type. This type is for tests only.
-
ErrorTask = 0xFF1
This type is Error Task type. This type is for error catching purposes.
-
NullTaskF = 0xFFF
This type is Null Task type (Special type for make null task).
-
-
class
pwbs.command.command.
Platform
¶ This class is for making specific platform tasks. [FUTURE:]
-
NullOS = 0b0000
This is for no platform.
-
Windows = 0b0001
This is for Windows platform.
-
Linux = 0b0010
This is for Linux platform.
-
MacOS = 0b0100
This is for Mac OS X platform.
-
Other = 0b1000
This is for other platforms.
-
Any = 0b1111
This is for any platform.
-
-
class
pwbs.command.command.
CommandMode
¶ This class is for Tasks Modes.
-
SingleTask_Standard = 0x2201001
This is Single Task - Standard Mode.
-
MultiTask_Standard = 0x2202001
This is Multi Task - Standard Mode.
-
MultiCommandTask_Standard = 0x22030001
This is Multi Command Task - Standard Mode
-
WatcherTask_StartAndRun = 0x22040001
This is Watcher Task - Start, Run Commands and Wait Mode.
-
WatcherTask_StartAndWait = 0x22040002
This is Watcher Task - Start and Wait Mode.
-
Scheduler_StartAndRun = 0x22050001
This is Scheduler Task - Start, Run Commands and Wait Mode.
-
Scheduler_StartAndWait = 0x22050002
This is Scheduler Task - Start and Wait Mode.
-
NullMode = 0x00000000
This is null mode.
-
ModeNotSpecified = 0x00000001
This is Mode for not specified mode.
-
TestTask_TestMode = 0xFFF00000
This is Test Task - Test Mode.
-
ErrorTask_ErrorMode = 0xFFF1FFFF
This is Error Task - Error Mode.
-
NullTask_NullMode = 0xF000FFF0
This is Null Task - Null Mode.
-
NullTaskF_NullMode = 0xFFFFFFF0
This is Null Task F - Null Mode.
-
ErrorMode = 0xFFFFFFFF
This is Error Mode.
-
-
class
pwbs.command.command.
Command
(name, cmd_type: CommandType = CommandType.InitialNullTask, commands: list = None, comment: str = "", mode: CommandMode = CommandMode.NullMode, arguments: dict = None, special: dict = None, platform: Platform = Platform:Any) → None¶ This is Command Class. It’s used to make Tasks from JSON to Python object.
Constructor making this steps:
- Making Logger Object
- Defining Variables
Parameters: - name (str) – Name of the Command (Task).
- cmd_type (CommandType) –
Type of Command.
Default it’s set to
pwbs.command.command.CommandType.InitialNullTask
. - commands (list) –
List of Commands.
Default it’s set to
None
. - mode (CommandMode) –
Mode of Command (Task).
Default it’s set to
pwbs.command.command.CommandMode.NullMode
. - arguments (dict) –
Arguments of Command (Task).
Default it’s set to
None
. - special (dict) –
Special Arguments of Commands (Task).
Default it’s set to
None
. - platform (Platform) –
Platform of Command (Task).
Default it’s set to
pwbs.command.command.Platform.Any
Returns: None
Return type: None
-
_log = pwbs.log.logger.Logger()
Logger Object
-
name
¶ Name of Command
-
type
¶ Type of Command
-
commands
¶ Commands specified to execute when task is called.
-
comment
¶ Comment to Command
-
mode
¶ Mode of Command
-
arguments
¶ Arguments of Command
-
special
¶ Special Arguments of the Command
-
platform
¶ Platform for the Command
-
__eq__
(self, other)¶ This thunder method is for Equation Operator Overload for this class.
-
run
()¶ This method is used to run task and commands associated with it.
TODO: MultiTask
Raises: - Exception – Error Task Reached. [TODO: Change exception]
- NotImplementedError – If not supported task type is reached.
Returns: None
Return type: None
This method is making these steps:
- Checking type
- Running Special
execute_as_XXXXXXX()
method for specified type
-
execute_as_singletask_or_multicommand
()¶ This method is executing that Command object as SingleTask or MultiCommandTask.
-
prefixer
(text)¶ Text Prefixer needed for that function. Used to time command outputs.
Parameters: text (str) – Text to prefix
-
-
execute_as_watcher
()¶ Raises: NotImplementedError – Feature not Implemented! [TODO:]
-
execute_as_scheduler
()¶ Raises: NotImplementedError – Feature not Implemented! [TODO:]
-
__add__
(self, other)¶ This thunder method is for Adding Operator Overload for this class.
-
argument_parser
()¶ This method is for argument_parser.
Returns: pwbs.command.command.Command.comment
Return type: str
-
class
pwbs.command.command.
CommandList
(value: Command) → None¶ This class is for making list Commands Class Objects.
Parameters: value (Command) – Array of values [Type: List of Command Class Objects] Returns: None Return type: None -
values
¶ Values of the CommandList
-
__getitem__
(self, key)¶ This thunder method is for X[Y] Operator Overload for this class.
-
__setitem__
(self, key, value)¶ This thunder method is for X[Y] = Z Operator Overload for this class.
-
__delitem__
(self, key)¶ This thunder method is for del X[Y] Operator Overload for this class.
-
__contains__
(self, item)¶ This thunder method is for Y in X Operator Overload for this class.
-
items
()¶ This method returns all items in CommandList.
Returns: pwbs.command.command.CommandList.values
Return type: list
-
pwbs.config.config_manager¶
This module is place for Configuration Manager.
-
exception
pwbs.config.config_manager.
PWBSConfigFileDontExistError
¶ Exception for handling
Local Config File Don't Exist
-
exception
pwbs.config.config_manager.
PWBSInvalidConfigFile
¶ Exception for handling
Invalid Format of Local Config File
-
class
pwbs.config.config_manager.
ConfigManager
(filename="pwbs.json")¶ This class is for Managing Configuration File.
Parameters: filename (str) – Filename of Configuration File.
Defaults to
pwbs.json
.Raises: PWBSConfigFileDontExistError – Local Configuration File Don’t Exist -
config_filename
¶ Configuration File Filename
-
config_filename_path
¶ Configuration File Path
-
error = None
Variable contains errors when they occur.
-
filemanager = pwbs.lib.pwm.pwm_json.JSON_IO(self.config_filename_path)
File Manager Object
-
config_dict
¶ Configuration File Dictionary Object
-
load
()¶ This method is trying to load Configuration File Data.
Returns: pwbs.config.config_manager.ConfigManager.config_dict
Return type: dict
Raises: PWBSInvalidConfigFile – If in Configuration File doesn’t exist commands key (Which means that config file is invalid).
-
write
(newdata)¶ This method is overwriting Configuration File with new data.
Returns: New data provided but returned from writing and reading config file. Return type: dict
-
pwbs.config.pwbs_config¶
This module is place for PWBS Configuration Manager.
-
class
pwbs.config.pwbs_config.
PWBS_ConfigManager
¶ This class is holding PWBS Config Manager.
-
log = pwbs.log.logger.Logger()
Logger
-
verbose = 1
Verbose Level
-
debug = False
Debug Mode
-
configmanager = pwbs.config.configmanager.ConfigManager()
Local Configuration File Manager
-
commands = pwbs.command.command.CommandList([])
Commands List
-
config_file
()¶ Configuration File Loader
Returns: Data from Configuration File Return type: dict
-
commands_to_commandlist
()¶ Method for changing Configuration File Data to CommandList Object
Raises: PWBSInvalidConfigFile – Invalid Configuration File
-
static
ctcl__cmdtype
(commandbody)¶ This method is to change Command Dict Object into
pwbs.command.command.CommandType
.Parameters: commandbody (dict) – Command Dict Object
-
static
ctcl__comment
(commandbody)¶ This method is to change Command Dict Object into
str
with comment.Parameters: commandbody (dict) – Command Dict Object
-
static
ctcl__cmdmode
(commandbody)¶ This method is to change Command Dict Object into
pwbs.command.command.CommandMode
.Parameters: commandbody (dict) – Command Dict Object
-
static
ctcl__arguments
(commandbody)¶ This method is to change Command Dict Object into
list
with arguments.Parameters: commandbody (dict) – Command Dict Object
-
static
ctcl__commands
(commandbody)¶ This method is to change Command Dict Object into
list
with commands.Parameters: commandbody (dict) – Command Dict Object
-
static
ctcl__platform
(commandbody)¶ This method is to change Command Dict Object into
pwbs.command.command.Platform
.Parameters: commandbody (dict) – Command Dict Object
-
pwbs.core¶
This module is place for PWBS core things like exceptions.
-
pwbs.core.
prefix_text
(text="")¶ Default Prefixer
-
exception
pwbs.core.
NotImplementedFeatureError
¶ Error for Not Implemented Functionality
pwbs.log.logger¶
This module is place for PWBS logging things.
-
exception
pwbs.log.logger.
LoggerAssertionError
¶ Error to show when Logger.log_assertion failed assertion.
-
class
pwbs.log.logger.
BaseLogger
¶ Base Logger Class
That Logger logging to STDOUT.
-
debug_delayed_story
¶ Story Log for Delayed Debug
-
debug_state
¶ Debug Mode State
-
verbose_state
¶ Verbose Mode State
-
debug
(state=False)¶ Debug Mode Changer
Parameters: state (bool) – State to change to
Defaults to False. [Debug Mode Disabled]
-
verbose
(state=1)¶ Verbose Mode Changer
Parameters: state (int) – State to change to
Defaults to 1.
Levels:
- No Verbose
- Small Verbose
- Medium Verbose
- Full Verbose
- Debug Verbose Mode
-
log
(text, prefix=pwbs.core.prefix_text)¶ Log Function
Parameters: - text (str) – Text to Log
- prefix (function) – Prefixer to Use
-
log_wop
(text)¶ Log Function [Without prefixer]
Parameters: text (str) – Text to Log
-
log_verbose
(text, verbose=1)¶ Log Verbose Function (Logs when message verbose is smaller than Configuration Verbosity)
Parameters: - text (str) – Text to Log
- verbose (int) –
Verbose Level for Message
Defaults to 1.
-
log_debug
(text)¶ Log Debug Function (Logs when debug mode is turned on)
Parameters: text (str) – Text to Log
-
log_assertion
(assertion, name=None)¶ Log Assertion Function
Parameters: - assertion (bool) – Assertion to check
- name (str) – Name of the Assertion [To name Log Assertions]
-
-
class
pwbs.log.logger.
LogLogger
¶ Log Logger Class
That Logger logging to file.
-
story = []
Story Log
-
logfile = "pwbs.log"
Log File Variable
-
activelogging = False
Active Logging Variable
When Active Logging is active then every any log function call it save to log file.
-
debug_delayed_story
¶ Story Log for Delayed Debug
-
debug_state
¶ Debug Mode State
-
verbose_state
¶ Verbose Mode State
-
debug
(state=False)¶ Debug Mode Changer
Parameters: state (bool) – State to change to
Defaults to False. [Debug Mode Disabled]
-
verbose
(state=1)¶ Verbose Mode Changer
Parameters: state (int) – State to change to
Defaults to 1.
Levels:
- No Verbose
- Small Verbose
- Medium Verbose
- Full Verbose
- Debug Verbose Mode
-
log
(text, prefix=pwbs.core.prefix_text)¶ Log Function
Parameters: - text (str) – Text to Log
- prefix (function) – Prefixer to Use
-
log_wop
(text)¶ Log Function [Without prefixer]
Parameters: text (str) – Text to Log
-
log_verbose
(text, verbose=1)¶ Log Verbose Function (Logs when message verbose is smaller than Configuration Verbosity)
Parameters: - text (str) – Text to Log
- verbose (int) –
Verbose Level for Message
Defaults to 1.
-
log_debug
(text)¶ Log Debug Function (Logs when debug mode is turned on)
Parameters: text (str) – Text to Log
-
log_assertion
(assertion, name=None)¶ Log Assertion Function
Parameters: - assertion (bool) – Assertion to check
- name (str) – Name of the Assertion [To name Log Assertions]
-
log_file_write
(file=None)¶ Log File Writer
Parameters: file (str) – Filename to write log.
Defaults to None. (Which using self.logfile class attribute)
-
-
class
pwbs.log.logger.
Logger
¶ Logger Class
That Logger logging to file and STDOUT.
-
log_logger = pwbs.log.logger.LogLogger()
File Logger
-
locker_log_logger = False
Log Logger Lock Variable
-
debug_delayed_story
¶ Story Log for Delayed Debug
-
debug_state
¶ Debug Mode State
-
verbose_state
¶ Verbose Mode State
-
debug
(state=False)¶ Debug Mode Changer
Parameters: state (bool) – State to change to
Defaults to False. [Debug Mode Disabled]
-
verbose
(state=1)¶ Verbose Mode Changer
Parameters: state (int) – State to change to
Defaults to 1.
Levels:
- No Verbose
- Small Verbose
- Medium Verbose
- Full Verbose
- Debug Verbose Mode
-
log
(text, prefix=pwbs.core.prefix_text)¶ Log Function
Parameters: - text (str) – Text to Log
- prefix (function) – Prefixer to Use
-
log_wop
(text)¶ Log Function [Without prefixer]
Parameters: text (str) – Text to Log
-
log_verbose
(text, verbose=1)¶ Log Verbose Function (Logs when message verbose is smaller than Configuration Verbosity)
Parameters: - text (str) – Text to Log
- verbose (int) –
Verbose Level for Message
Defaults to 1.
-
log_debug
(text)¶ Log Debug Function (Logs when debug mode is turned on)
Parameters: text (str) – Text to Log
-
log_assertion
(assertion, name=None)¶ Log Assertion Function
Parameters: - assertion (bool) – Assertion to check
- name (str) – Name of the Assertion [To name Log Assertions]
-
log_file_write
(file=None)¶ Log File Writer
Parameters: file (str) – Filename to write log.
Defaults to None. (Which using self.logfile class attribute)
-
story
()¶ Log Logger Story Variable Getter
Returns: pwbs.log.logger.Logger.log_logger.story
Return type: list
-
pwbs.pwbs_class¶
This module is place for main PWBS Program Class.
-
class
pwbs.pwbs_class.
PWBS
¶ This class is main PWBS Program Class.
Constructor is making these steps:
- Making Argument Parser [Parser of CLI Arguments]
- Initialize Parser
- Making PWBS Config Manager Object
- Check for errors of PWBS Config Manager Object
- Initialize Config Manager
-
argparser
¶ Argument Parser
-
argparser_specialtasks
¶ Argument Parser Argument Group for Special Tasks
-
argparser_localconfigtasks
¶ Argument Parser Argument Group for Local Configuration Tasks
-
pwbscm
¶ PWBS Config Manager
-
args
¶ Arguments from argparser
-
parser_initializer
()¶ This method is to initalize parser.
This method is making these steps:
- Making Special Tasks Argument Group
- Adding Special Tasks Commands: [–verbose, –debug, –version, –new-config, –log, –log-file, –config-file, –test-mode, –run-tests]
- Adding Task Argument [This argument takes everything which is after special tasks commands or everything if there isn’t any special task command]
- Adding Local Configuration Tasks Argument Group
-
localconfig_parser_initializer
()¶ This method is to initalize parser of local configuration.
This method is:
- Trying to change json tasks into Commands Class Object changing it into one CommandList Class Object with all commands.
-
special_tasks_interpreter
()¶ This method is to interpret special tasks.
This method is:
- Checking is any of special task was called.
- If yes then it executes that special task that was called.
-
task_runner
()¶ This method is to run local configurations tasks.
This method is:
- Calling run method on every Command object that was called.
-
main
()¶ This method is main function of Program.
This method is:
- Parsing Arguments
- Interpreting Special Tasks
- Interpreting Normal Tasks
pwbs.tests¶
This module is place for PWBS tests.
Test Runner¶
-
exception
pwbs.tests.
TestSucceed
¶ Exception for Passed Test
-
exception
pwbs.tests.
TestFailed
¶ Exception for Failed Test
-
pwbs.tests.
tests_prefix_text
(text)¶ Test Runner Prefixer
Parameters: text (str) – Text to Prefixer
-
pwbs.tests.
run_test
(test_function, test_name: str, test_comment: str, test_module: str, test_except_to_fail=False)¶ Function for running tests in Test Runner.
Parameters: - test_function (function) – Test Function
- test_name (str) – Name of the Test
- test_comment (str) – Comment of the Test
- test_module (str) – Tested Module
- test_except_to_fail (bool) – Test Excepted to Fail
-
pwbs.tests.
test_runner
()¶ Test Runner
Tests¶
-
pwbs.tests.test_0.
test_0_0
()¶ Test testing assertions
-
pwbs.tests.test_0.
test_0_1
()¶ Test testing excepted failed assertions
-
pwbs.tests.test_1.
test_1_0
()¶ Checking
pwbs.command.command.CommandType
-
pwbs.tests.test_1.
test_1_1
()¶ Checking
pwbs.command.command.Platform
-
pwbs.tests.test_1.
test_1_2
()¶ Checking
pwbs.command.command.CommandMode
-
pwbs.tests.test_1.
test_1_3
()¶ Checking
pwbs.command.command.Command
Tested:
- Command.__init__()
- Command.__eq__()
-
pwbs.tests.test_1.
test_1_4
()¶ Checking
pwbs.command.command.Command
Tested:
- Command.run()
- Command.argument_parser()
-
pwbs.tests.test_1.
test_1_5
()¶ Checking
pwbs.command.command.Command
Tested:
- Command.execute_as_singletask_or_multicommand()
-
pwbs.tests.test_1.
test_1_6
()¶ Checking
pwbs.command.command.Command
Tested:
- Command.execute_as_watcher() [TODO: Testing NotImplementedFeatureError]
-
pwbs.tests.test_1.
test_1_7
()¶ Checking
pwbs.command.command.Command
Tested:
- Command.execute_as_scheduler()
-
pwbs.tests.test_1.
test_1_8
()¶ Checking
pwbs.command.command.Command
Tested:
- Command.__add__()
-
pwbs.tests.test_1.
test_1_9
()¶ Checking
pwbs.command.command.CommandList
-
pwbs.tests.test_2.
test_2_0
()¶ Checking
pwbs.config.config_manager
Exceptions Tests
-
pwbs.tests.test_2.
test_2_1
()¶
-
pwbs.tests.test_2.
test_2_2
()¶
-
pwbs.tests.test_3.
test_3_0
()¶ Checking
pwbs.core.NotImplementedFeatureError
-
pwbs.tests.test_3.
test_3_1
()¶ Checking
pwbs.core.prefix_text
Test has been deleted in commit: db38a705d725e65c999843e3f25f84a4b201ec54
.
This test has been deleted by copying Test 5.
-
pwbs.tests.test_5.
test_5_0
()¶ Checking
pwbs.log.logger.LoggerAssertionError
-
pwbs.tests.test_5.
test_5_1
()¶ Checking
pwbs.log.logger.BaseLogger
-
pwbs.tests.test_5.
test_5_2
()¶ Checking
pwbs.log.logger.LogLogger
-
pwbs.tests.test_5.
test_5_3
()¶ Checking
pwbs.log.logger.Logger
Roadmap to FUTURE:¶
Core Features¶
- Multi Tasks
- Watcher Tasks
- Scheduler Tasks
- Argumented Tasks
Features¶
Server Mode
- PWBS is making little server with interface by which can be executed tasks and you can see output afterwards by that interface.
Python PWBS API
- Making availble some functions as PWBS API in Python.
- Plugins written in Python to extend PWBS.
Special Integrated Tasks PWBS API
- Making availble some special tasks as PWBS API in JSON.
- Plugins written in JSON to extend PWBS.
Better Logging
Make use of verbose_mode and debug_mode (and test_mode(255,True) too)
Better Logging Levels
Global Configuration File (Or Local User Configuration File)
Better STDOUT with colorama or something
Better and more tests