Updated docs.

development
Shawn Davis 2 years ago
parent 6de3956dc6
commit 0d93018a00
  1. 171
      help/docs/cli.md
  2. 8
      help/docs/commands/django.md
  3. 23
      help/docs/commands/mysql.md
  4. 23
      help/docs/commands/pgsql.md
  5. 24
      help/docs/getting-started.md
  6. 14
      help/docs/how-to/create-executable-script.md
  7. 51
      help/docs/how-to/define-custom-command.md
  8. BIN
      help/docs/how-to/images/slack-1.jpg
  9. BIN
      help/docs/how-to/images/slack-2.jpg
  10. BIN
      help/docs/how-to/images/slack-3.jpg
  11. BIN
      help/docs/how-to/images/twist-1.png
  12. BIN
      help/docs/how-to/images/twist-2.png
  13. 41
      help/docs/how-to/post-message-slack.md
  14. 35
      help/docs/how-to/post-message-twist.md
  15. 50
      help/docs/how-to/use-with-commonkit.md
  16. 8
      help/docs/index.md
  17. 65
      help/docs/topics/command-file.md
  18. 14
      help/docs/topics/itemized-commands.md
  19. 37
      help/docs/topics/templates.md
  20. 0
      help/docs/topics/variables.md
  21. 20
      help/mkdocs.yml
  22. 3
      scripttease/lib/commands/base.py
  23. 4
      scripttease/lib/commands/messages.py
  24. 2
      scripttease/lib/commands/pgsql.py

@ -0,0 +1,171 @@
---
title: CLI
---
The `tease` command may be used to parse a configuration file, providing additional utilities for working with commands.
## Getting Help
Use `tease -h` to get started. There are three (3) sub-commands: [docs](#the-docs-sub-command), [inventory](#the-inventory-sub-command), and [script](#the-script-sub-command).
```text
usage: tease [-h] [-v] [--version] docs, inventory, script ...
positional arguments:
docs, inventory, script
Commands
docs Output documentation instead of code.
inventory (inv) Copy an inventory item to a local directory.
script Output the commands.
optional arguments:
-h, --help show this help message and exit
-v Show version number and exit.
--version Show verbose version information and exit.
NOTES
This command is used to parse configuration files and output the commands.
```
## The Docs Sub-Command
A nice benefit of using configuration for commands is that the information may be used to output documentation. This allows the automatic creation of an install guide or tutorial using exactly the same commands that would be used for the actual work.
Additionally, Script Tease provides the [explain](commands/messages.md#explain) and [screenshot](commands/messages.md#screenshot) commands that help provide extra content for documentary output.
```text
usage: tease docs [-h] [-o= {html,md,plain,rst}] [-C= VARIABLES] [-i= COMMAND_FILE] [-O= OPTIONS] [-P= {centos,ubuntu}]
[-T= TEMPLATE_LOCATIONS] [-w= OUTPUT_FILE] [-V= VARIABLES_FILE] [-D] [-p]
optional arguments:
-h, --help show this help message and exit
-o= {html,md,plain,rst}, --output-format= {html,md,plain,rst}
The output format; HTML, Markdown, plain text, or ReStructuredText.
-C= VARIABLES, --context= VARIABLES
Context variables for use in pre-parsing the config and templates. In the form of: name:value
-i= COMMAND_FILE, --input-file= COMMAND_FILE
The path to the configuration file.
-O= OPTIONS, --option= OPTIONS
Common command options in the form of: name:value
-P= {centos,ubuntu}, --profile= {centos,ubuntu}
The OS profile to use.
-T= TEMPLATE_LOCATIONS, --template-path= TEMPLATE_LOCATIONS
The location of template files that may be used with the template command.
-w= OUTPUT_FILE, --write= OUTPUT_FILE
Write the output to disk.
-V= VARIABLES_FILE, --variables-file= VARIABLES_FILE
Load variables from a file.
-D, --debug Enable debug mode. Produces extra output.
-p Preview mode.
```
## The Inventory Sub-Command
Script Tease ships with few pre-defined configurations that may be copied to a local directory.
Use `tease inv ?` to list available inventory items.
```text
usage: tease inventory [-h] [-P= TO_PATH] [-D] [-p] name
positional arguments:
name The name of the inventory item. Use ? to list available items.
optional arguments:
-h, --help show this help message and exit
-P= TO_PATH, --path= TO_PATH
The path to where the item should be copied. Defaults to the current working directory.
-D, --debug Enable debug mode. Produces extra output.
-p Preview mode.
```
!!! note "Road Map"
A future release will include support for multiple inventory locations that may be defined by the user.
## The Script Sub-Command
The `script` sub-command exports command configuration to actual Bash statements. Minimum usage is
```bash
tease -i commands.ini
```
This will output the statements represented in the specified configuration file. There are quite a few other parameters.
```text
usage: tease script [-h] [-c] [-s] [-C= VARIABLES] [-i= COMMAND_FILE] [-O= OPTIONS] [-P= {centos,ubuntu}] [-T= TEMPLATE_LOCATIONS]
[-w= OUTPUT_FILE] [-V= VARIABLES_FILE] [-D] [-p]
optional arguments:
-h, --help show this help message and exit
-c, --color Enable code highlighting for terminal output.
-s, --shebang Add the shebang to the beginning of the output.
-C= VARIABLES, --context= VARIABLES
Context variables for use in pre-parsing the config and templates. In the form of: name:value
-i= COMMAND_FILE, --input-file= COMMAND_FILE
The path to the configuration file.
-O= OPTIONS, --option= OPTIONS
Common command options in the form of: name:value
-P= {centos,ubuntu}, --profile= {centos,ubuntu}
The OS profile to use.
-T= TEMPLATE_LOCATIONS, --template-path= TEMPLATE_LOCATIONS
The location of template files that may be used with the template command.
-w= OUTPUT_FILE, --write= OUTPUT_FILE
Write the output to disk.
-V= VARIABLES_FILE, --variables-file= VARIABLES_FILE
Load variables from a file.
-D, --debug Enable debug mode. Produces extra output.
-p Preview mode.
```
### Context Variables May be Provided on the Command Line
To supply context variables on the command line:
```bash
tease -C domain_name:example.com -C domain_tld:example_com
```
!!! important
Variables provided on the command will always override those provided in a file.
### Loading Context Variables from a File
Context variables may be loaded from a file:
```ini
[domain_name]
value = example.com
[domain_tld]
value = example_com
```
The variables above are available as template variables in a commands file.
For example, ``{{ domain_name }}`` becomes ``example.com``.
To load the variables, use the `-V` switch:
```bash
tease -V variables.ini
```
### Setting Common Options for All Commands
Rather than include a common parameter in the configuration file, it is possible to specify a common option on the command line.
```bash
tease -O sudo:yes
```
### The Difference Between Variables and Options
Variables are used to pre-process configuration files as templates, while common options are passed to *all* command instances.

@ -24,7 +24,7 @@ django.migrate:
settings: tenants.example_com.settings settings: tenants.example_com.settings
[dump some data] [dump some data]
django.dump: path/to/dump.json django.dump: projects.Category
indent: 4 indent: 4
natural_foreign: yes natural_foreign: yes
natural_primary: yes natural_primary: yes
@ -121,4 +121,10 @@ first_option_name: asdf
second_option_name: 1234 second_option_name: 1234
third_option_name: yes third_option_name: yes
``` ```
This will generate a statement like:
```bash
./manage.py command_name --first-option-name="asdf" --second-option-name=1234 --third-option-name
``` ```

@ -49,16 +49,29 @@ Grant privileges to a user. Argument is the privileges to be granted.
- `database`: The database name where privileges are granted. - `database`: The database name where privileges are granted.
- `user`: The user name for which the privileges are provided. - `user`: The user name for which the privileges are provided.
### mysql.user.create ### mysql.user
Create a user. Argument is the username. Create a user. Argument is the username.
- `password`: The user's password. - `password`: The user's password.
### mysql.user.drop ```ini
[create a database user]
mysql.user: username
```
Remove a user. Argument is the user name. Remove a user.
### mysql.user.exists ```ini
[create a database user]
mysql.user: username
op: remove
```
Determine if a user exists. Argument is the user name. Determine if a user exists.
```ini
[create a database user]
mysql.user: username
op: exists
```

@ -42,16 +42,29 @@ Execute an SQL statement. Argument is the SQL statement.
Determine if a database exists. Argument is the database name. Determine if a database exists. Argument is the database name.
### pgsql.user.create ### pgsql.user
Create a user. Argument is the user name. Create a user. Argument is the user name.
- `password`: The user's password. - `password`: The user's password.
### pgsql.user.drop ```ini
[create a database user]
pgsql.user: username
```
Remove a user. Argument is the user name. Remove a user.
### pgsql.user.exists ```ini
[remove a database user]
pgsql.user: username
op: remove
```
Determine if a user exists. Argument is the user name. Determine if a user exists.
```ini
[determine if database user exists]
pgsql.user: username
op: exists
```

@ -0,0 +1,24 @@
# Getting Started
## System Requirements
Python 3.6 or greater is required.
## Install
To install:
```bash
pip install python-scripttease;
```
## Configuration
See [Commands File](topics/command-file.md) for creating a configuration file.
## FAQs
Have a question? `Just ask`_!
.. _Just ask: https://develmaycare.com/contact/?product=Script%20Tease

@ -0,0 +1,14 @@
# Create an Executable Script
To create a script that is ready to execute:
```bash
tease -i commands.ini -s -w script.sh
chmod +x script.sh
```
The `-s` switch causes the [shebang](https://linuxhandbook.com/shebang/) to be included at the top of the output. This defaults to:
`#! /usr/bin/env bash`
The script is now ready to run: `./script.sh`

@ -0,0 +1,51 @@
# Define A Custom Command
!!! note
It is not currently possible to define a custom command which may be used with the `tease` command.
## 1) Create A Function
Create a function that does what you want:
```python
# mycommands.py
from scripttease.lib.commands.base import Command
def do_something_impressive(arg1, **kwargs):
return Command("ls -ls %s" % arg1, **kwargs)
```
!!! important
kwargs are *always* required.
## 2) Create A Mapping
```python
# mycommands.py
MAPPINGS = {
'impressive': do_something_impressive,
}
```
`impressive` is now mapped to the function which creates the command.
## 3) Supply The Mapping to the Command Factory
```python
from scripttease.lib.factories import command_factory
from scripttease.lib.loaders import INILoader
from .mycommands import MAPPINGS
ini = INILoader("path/to/commands.ini")
ini.load()
commands = command_factory(ini, mappings=MAPPINGS)
```
## 4) Include the Custom Command
```ini
[this is my custom command]
impressive: testing
```

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 393 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 181 KiB

@ -0,0 +1,41 @@
# Post a Message to Slack
The `slack` command may be used to send a message to a Slack channel. This uses the Incoming Webhooks feature, which requires some additional setup.
!!! note
The following steps were accurate as of September 2020.
## 1) Log in to Slack
Log in to Slack and go to [Your Apps](https://api.slack.com/apps).
## 2) Create New Slack App
Create a new Slack app.
## 3) Select Incoming Webhooks
On the next page, select Incoming Webhooks and then toggle activation.
![incoming webhooks](images/slack-1.jpg)
## 4) Select Channel
Next, click "Add new Webhook to Workspace" and select the channel to which the message will be posted.
![slack 2](images/slack-2.jpg)
![slack 3](images/slack-3.jpg)
## 5) Copy the URL
Copy the URL for the new webhook to use as the ``url`` parameter for the Slack command.
```ini
[send a message to slack]
slack: "This is a test message."
url: the URL you created goes here
```
!!! tip
Define this URL in a `variables.ini` file if you need to send multiple messages to the same channel.

@ -0,0 +1,35 @@
# Post a Message to Twist
The `twist` command may be used to send a message to Twist, which requires some additional setup.
!!! note
The following steps were accurate as of September 2020.
## 1) Log In To Twist
Log in to Twist and from the profile menu go to Add Integrations. Then click on Build and "Add a new integration".
## 2) Provide Requested Information
Provide the requested info.
![twist 1](images/twist-1.png)
## 3) Install Integration
After submitting this info, go to Installation. Select a channel and who to notify. Then click "Install integration".
![twist 2](images/twist-2.png)
## 4) Copy the URL
Copy the "Post content manually" URL for use in your configuration file.
```ini
[post a message to twist]
twist: "This is a test message."
url: the URL you created goes here
```
!!! tip
Define this URL in a `variables.ini` file if you need to send multiple messages to the same channel.

@ -0,0 +1,50 @@
# Use Script Tease With Common Kit
Since the focus of Script Tease is to convert plain text instructions into valid command line statements, it does *not* provide support for executing those statements either locally or remotely. However, The shell component of [python-commonkit](https://docs.develmaycare.com/en/python-commonkit/stable/components/#module-commonkit.shell) *does* provide support for executing commands in local POSIX environments.
Here is an example of how to use these packages together:
```python
from commonkit.shell import Command
from scripttease.lib.factories import command_factory
from scripttease.lib.loaders import INILoader
def execute(step):
command = Command(
step.statement,
comment=step.comment,
path=step.cd,
prefix=step.prefix,
shell=step.shell
)
# Sudo is a different class, but identical in behavior.
command.sudo = step.sudo
if command.run():
print("[success] %s" % step.comment)
else:
print("[failure] %s" % step.comment)
if step.stop:
print("I can't go on: %s" % command.error)
exit(command.code)
ini = INILoader("path/to/commands.ini")
ini.load()
steps = command_factory(ini)
# A failure to load results in None.
if steps is None:
print("Failed to load steps. Bummer.")
exit(1)
# Iterate through each step to create a COMMON KIT command instance.
for step in steps:
# To preview ...
# print(step.get_statement(cd=True))
execute(step)
```
Common Kit is already a dependency of Script Tease, so it is installed by default. The ``execute()`` function provides the interface between Script Tease command instances and Common Kit command instances.

@ -16,7 +16,7 @@ The primary focus (and limit) is to convert plain text instructions (in INI or Y
Script Tease may be used in three (3) ways: Script Tease may be used in three (3) ways:
1. Using the library to programmatically define commands and export them as command line statements. 1. Using the library to programmatically define commands and export them as command line statements.
2. Using the `tease` command to generate commands from a configuration file. See [command file configuration](config/command-file.md). 2. Using the `tease` command to generate commands from a configuration file. See [command file configuration](topics/command-file.md).
3. Using the command file format and library to create a custom implementation. 3. Using the command file format and library to create a custom implementation.
This documentation focuses on the second method, but the developer docs may be used in your own implementation. This documentation focuses on the second method, but the developer docs may be used in your own implementation.
@ -46,17 +46,17 @@ All commands are represented by simple, Python functions. These functions are re
Profiles contain command functions that are specific to an operating system. Not all operating systems support the same commands. Profiles contain command functions that are specific to an operating system. Not all operating systems support the same commands.
!!! note !!! note
At present, the only fully defined operating systems are for Cent OS and Ubuntu. At present, the only defined operating system profiles are for Cent OS and Ubuntu.
Profiles import and appropriate all other available commands. Profiles import and appropriate all other available commands.
## Terms and Definitions ## Terms and Definitions
command command
: When used in Script Tease documentation, this is a command instance which contains the properties and parameters for a command line statement. : When used in Script Tease documentation, this is a command instance which contains the properties and parameters for assembling a command line statement.
statement statement
: A specific statement (string) to be executed. A *statement* is contained within a *command*. : A specific statement (string) to be executed. A *statement* is generated from a *command*.
## License ## License

@ -39,9 +39,8 @@ restart: postfix
With both INI and YAML files, the formatting rules are: With both INI and YAML files, the formatting rules are:
- The first part of each command is the INI section or YAML item and is used as the comment. - The first part of each command is the INI section or YAML item and is used as the comment.
- The command name *must* be the *first* option in the section. - The command name *must* be the *first* option in an INI section.
- The arguments for the command appear as the value of the first option in the section. Arguments are separated by a - The arguments for the command appear as the value of the first option in the section. Arguments are separated by a space.
space.
- Arguments that should be treated as a single value should be enclosed in double quotes. - Arguments that should be treated as a single value should be enclosed in double quotes.
- `yes` and `no` are interpreted as boolean values. `maybe` is interpreted as `None`. - `yes` and `no` are interpreted as boolean values. `maybe` is interpreted as `None`.
- List values, where required, are separated by commas when appearing in INI files, but are a `[standard, list, of, values]` in a YAML file. - List values, where required, are separated by commas when appearing in INI files, but are a `[standard, list, of, values]` in a YAML file.
@ -70,7 +69,7 @@ cd: /path/to/project
### comment ### comment
The comment comes from the section name (INI) or list name (YAML). It is included by default when the statement is generated, by may be suppressed using `include_comment=False`. The comment comes from the section name (INI) or list name (YAML). It is included by default when the statement is generated, but may be suppressed using `include_comment=False`.
```ini ```ini
[this becomes the comment] [this becomes the comment]
@ -94,20 +93,22 @@ The `env` option indicates the target environment (or environments) in which the
This option may be given as `environments`, `environs`, `envs`, or simply `env`. It may be a list or CSV string. This option may be given as `environments`, `environs`, `envs`, or simply `env`. It may be a list or CSV string.
The attribute name is always normalized to `environments`.
### prefix ### prefix
The `prefix` option is used to define a statement to be executed before the main statement is executed. The `prefix` option is used to define a statement to be executed before the main statement is executed.
```ini ```ini
[migrate the database] [migrate the database]
django: migrate django.migrate:
cd: /path/to/project/source cd: /path/to/project/source
prefix: source ../python/bin/activate prefix: source ../python/bin/activate
``` ```
### register ### register
`register` defines the name of a variable to which the result of the statement should be saved. It is included by default when the statement is generated, but may be suppressed using `include_register=False`. `register` defines the name of a variable to which the result of the statement should be saved. For some commands, it may be included by default when the statement is generated, but may be suppressed using `include_register=False`.
```yaml ```yaml
- check apache configuration: - check apache configuration:
@ -117,11 +118,11 @@ prefix: source ../python/bin/activate
### shell ### shell
The `shell` defines the shell to be used for command execution. It is not used for statement generation, but may be used programmatically -- for example, with Python's subprocess module. Some commands (such as Django management commands) need a shell to be explicitly defined. The `shell` defines the shell to be used for command execution. It is not used for statement generation, but may be used programmatically -- for example, with Python's subprocess module. Some commands (such as Django management commands) may need a shell to be explicitly defined.
```ini ```ini
[run django checks] [run django checks]
django: check django.check:
cd: /path/to/project/source cd: /path/to/project/source
prefix: source ../python/bin/activate prefix: source ../python/bin/activate
shell: /bin/bash shell: /bin/bash
@ -133,7 +134,7 @@ shell: /bin/bash
### stop ### stop
A `yes` indicates processing should stop if the statement fails to execute with success. It is included by default when the statement is generated, but may be suppressed. Additionally, when [register](#register) is defined, this option will use the result of the command to determine success. This option is also useful for programmatic execution. A `yes` indicates processing should stop if the statement fails to execute with success. If provided, it is included by default when the statement is generated, but may be suppressed. Additionally, when [register](#register) is defined, this option will use the result of the command to determine success. This option is also useful for programmatic execution.
```yaml ```yaml
- check apache configuration: - check apache configuration:
@ -144,7 +145,7 @@ A `yes` indicates processing should stop if the statement fails to execute with
!!! warning !!! warning
Some commands do not provide an zero or non-zero exit code on success or failure. You should verify that the `stop` will actually be used. Some commands do not provide a zero or non-zero exit code on success or failure. You should verify that the `stop` will actually be used.
### sudo ### sudo
@ -186,7 +187,17 @@ sudo: yes
tags: [django, python] tags: [django, python]
``` ```
## Ad Hoc Options With YAML, tags may also be specified like so:
```yaml
- install apache:
install: apache2
tags:
- apache
- web
```
## Ad Hoc Parameters
Options that are not recognized as common or as part of those specific to a command are still processed by the loader. This makes it possible to define your own options based on the needs of a given implementation. Options that are not recognized as common or as part of those specific to a command are still processed by the loader. This makes it possible to define your own options based on the needs of a given implementation.
@ -205,4 +216,34 @@ remote: yes
; and so on ... ; and so on ...
``` ```
This will be of no use as a generated script since the generator does not know about `local` and `remote`, but these could be used programmatically to control whether Python subprocess or an SSH client is invoked. This will be of no use as a generated script since the generator does not know about `local` and `remote`, but these could (for example) be used programmatically to control whether Python subprocess or an SSH client is invoked.
## Template Processing
Commands often need to be specific to an environment or installation. To facilitate this, the configuration file may be parsed as a Jinja2 template prior to processing and generating the statements. This happens automatically when variables are provided.
Template context [may be provided on the command line](../cli.md#context-variables-may-be-provided-on-the-command-line), using a [variables file](variables.md), or both.
In the configuration file:
```ini
; commands.ini
[create the document root of the website]
dir: /var/www/{{ domain_tld }}/www
owner: {{ deploy_user }}
group: {{ webserver_user }}
recursive: yes
```
In the variables file:
```ini
[deploy_user]
value: deploy
[domain_tld]
value: example_com
[webserver_user]
value: www-data
```

@ -0,0 +1,14 @@
# Itemized Commands
It is sometimes useful to create a single command entry that does the same thing with different input. Script Tease facilitates this with the "itemized" command.
```ini
[install common utilities]
install: $item
items: curl, git, lftp, wget
```
In the example above, statements will be generated to install each of the packages named in `items`.
!!! note
Content commands (`explain` and `screenshot`) and Template commands cannot be itemized.

@ -0,0 +1,37 @@
# Templates
Script Tease supports processing of template files using Jinja2.
## Location of Templates
By default, the location of template files are reckoned as relative to the commands configuration file.
```text
package_name/
|-- commands.ini
|-- templates
| `-- httpd.conf
```
Upon loading the `commands.ini` file, any reference to a template file is assumed to be in the `templates/` directory in the same location.
!!! tip
The `-T` switch of the `tease` command may be used to add template locations.
## Template Context
The context variables available to parse the template are:
- Variables received on the command line are included in the context.
- Variables loaded from a file.
- Options passed to the loader from the command line are also included.
Additionally, any unrecognized parameters specified in the command are included in the context. For example:
```ini
[create the httpd.conf file]
template: httpd.conf /etc/apache/sites-available/example.com.conf
ssl_enabled: yes
```
`ssl_enabled` is not a normal parameter for the template command, so it is included in the context.

@ -8,14 +8,23 @@ markdown_extensions:
- def_list - def_list
- pymdownx.superfences - pymdownx.superfences
nav: nav:
- Home: index.md - Introduction: index.md
- Configuration: - Getting Started: getting-started.md
- Command File: config/command-file.md - Topics:
- Variables: config/variables.md - Command File: topics/command-file.md
- Variables File: topics/variables.md
- Itemized Commands: topics/itemized-commands.md
- Templates: topics/templates.md
- How-To:
- Create an Executable Script: how-to/create-executable-script.md
- Define a Custom Command: how-to/define-custom-command.md
- Post a Message to Slack: how-to/post-message-slack.md
- Post a Message to Twist: how-to/post-message-twist.md
- Use Script Tease with Common Kit: how-to/use-with-commonkit.md
- Commands: - Commands:
- Django: commands/django.md - Django: commands/django.md
- MySQL: commands/mysql.md
- Messages: commands/messages.md - Messages: commands/messages.md
- MySQL: commands/mysql.md
- PHP: commands/php.md - PHP: commands/php.md
- Postgres: commands/pgsql.md - Postgres: commands/pgsql.md
- POSIX: commands/posix.md - POSIX: commands/posix.md
@ -23,6 +32,7 @@ nav:
- Profiles: - Profiles:
- CentOS: profiles/centos.md - CentOS: profiles/centos.md
- Ubuntu: profiles/ubuntu.md - Ubuntu: profiles/ubuntu.md
- CLI: cli.md
repo_name: Git Traction repo_name: Git Traction
repo_url: https://gittraction.com/diff6/python-scripttease repo_url: https://gittraction.com/diff6/python-scripttease
theme: theme:

@ -25,7 +25,7 @@ __all__ = (
class Command(object): class Command(object):
def __init__(self, statement, cd=None, comment=None, condition=None, name=None, prefix=None, register=None, stop=False, sudo=None, tags=None, **kwargs): def __init__(self, statement, cd=None, comment=None, condition=None, name=None, prefix=None, register=None, shell=None, stop=False, sudo=None, tags=None, **kwargs):
self.cd = cd self.cd = cd
self.comment = comment self.comment = comment
self.condition = condition self.condition = condition
@ -33,6 +33,7 @@ class Command(object):
self.number = None self.number = None
self.prefix = prefix self.prefix = prefix
self.register = register self.register = register
self.shell = shell
self.statement = statement self.statement = statement
self.stop = stop self.stop = stop
self.tags = tags or list() self.tags = tags or list()

@ -20,8 +20,8 @@ def explain(message, heading=None, **kwargs):
return Content("explain", message=message, heading=heading, **kwargs) return Content("explain", message=message, heading=heading, **kwargs)
def screenshot(image, caption=None, height=None, width=None, **kwargs): def screenshot(image, caption=None, css=None, height=None, width=None, **kwargs):
return Content("screenshot", caption=caption, height=height, image=image, width=width, **kwargs) return Content("screenshot", caption=caption, css=css, height=height, image=image, width=width, **kwargs)
def slack(message, url=None, **kwargs): def slack(message, url=None, **kwargs):

@ -136,7 +136,7 @@ def pgsql_user(name, admin_pass=None, admin_user="postgres", op="create", passwo
command.statement += " -c \"ALTER USER %s WITH ENCRYPTED PASSWORD '%s';\"" % (name, password) command.statement += " -c \"ALTER USER %s WITH ENCRYPTED PASSWORD '%s';\"" % (name, password)
return command return command
elif op == "drop": elif op in ("drop", "remove"):
kwargs.setdefault("comment", "remove %s postgres user" % name) kwargs.setdefault("comment", "remove %s postgres user" % name)
return pgsql("dropuser", name, password=admin_pass, user=admin_user, **kwargs) return pgsql("dropuser", name, password=admin_pass, user=admin_user, **kwargs)

Loading…
Cancel
Save