Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions atest/resources/cli_output/help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ usage: robotdashboard [[]-v[]] [[]-h[]] [[]-o [[]OUTPUTPATH ...[]][]]
[[]-t DASHBOARDTITLE[]] [[]-m MESSAGECONFIG[]] [[]-q QUANTITY[]]
[[]-u [[]USELOGS[]][]] [[]-g [[]GENERATEDASHBOARD[]][]] [[]-l [[]LISTRUNS[]][]]
[[]--offlinedependencies [[]OFFLINEDEPENDENCIES[]][]]
[[]-c DATABASECLASS[]] [[]-s [[]SERVER[]][]]
[[]--novacuum [[]NOVACUUM[]][]] [[]-c DATABASECLASS[]] [[]-s [[]SERVER[]][]]

options:
-v, --version Display application version information.
Expand Down Expand Up @@ -45,15 +45,16 @@ options:
Examples:
. '--projectversion=1.1'
-r [[]REMOVERUNS ...[]], --removeruns [[]REMOVERUNS ...[]]
`string` Specifies indexes, run_starts, aliases or tags to remove from the database.
`string` Specifies indexes, run_starts, aliases, tags or limit to remove from the database.
Usage behavior:
• Multiple values separated by commas (,)
• Must specify data types: index, run_start, alias or tag
• Must specify data types: index, run_start, alias, tag or limit
• Ranges supported using ':' and lists using ';'
Examples:
• '-r index=0,index=1:4;9,index=10' -> remove index 0, 1, 2, 3, 9, 10
• '-r run_start=2024-07-30 15:27:20.184407,index=20' -> remove specified run and index 20
• '-r alias=some_alias,tag=prod,tag=dev' -> remove all runs with alias some_alias or tag prod or dev
• '-r limit=10' -> remove all runs, leaving only the 10 most recent additions
-d DATABASEPATH, --databasepath DATABASEPATH
`path` Specifies the path to the database file.
Usage behavior:
Expand Down Expand Up @@ -133,6 +134,13 @@ options:
• Using '--offlinedependencies' with no value -> True (reverse default)
• Using '--offlinedependencies true' -> True
• Using '--offlinedependencies false' -> False
--novacuum [[]NOVACUUM[]]
`boolean` Disables automatic database vacuuming.
Usage behavior:
• Default value: False
• Using '--novacuum' with no value -> True (reverse default)
• Using '--novacuum true' -> True
• Using '--novacuum false' -> False
-c DATABASECLASS, --databaseclass DATABASECLASS
`path` Specifies a custom database class to override SQLite.
Usage behavior:
Expand Down
3 changes: 2 additions & 1 deletion atest/resources/cli_output/removerun.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
Removed run from the database: index=-1, run_start=2025-03-13 00:30:06.726165
Removed run from the database: index=6, run_start=2025-03-13 00:24:31.912429
Removed run from the database: run_start=2025-03-13 00:27:39.871333
ERROR: Could not find run to remove from the database: alias=abc
ERROR: Could not find run to remove from the database: alias=abc, check out robotdashboard --help for instructions
WARNING: no runs were removed as no runs were found with tag: tag1
Vacuumed the database in 0.0 seconds
======================================================================================
5. Creating dashboard HTML
created dashboard *
18 changes: 14 additions & 4 deletions docs/basic-command-line-interface-cli.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,19 @@ robotdashboard -f ./results:version_1.1 ./results2:version_2.3.4

## Removing Runs from the Database

### Remove runs by index, run start, alias, or tag
### Remove runs by index, run start, alias, tag, or limit
```bash
robotdashboard -r index=0,index=1:4;9,index=10
robotdashboard --removeruns 'run_start=2024-07-30 15:27:20.184407,index=20'
robotdashboard -r alias=some_cool_alias,tag=prod,tag=dev -r alias=alias12345
robotdashboard -r limit=10
```
- Optional: `-r` or `--removeruns` specifies one or more runs to remove.
- Runs can be identified by index, run_start, alias, or tag.
- Multiple types of identifiers can be used at once.
- Index ranges use `:` for ranges and `;` for singular indexes.
- Multiple values are separated by commas (,).
- Must specify data types: index, run_start, alias, tag or limit.
- Index ranges use `:` for ranges and `;` for lists.
- Quotation marks are required when spaces exist in identifiers.
- With limit=10 only the 10 most recent runs will be kept, all others will be removed.

## Customizing the Dashboard

Expand Down Expand Up @@ -161,6 +163,14 @@ robotdashboard --offlinedependencies True
- By default, urls to the actual JS and CSS CDN are used.
- See [Advanced CLI & Examples](/advanced-cli-examples#offline-dependencies) for more information.

### Disable automatic database vacuuming
```bash
robotdashboard --novacuum
robotdashboard --novacuum True
```
- Optional: `--novacuum` disables automatic database vacuuming.
- Default: False. Using `--novacuum` with no value sets it to True.

### Use a custom database class
```bash
robotdashboard -c ./path/to/custom_class.py
Expand Down
2 changes: 1 addition & 1 deletion docs/dashboard-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ The built-in server exposes several HTTP endpoints to manage and serve dashboard
| `/get-outputs` | Returns a JSON list of stored runs (`run_start`, `alias`, `tags`), callable |
| `/add-outputs` | Accepts new output data via JSON (file path, raw XML or folder), callable |
| `/add-output-file` | Accepts new output data via file input, callable |
| `/remove-outputs` | Deletes runs by index, alias, `run_start`, tags or 'all=true' for all outputs, callable |
| `/remove-outputs` | Deletes runs by index, alias, `run_start`, tags, limit or 'all=true' for all outputs, callable |
| `/get-logs` | Returns a JSON list of stored logs on the server (`log_name`), callable |
| `/add-log` | Upload HTML a log file and associate them with runs (for `uselogs`), callable |
| `/add-log-file` | Upload a HTML log file (for `uselogs`), callable |
Expand Down
35 changes: 8 additions & 27 deletions example/listener/robotdashboardlistener.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,36 +189,17 @@ def _upload_log_file(self):
)

def _remove_runs_over_limit(self):
response = get(f"http://{self.host}:{self.port}/get-outputs")
if response.status_code == 200:
response_json = response.json()
self._print_listener(
f"amount of runs in the database: {len(response_json)}, limit {self.limit}"
if self.limit > 0:
body = {"limit": int(self.limit)}
response = delete(
f"http://{self.host}:{self.port}/remove-outputs", json=body
)
if self.limit != 0 and len(response_json) > self.limit:
amount_to_remove = len(response_json) - self.limit
if response.status_code == 200:
self._print_console_message(response)
else:
self._print_listener(
f"removing {amount_to_remove} run(s) from the database"
)
run_starts = []
for i in range(0, amount_to_remove):
run_starts.append(response_json[i]["run_start"])
body = {"run_starts": run_starts}
response = delete(
f"http://{self.host}:{self.port}/remove-outputs", json=body
f"ERROR something went wrong while deleting the runs from the database: {response.json()}"
)
if response.status_code == 200:
self._print_console_message(response)
else:
self._print_listener(
f"ERROR something went wrong while deleting the runs from the database: {response.json()}"
)
else:
self._print_listener(f"no runs have to be removed")
else:
self._print_listener(
f"ERROR something went wrong while retrieving the outputs from the database: {response.json()}"
)

def _print_listener(self, value: str):
print(f"robotdashboardlistener: {value}")
Expand Down
10 changes: 5 additions & 5 deletions requirements-test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
robotframework==7.3.2
robotframework-pabot==5.1.0
robotframework-browser==19.10.1
robotframework-databaselibrary==2.3.2
robotframework-doctestlibrary==0.28.2
robotframework==7.4.1
robotframework-pabot==5.2.0
robotframework-browser==19.12.4
robotframework-databaselibrary==2.4.1
robotframework-doctestlibrary==0.31.0
26 changes: 19 additions & 7 deletions robotframework_dashboard/arguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,16 @@ def _parse_arguments(self):
"-r",
"--removeruns",
help=(
"`string` Specifies indexes, run_starts, aliases or tags to remove from the database.\n"
"`string` Specifies indexes, run_starts, aliases, tags or limit to remove from the database.\n"
"Usage behavior:\n"
" • Multiple values separated by commas (,)\n"
" • Must specify data types: index, run_start, alias or tag\n"
" • Must specify data types: index, run_start, alias, tag or limit\n"
" • Ranges supported using ':' and lists using ';'\n"
"Examples:\n"
" • '-r index=0,index=1:4;9,index=10' -> remove index 0, 1, 2, 3, 9, 10\n"
" • '-r run_start=2024-07-30 15:27:20.184407,index=20' -> remove specified run and index 20\n"
" • '-r alias=some_alias,tag=prod,tag=dev' -> remove all runs with alias some_alias or tag prod or dev\n"
" • '-r limit=10' -> remove all runs, leaving only the 10 most recent additions\n"
),
action="append",
nargs="*",
Expand Down Expand Up @@ -257,7 +258,6 @@ def _parse_arguments(self):
const=True,
default=False,
)

parser.add_argument(
"-g",
"--generatedashboard",
Expand All @@ -273,7 +273,6 @@ def _parse_arguments(self):
const=False,
default=True,
)

parser.add_argument(
"-l",
"--listruns",
Expand All @@ -289,7 +288,6 @@ def _parse_arguments(self):
const=False,
default=True,
)

parser.add_argument(
"--offlinedependencies",
help=(
Expand All @@ -304,7 +302,20 @@ def _parse_arguments(self):
const=True,
default=False,
)

parser.add_argument(
"--novacuum",
help=(
"`boolean` Disables automatic database vacuuming.\n"
"Usage behavior:\n"
" • Default value: False\n"
" • Using '--novacuum' with no value -> True (reverse default)\n"
" • Using '--novacuum true' -> True\n"
" • Using '--novacuum false' -> False\n"
),
nargs="?",
const=True,
default=False,
)
parser.add_argument(
"-c",
"--databaseclass",
Expand All @@ -319,7 +330,6 @@ def _parse_arguments(self):
),
default=None,
)

parser.add_argument(
"-s",
"--server",
Expand Down Expand Up @@ -398,6 +408,7 @@ def _process_arguments(self, arguments):
force_json_config = self._normalize_bool(
arguments.forcejsonconfig, "forcejsonconfig"
)
no_vacuum = self._normalize_bool(arguments.novacuum, "novacuum")

# generates the datetime used in the file dashboard name and the html title
generation_datetime = datetime.now()
Expand Down Expand Up @@ -498,5 +509,6 @@ def _process_arguments(self, arguments):
"offline_dependencies": offline_dependencies,
"force_json_config": force_json_config,
"project_version": arguments.project_version,
"no_vacuum": no_vacuum,
}
return dotdict(provided_args)
Loading