imrahil / OctoPrint-PrintHistory

Plugin for OctoPrint - saves filename, print time and filament usage for each print
GNU Affero General Public License v3.0
63 stars 64 forks source link

Unable to Export to CSV #91

Closed Tinkerman61 closed 1 year ago

Tinkerman61 commented 2 years ago

When trying to export the print history to CSV or Excel I get the below error;

"The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."

guysoft commented 2 years ago

Hey. Can you provide the octoprint.log ? Should help determine what error you are getting

Tinkerman61 commented 2 years ago

Hello, attached is my octprint log. Thanks!

octoprint(1).log

guysoft commented 2 years ago

Ok there is indeed an error in the log:

Seems to be a syntax error, let me see if I can fix that.

2021-10-18 14:27:45,765 - octoprint - ERROR - Exception on /plugin/printhistory/export/csv [GET]
Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_printhistory/__init__.py", line 238, in exportHistoryData
    from . import export
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_printhistory/export.py", line 88
    value = formatTimestamp(historyDetails.get(field, '-'))
                                                          ^
TabError: inconsistent use of tabs and spaces in indentation
guysoft commented 2 years ago

Ok fixed, You can upgrade by running on OctoPI:

~/oprint/bin/pip install git+https://github.com/imrahil/OctoPrint-PrintHistory@devel --upgrade

I want to make a release, but it seems the other export options are broken. I can't seem to get the csv extra option to work. Its was written in python2, and python3 does not handle lots of stuff in the same way, and its doing some strange stuff with class declarations which makes it hard to follow.

Tinkerman61 commented 2 years ago

Thank you for the update, Im not sure how to run the command line in OctoPi.

guysoft commented 2 years ago
  1. ssh to octopi . Here is a guide from Vroron, you might find another guide that is simpler, if you use Windows us putty, if linux/mac use ssh: https://voron.dozuki.com/Guide/Connecting+to+your+Raspberry+Pi+via+SSH/2
  2. in the commandline paste the line I wrote above.
Tinkerman61 commented 2 years ago

I ran the command thru PuTTY and get the below error when trying to export to CSV or Excel. I did reboot the server after the install.

{"error":"The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."}

This is the install log:

pi@octopi-Prusa1:~ $ ~/oprint/bin/pip install git+https://github.com/imrahil/Oct oPrint-PrintHistory@devel --upgrade Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting git+https://github.com/imrahil/OctoPrint-PrintHistory@devel Cloning https://github.com/imrahil/OctoPrint-PrintHistory (to revision devel) to /tmp/pip-req-build-si_iwx8z Requirement already satisfied: OctoPrint in ./oprint/lib/python3.7/site-packages (from OctoPrint-PrintHistory==1.3) (1.7.2) Requirement already satisfied: XlsxWriter in ./oprint/lib/python3.7/site-package s (from OctoPrint-PrintHistory==1.3) (3.0.1) Requirement already satisfied: unicodecsv in ./oprint/lib/python3.7/site-package s (from OctoPrint-PrintHistory==1.3) (0.14.1) Requirement already satisfied: wrapt<1.13,>=1.12.1 in ./oprint/lib/python3.7/sit e-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.12.1) Requirement already satisfied: netaddr<0.9,>=0.8 in ./oprint/lib/python3.7/site- packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (0.8.0) Requirement already satisfied: feedparser<7,>=6.0.8 in ./oprint/lib/python3.7/si te-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (6.0.8) Requirement already satisfied: Flask-Assets<3,>=2.0 in ./oprint/lib/python3.7/si te-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (2.0) Requirement already satisfied: cachelib<0.2,>=0.1 in ./oprint/lib/python3.7/site -packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (0.1.1) Requirement already satisfied: sentry-sdk<2,>=1.3.1 in ./oprint/lib/python3.7/si te-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.4.3) Requirement already satisfied: zipstream-new<1.2,>=1.1.8 in ./oprint/lib/python3 .7/site-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.1.8) Requirement already satisfied: colorlog<6,>=5.0.1 in ./oprint/lib/python3.7/site -packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (5.0.1) Requirement already satisfied: netifaces<1,>=0.11 in ./oprint/lib/python3.7/site -packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (0.11.0) Requirement already satisfied: OctoPrint-FileCheck>=2021.2.23 in ./oprint/lib/py thon3.7/site-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (2021.2.23) Requirement already satisfied: psutil<6,>=5.8 in ./oprint/lib/python3.7/site-pac kages (from OctoPrint->OctoPrint-PrintHistory==1.3) (5.8.0) Requirement already satisfied: zeroconf<0.34,>=0.33 in ./oprint/lib/python3.7/si te-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (0.33.4) Requirement already satisfied: unidecode in ./oprint/lib/python3.7/site-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (0.4.21) Requirement already satisfied: Click<8,>=7.1.2 in ./oprint/lib/python3.7/site-pa ckages (from OctoPrint->OctoPrint-PrintHistory==1.3) (7.1.2) Requirement already satisfied: regex!=2018.11.6 in ./oprint/lib/python3.7/site-p ackages (from OctoPrint->OctoPrint-PrintHistory==1.3) (2020.11.13) Requirement already satisfied: pyserial<4,>=3.4 in ./oprint/lib/python3.7/site-p ackages (from OctoPrint->OctoPrint-PrintHistory==1.3) (3.5) Requirement already satisfied: PyYAML<6,>=5.4.1 in ./oprint/lib/python3.7/site-p ackages (from OctoPrint->OctoPrint-PrintHistory==1.3) (5.4.1) Requirement already satisfied: blinker<2,>=1.4 in ./oprint/lib/python3.7/site-pa ckages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.4) Requirement already satisfied: pkginfo<2,>=1.7.1 in ./oprint/lib/python3.7/site- packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.7.1) Requirement already satisfied: OctoPrint-FirmwareCheck>=2021.10.11 in ./oprint/l ib/python3.7/site-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (2021.1 0.11) Requirement already satisfied: semantic-version<3,>=2.8.5 in ./oprint/lib/python 3.7/site-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (2.8.5) Requirement already satisfied: pylru<2,>=1.2 in ./oprint/lib/python3.7/site-pack ages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.2.0) Requirement already satisfied: emoji<2,>=1.4.2 in ./oprint/lib/python3.7/site-pa ckages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.6.1) Requirement already satisfied: filetype<2,>=1.0.7 in ./oprint/lib/python3.7/site -packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.0.7) Requirement already satisfied: watchdog==0.10.4 in ./oprint/lib/python3.7/site-p ackages (from OctoPrint->OctoPrint-PrintHistory==1.3) (0.10.4) Requirement already satisfied: future<1,>=0.18.2 in ./oprint/lib/python3.7/site- packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (0.18.2) Requirement already satisfied: tornado<7,>=6 in ./oprint/lib/python3.7/site-pack ages (from OctoPrint->OctoPrint-PrintHistory==1.3) (6.1) Requirement already satisfied: Jinja2<3,>=2.11.3 in ./oprint/lib/python3.7/site- packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (2.11.3) Requirement already satisfied: markupsafe<2.0,>=1.1 in ./oprint/lib/python3.7/si te-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.1.1) Requirement already satisfied: itsdangerous<2,>=1.1.0 in ./oprint/lib/python3.7/ site-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.1.0) Requirement already satisfied: werkzeug<2,>=1.0.1 in ./oprint/lib/python3.7/site -packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.0.1) Requirement already satisfied: immutabledict<3,>=2.1 in ./oprint/lib/python3.7/s ite-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (2.2.1) Requirement already satisfied: Flask-Babel<2,>=1.0 in ./oprint/lib/python3.7/sit e-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.0.0) Requirement already satisfied: flask<2,>=1.1.4 in ./oprint/lib/python3.7/site-pa ckages (from OctoPrint->OctoPrint-PrintHistory==1.3) (1.1.4) Requirement already satisfied: markdown<3.2,>=3.1 in ./oprint/lib/python3.7/site -packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (3.1.1) Requirement already satisfied: pathvalidate<3,>=2.4.1 in ./oprint/lib/python3.7/ site-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (2.5.0) Requirement already satisfied: websocket-client<1,>=0.59 in ./oprint/lib/python3 .7/site-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (0.59.0) Requirement already satisfied: sarge==0.1.6 in ./oprint/lib/python3.7/site-packa ges (from OctoPrint->OctoPrint-PrintHistory==1.3) (0.1.6) Requirement already satisfied: OctoPrint-PiSupport>=2021.10.28 in ./oprint/lib/p ython3.7/site-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (2021.10.28 ) Requirement already satisfied: requests<3,>=2.26.0 in ./oprint/lib/python3.7/sit e-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (2.26.0) Requirement already satisfied: Flask-Login<0.6,>=0.5 in ./oprint/lib/python3.7/s ite-packages (from OctoPrint->OctoPrint-PrintHistory==1.3) (0.5.0) Requirement already satisfied: pathtools>=0.1.1 in ./oprint/lib/python3.7/site-p ackages (from watchdog==0.10.4->OctoPrint->OctoPrint-PrintHistory==1.3) (0.1.2) Requirement already satisfied: sgmllib3k in ./oprint/lib/python3.7/site-packages (from feedparser<7,>=6.0.8->OctoPrint->OctoPrint-PrintHistory==1.3) (1.0.0) Requirement already satisfied: webassets>=2.0 in ./oprint/lib/python3.7/site-pac kages (from Flask-Assets<3,>=2.0->OctoPrint->OctoPrint-PrintHistory==1.3) (2.0) Requirement already satisfied: pytz in ./oprint/lib/python3.7/site-packages (fro m Flask-Babel<2,>=1.0->OctoPrint->OctoPrint-PrintHistory==1.3) (2020.5) Requirement already satisfied: Babel>=2.3 in ./oprint/lib/python3.7/site-package s (from Flask-Babel<2,>=1.0->OctoPrint->OctoPrint-PrintHistory==1.3) (2.9.0) Requirement already satisfied: setuptools>=36 in ./oprint/lib/python3.7/site-pac kages (from markdown<3.2,>=3.1->OctoPrint->OctoPrint-PrintHistory==1.3) (51.1.2) Requirement already satisfied: idna<4,>=2.5 in ./oprint/lib/python3.7/site-packa ges (from requests<3,>=2.26.0->OctoPrint->OctoPrint-PrintHistory==1.3) (2.10) Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./oprint/lib/python3.7/s ite-packages (from requests<3,>=2.26.0->OctoPrint->OctoPrint-PrintHistory==1.3) (1.26.2) Requirement already satisfied: charset-normalizer~=2.0.0 in ./oprint/lib/python3 .7/site-packages (from requests<3,>=2.26.0->OctoPrint->OctoPrint-PrintHistory==1 .3) (2.0.7) Requirement already satisfied: certifi>=2017.4.17 in ./oprint/lib/python3.7/site -packages (from requests<3,>=2.26.0->OctoPrint->OctoPrint-PrintHistory==1.3) (20 20.12.5) Requirement already satisfied: six in ./oprint/lib/python3.7/site-packages (from websocket-client<1,>=0.59->OctoPrint->OctoPrint-PrintHistory==1.3) (1.15.0) Requirement already satisfied: ifaddr>=0.1.7 in ./oprint/lib/python3.7/site-pack ages (from zeroconf<0.34,>=0.33->OctoPrint->OctoPrint-PrintHistory==1.3) (0.1.7) WARNING: You are using pip version 20.3.3; however, version 21.3.1 is available. You should consider upgrading via the '/home/pi/oprint/bin/python3 -m pip instal l --upgrade pip' command. pi@octopi-Prusa1:~ $ ^C

Tinkerman61 commented 2 years ago

Not sure why the lines above have a strikethrough after posting.

guysoft commented 2 years ago

They did that because markdown uses notations. When posting code you should add before it ```. and again after it ```. That way the code would look like this:

this is code unchanged

Looks like it worked, restart your OctoPrint service (or just reboot), and test the export.

The export to CSV was fixed, not the export to excel, I hadn't figured how to do that yet.

Tinkerman61 commented 2 years ago

When trying the CSV export, I am getting the below error

"The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application." "The server encountered a…ror in the application."

guysoft commented 2 years ago

That error means there is another error in your octoprint.log. I can't understand what the error is without seeing that. Can you please provide your octoprint.log?

Thanks.

Tinkerman61 commented 2 years ago

Attached is my octoprint log octoprint log.txt .

guysoft commented 2 years ago

Error from the log is:

Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_printhistory/__init__.py", line 238, in exportHistoryData
    from . import export
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_printhistory/export.py", line 88
    value = formatTimestamp(historyDetails.get(field, '-'))
                                                          ^
TabError: inconsistent use of tabs and spaces in indentation

However that is line 100 in the code at the moment, as seen here: https://github.com/imrahil/OctoPrint-PrintHistory/blob/devel/octoprint_printhistory/export.py#L100

So you are not running an up to date version of the plugin, please make sure you installed it and tested again.

Nicoautoxp commented 2 years ago

Hi, i also wanted to use the export function but i get the following error: "The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application."

I performed the upgrade as you mentioned in one of the above post but it didn't seem to work.

Here you can find the log file: octoprint.log Any advice on how to proceed?

guysoft commented 2 years ago

@Nicoautoxp This is the error in the plugin:

Traceback (most recent call last):
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/pi/oprint/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_printhistory/__init__.py", line 238, in exportHistoryData
    from . import export
  File "/home/pi/oprint/lib/python3.7/site-packages/octoprint_printhistory/export.py", line 88
    value = formatTimestamp(historyDetails.get(field, '-'))
    TabError: inconsistent use of tabs and spaces in indentation                                                      ^

There is a syntax error in the file. That whole area needs to be reweworked, I am kinda busy to fix it atm

guysoft commented 2 years ago

@Nicoautoxp I jsut had a look, there arn't any tabs there. please make sure you are using the latest version of the plugin

Nicoautoxp commented 2 years ago

@guysoft no problem i wasn't sure if i maybe had missed something. I'm on version 1.3 at the moment i thought that this was the latest or is there a newer version?

chrineuh commented 1 year ago

Hello,

I have the same Problem with Octoprint History Plugin, dose someone have an solution. Thanks

guysoft commented 1 year ago

Fixed in #92 :) Will release soon