Commit f38de2d9 authored by Julius Metz's avatar Julius Metz

add some comments, add collectl command to readme

parent dbe9fb83
......@@ -173,6 +173,8 @@ def is_merger(to_check):
Returns:
(bool, str) -- return true if it is a merger false and error if not
"""
# check is tuple with 2 elems
try:
name, mergerkwargs = to_check
except ValueError:
......@@ -217,7 +219,7 @@ def check_valid(to_check, validationinfos):
return is_merger(to_check)
else:
if isinstance(to_check, validationinfos['type']):
if validationinfos['type'] == dict:
if type(to_check) == dict:
if not validationinfos.get('emptyable', False) and not len(to_check):
return False, '{0} can not be empty!'.format(to_check)
......@@ -242,7 +244,7 @@ def check_valid(to_check, validationinfos):
if not valid:
return valid, '[{0}] => {1}'.format(key, error_msg)
if validationinfos['type'] == list or validationinfos['type'] == tuple:
if isinstance(to_check, (list, tuple)):
if not validationinfos.get('emptyable', False) and not len(to_check):
return False, '{0} can not be empty!'.format(to_check)
......@@ -458,21 +460,28 @@ def make_relative_xaxi(all_values):
"""
min_value = min(all_values)
max_value = max(all_values)
# Is the reference value where the next possible value is searched. For a good number of ticks on the axis.
guideline_tickcounts = 10
end_value = (max_value - min_value).total_seconds()
conversion_factor = 1
for current_unit in AXIS_INTERVAL_REL:
# Convert to higher units until the correct one is sufficient
if 'max' in current_unit and end_value > current_unit['max']:
end_value /= current_unit['max']
conversion_factor *= current_unit['max']
continue
# find out the best possible interval
distances = [
max(end_value // interval - guideline_tickcounts, guideline_tickcounts - end_value // interval) \
for interval in current_unit['intervals']
]
interval = current_unit['intervals'][distances.index(min(distances))]
# make array with plotly axis data
xaxis_ticks = [interval * i for i in range(int(end_value/interval)+1)]
if len(xaxis_ticks) == 1:
xaxis_ticks.append(1)
......@@ -666,7 +675,7 @@ def data_from_file(arguments):
@click.command(help='Generate htmlfiles with Plotlyplots with data from collectlfiles(".raw.gz")')
@click.option('--source', '-s', multiple=True, default=['.'], show_default=True, type=click.Path(exists=True), help='source for the plots. (.raw.gz file or directory with .raw.gz) multiple useable')
@click.option('--source', '-s', multiple=True, default=['.'], show_default=True, type=click.Path(exists=True), help='source for the plots. (collectl data(.raw.gz) file or directory with collectl data) multiple useable')
@click.option('--collectl', '-c', default='collectl', show_default=True, help='collectl command')
@click.option('--plotlypath', '-p', type=click.Path(exists=True), help='path to plotly.js')
@click.option('--destination', '-d', default='.', type=click.Path(exists=True), show_default=True, help='path to directory where directory with plots will be created')
......
......@@ -2,7 +2,7 @@
# Collectl2plotly
## How to
For use you need to install it via pip:
To use you need to install it via pip:
```
pip install ./Collectl2plotly
```
......@@ -18,7 +18,7 @@ For informations of the options use "--help" or go to the [options](#options) de
| Option | Takes | Description | Default |
| --------------- | ----- | ------------ | ------- |
| -s, --source | a path to a directory with .raw.gz or .raw.gz file directly. | It is multiple useable! It will be used as collectl sources to get the Plotdata. | If no sources is given as parameter it search in the current dir |
| -s, --source | a path to a directory with collectl datafiles(.raw.gz) or collectl datafile file directly. | It is multiple useable! It will be used as collectl sources to get the Plotdata. | If no sources is given as parameter it search in the current dir |
| -c, --collectl | how to call collectl | is the collectl that will be called to get the data from the sources | collectl without a path |
| -p, --plotlypath | a path to a plotly javascript libery | is needed for the plot in the html files | plotly.js next to skript |
| -d, --destination | a path to a directory | is where a directory with the html files will be created | current directory |
......@@ -30,7 +30,11 @@ For informations of the options use "--help" or go to the [options](#options) de
| --filtervalue | any value (string, int, ...) | is passed to the filter function as string | - |
| --force | - | override existing plot directory if exist | - |
### make collectl source files
Important is "-sZ" with out Collectl2plotly can not get the data from the file for the plots
```
collectl -f <filename that will be created> -i <interval> -sZ
```
## Config
The config is python file with following varibles to create spezial plots or/and with different values instead of the default.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment