m110 / grafcli

Grafana CLI for quick and easy dashboards management.
MIT License
168 stars 20 forks source link

Getting Python Error But Nothing Meaningful #25

Closed mhobotpplnet closed 5 years ago

mhobotpplnet commented 6 years ago

Am trying to do simple backup and followed instructions as specified. I can do an ls , vi and everything with the dashboards, but I can not for some odd reason do a backup

I get this error regardless of system path I specify

[/]> backup /remote/localhost/ /Users/myusername/tmp
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/climb/core.py", line 56, in run
    result = self.execute(*shlex.split(command))
  File "/usr/local/lib/python3.6/site-packages/climb/core.py", line 79, in execute
    return self._commands.execute(command, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/climb/commands.py", line 26, in execute
    return method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/grafcli/commands.py", line 213, in backup
    self.file_export(doc_path, file_path)
  File "/usr/local/lib/python3.6/site-packages/grafcli/commands.py", line 244, in file_export
    document = self._resources.get(path)
  File "/usr/local/lib/python3.6/site-packages/grafcli/resources/resources.py", line 46, in get
    return manager.get(*parts)
  File "/usr/local/lib/python3.6/site-packages/grafcli/resources/common.py", line 33, in get
    dashboard = self._storage.get(dashboard_name)
  File "/usr/local/lib/python3.6/site-packages/grafcli/storage/api.py", line 45, in get
    return Dashboard(source['dashboard'], dashboard_id)
  File "/usr/local/lib/python3.6/site-packages/grafcli/documents.py", line 95, in __init__
    self._load(source)
  File "/usr/local/lib/python3.6/site-packages/grafcli/documents.py", line 101, in _load
    for row in source['rows']:

Worth to mention this is Grafana 5.0 -- so that might be the issue.

mhobotpplnet commented 6 years ago

Also tried with the new branch element -5

Got bit diff error regardless of where or how I try to backup

Traceback (most recent call last):
  File "/usr/local/bin/grafcli", line 4, in <module>
    __import__('pkg_resources').run_script('grafcli===0.6.0-1-ge910b68', 'grafcli')
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 750, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 1534, in run_script
    exec(script_code, namespace, namespace)
  File "/usr/local/lib/python3.6/site-packages/grafcli-0.6.0_1_ge910b68-py3.6.egg/EGG-INFO/scripts/grafcli", line 27, in <module>
  File "/usr/local/lib/python3.6/site-packages/grafcli-0.6.0_1_ge910b68-py3.6.egg/EGG-INFO/scripts/grafcli", line 13, in main
  File "/usr/local/lib/python3.6/site-packages/climb/core.py", line 79, in execute
    return self._commands.execute(command, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/climb/commands.py", line 26, in execute
    return method(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/grafcli-0.6.0_1_ge910b68-py3.6.egg/grafcli/commands.py", line 213, in backup
  File "/usr/local/lib/python3.6/site-packages/grafcli-0.6.0_1_ge910b68-py3.6.egg/grafcli/commands.py", line 244, in file_export
  File "/usr/local/lib/python3.6/site-packages/grafcli-0.6.0_1_ge910b68-py3.6.egg/grafcli/resources/resources.py", line 46, in get
  File "/usr/local/lib/python3.6/site-packages/grafcli-0.6.0_1_ge910b68-py3.6.egg/grafcli/resources/common.py", line 33, in get
  File "/usr/local/lib/python3.6/site-packages/grafcli-0.6.0_1_ge910b68-py3.6.egg/grafcli/storage/api.py", line 45, in get
  File "/usr/local/lib/python3.6/site-packages/grafcli-0.6.0_1_ge910b68-py3.6.egg/grafcli/documents.py", line 95, in __init__
  File "/usr/local/lib/python3.6/site-packages/grafcli-0.6.0_1_ge910b68-py3.6.egg/grafcli/documents.py", line 101, in _load
KeyError: 'rows'
bartwo commented 6 years ago
Traceback (most recent call last):
  File "/home/bwouters/.local/bin/grafcli", line 27, in <module>
    sys.exit(main())
  File "/home/bwouters/.local/bin/grafcli", line 13, in main
    result = cli.execute(*sys.argv[1:])
  File "/home/bwouters/.local/lib/python3.6/site-packages/climb/core.py", line 79, in execute
    return self._commands.execute(command, **kwargs)
  File "/home/bwouters/.local/lib/python3.6/site-packages/climb/commands.py", line 26, in execute
    return method(*args, **kwargs)
  File "/home/bwouters/.local/lib/python3.6/site-packages/grafcli/commands.py", line 244, in file_export
    document = self._resources.get(path)
  File "/home/bwouters/.local/lib/python3.6/site-packages/grafcli/resources/resources.py", line 46, in get
    return manager.get(*parts)
  File "/home/bwouters/.local/lib/python3.6/site-packages/grafcli/resources/common.py", line 33, in get
    dashboard = self._storage.get(dashboard_name)
  File "/home/bwouters/.local/lib/python3.6/site-packages/grafcli/storage/api.py", line 45, in get
    return Dashboard(source['dashboard'], dashboard_id)
  File "/home/bwouters/.local/lib/python3.6/site-packages/grafcli/documents.py", line 95, in __init__
    self._load(source)
  File "/home/bwouters/.local/lib/python3.6/site-packages/grafcli/documents.py", line 101, in _load
    for row in source['rows']:
KeyError: 'rows'

Also have this issue by the looks of it

nkovacne commented 5 years ago

I made a workaround to avoid the failure, not sure if it breaks something, though. The grafcli command ends correctly.

# diff /usr/lib/python3.4/site-packages/grafcli/documents.py /root/documents.py 
101,103c101,102
<         if 'rows' in source:
<             for row in source['rows']:
<                 self._add_row(row)
---
>         for row in source['rows']:
>             self._add_row(row)
m110 commented 5 years ago

Will be resolved within #24