Giter Site home page Giter Site logo

hexadecimaldinosaur / octoprint-cli Goto Github PK

View Code? Open in Web Editor NEW
38.0 38.0 6.0 895 KB

Command line client for controlling your OctoPrint 3D printer server

License: GNU General Public License v3.0

Python 100.00%
3d-printing cli command-line octoprint octoprint-api octoprint-client python

octoprint-cli's Introduction

Hi there 👋

email pgp site

I'm Ivy Fan-Chiang, a student studying Computer Science at the University of Waterloo. Many of my programming projects can be found here under this profile. I am interested in computer science, cybersecurity, music, and 3D printing.

My website can be found at ivyfanchiang.ca

My open source projects are currently scattered between GitHub under this account and on Codeberg

Tools, Languages, and Frameworks

python java bash html javascript jinja terraform latex neovim flask django FastAPI Pandas NumPy PostgreSQL Linux Arch Linux Raspberry Pi Arduino

octoprint-cli's People

Contributors

hexadecimaldinosaur avatar imgbotapp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

octoprint-cli's Issues

Exception on first execution after install

Getting exception in decorating_function on first execution. Have installed with pip and separately from git. If install is corrupt, neither method gave any indication.

pi@octopi:~/src/octoprint-cli $ octoprint-cli
Traceback (most recent call last):
File "/home/pi/.local/bin/octoprint-cli", line 33, in
sys.exit(load_entry_point('octoprint-cli==3.3.2', 'console_scripts', 'octoprint-cli')())
File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli-3.3.2-py3.7.egg/octoprint_cli/main.py", line 887, in main
File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli-3.3.2-py3.7.egg/octoprint_cli/api.py", line 57, in connectionTest
TypeError: decorating_function() takes 1 positional argument but 2 were given
pi@octopi:~/src $ python3 --version
Python 3.7.3

TypeError: unsupported operand type(s) for //: 'NoneType' and 'int'

Describe the bug
TypeError: unsupported operand type(s) for //: 'NoneType' and 'int'

This fails on BOTH fedora 34 and my raspberry pi that is running octopi

To Reproduce
octoprint-cli print status


octoprint-cli print status
Printing
File: PIKVM_Case_Bottom_3h55m_0.16mm_205C_PLA_ENDER3.gcode
Traceback (most recent call last):
  File "/opt/anaconda3/bin/octoprint-cli", line 8, in <module>
    sys.exit(main())
  File "/opt/anaconda3/lib/python3.7/site-packages/octoprint_cli/__main__.py", line 896, in main
    options.func(options)
  File "/opt/anaconda3/lib/python3.7/site-packages/octoprint_cli/__main__.py", line 290, in print_status
    jobPrint()
  File "/opt/anaconda3/lib/python3.7/site-packages/octoprint_cli/__main__.py", line 272, in jobPrint
    attrs=['bold']) + caller.getTotalTime())
  File "/opt/anaconda3/lib/python3.7/site-packages/octoprint_cli/api.py", line 90, in getTotalTime
    hours = int(time//3600)
TypeError: unsupported operand type(s) for //: 'NoneType' and 'int'

Expected behavior
not fail... give good results.

Environment Information:

  • OS: Fedora 34 and Raspberry Pi running octopi
  • Version 3.3.1
  • Python Version: 3.7.6 ( fedora 34)
  • Python Version: 3.7.3 ( raspberrry pi )
  • Dependency versions
  • OctoPrint version: 1.6.1
  • 3D Printer Model: Ender 3

Additional context
other commands work fine:
octoprint-cli files list
octoprint-cli continuous
octoprint-cli version
... the octoprint-cli print status is the only command that I know fails... but I didn't run all the commands.

TypeError: Expected maxsize to be an integer or None

Describe the bug
I get this TypeError when I try using it;
TypeError: Expected maxsize to be an integer or None
Not sure if I missed something, but it worked fine on my previous Pi (I have upgraded to a Pi 4 from 3).

Full output
pi@octopi:~/.config $ octoprint-cli version
Traceback (most recent call last):
  File "/home/pi/.local/bin/octoprint-cli", line 33, in <module>
    sys.exit(load_entry_point('octoprint-cli==3.3.2', 'console_scripts', 'octoprint-cli')())
  File "/home/pi/.local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 474, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/pi/.local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2846, in load_entry_point
    return ep.load()
  File "/home/pi/.local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2450, in load
    return self.resolve()
  File "/home/pi/.local/lib/python3.7/site-packages/pkg_resources/__init__.py", line 2456, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli-3.3.2-py3.7.egg/octoprint_cli/__main__.py", line 12, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli-3.3.2-py3.7.egg/octoprint_cli/api.py", line 6, in <module>
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli-3.3.2-py3.7.egg/octoprint_cli/api.py", line 19, in api
  File "/usr/lib/python3.7/functools.py", line 477, in lru_cache
    raise TypeError('Expected maxsize to be an integer or None')
TypeError: Expected maxsize to be an integer or None

To Reproduce
Steps to reproduce the behavior:

  1. git clone
  2. python3 setup.py install --user
  3. octoprint-cli version

Expected behavior
No errors

Environment Information:

  • OS: Latest OctoPi image - Version 0.18.0, running on a Pi 4 Model B Rev 1.1
  • Version: git
  • Python Version: 3.7
  • Dependency versions: termcolor 1.1.0 + requests 2.25.1
  • OctoPrint version: 1.6.1
  • 3D Printer Model: Creality Ender 3 Pro

Client just gives errors when executing any command

Describe the bug
I don't even know what it is... And sorry for the title...

I tried octoprint-cli system restart and other commands, and this happened:

ccomm@Sobotka:~$ octoprint-cli system restart
Traceback (most recent call last):
  File "/home/ccomm/.local/lib/python3.8/site-packages/octoprint_cli/__main__.py", line 639, in main
    if config['preferences']['UpdateCheck'] == 'true':
  File "/usr/lib/python3.8/configparser.py", line 1254, in __getitem__
    raise KeyError(key)
KeyError: 'UpdateCheck'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/ccomm/.local/bin/octoprint-cli", line 8, in <module>
    sys.exit(main())
  File "/home/ccomm/.local/lib/python3.8/site-packages/octoprint_cli/__main__.py", line 642, in main
    updateCheck()
  File "/home/ccomm/.local/lib/python3.8/site-packages/octoprint_cli/__main__.py", line 635, in updateCheck
    if v(request.json()['tag_name'][1:]) > v(__version__):
  File "/home/ccomm/.local/lib/python3.8/site-packages/octoprint_cli/__main__.py", line 634, in <lambda>
    v = lambda t: tuple(map(int,t.split('.')))
ValueError: invalid literal for int() with base 10: '1-1'

Additional context
The only thing that worked was the command syntax (for example octoprint-cli -h)

Progress bar cursor and layer progress

If you do end up looking at temperature plotting or similar, it would be really cool if you could display an old school cursor on the progress bar

I've been using terminals for decades on servers and mainframes, and many processes use a text based progress bar
that have a spinning cursor at the progress point to give it that real terminal feel. (repeat the characters | - / \ )

Current layer progress would also be a useful addition

Command Usage Wrong

Describe the bug
In the README.md it says octoprint-cli ... , but you would use python3 octoprint-cli.py ...

Additional context
Would fix it with an install script (maybe .sh script) that 1. checks for dependencies and 2. maybe edits .bashrc for alias? (Not that good at programming so I wouldn't take this as the solution..!

Difference in percentage numbers between your app and Octoprint Dashboard app

I see that the percentage remaining number is different between your app and the Octoprint Dashboard plugin. The time remaining values seem close, however.

Thank for this app and having a look this issue.

pi@octipi-01:~ $ date
Wed  7 Sep 18:55:18 PDT 2022
pi@octipi-01:~ $ octoprint-cli print status
Printing
File: AV bottom-body Generic PLA lw 0.4mm lh 0.1mm if 20% ext1 200C bed 60C.aw.gcode
Estimated Total Print Time: 04:07
Estimated Print Time Left: 01:34:33
Progress: 52%
Extruder Temp: 201.21°C
Extruder Target: 200.0°C
Bed Temp: 59.97°C
Bed Target: 60.0°C
pi@octipi-01:~ $

octoprint_remaining_precentage

TypeError in continuous mode during gcode file processing

When octoprint process a very large gcode file to be ready for print (this one is 52.8mb) there appears to be an overflow error.

Continuous mode works fine until you either attempt to start the print, or you load the gcode viewer.
It's at this point that the layer count is generated, along with the expected print time. 582 layers, approx 7 hours in this particular case.

Doesn't happen with smaller files - still testing, but so far anything over 40mb causes the error output below:


Traceback (most recent call last):
  File "/home/pi/.local/bin/octoprint-cli", line 11, in <module>
    load_entry_point('octoprint-cli==3.2.2', 'console_scripts', 'octoprint-cli')()
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli-3.2.2-py3.7.egg/octoprint_cli/__main__.py", line 669, in main
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli-3.2.2-py3.7.egg/octoprint_cli/__main__.py", line 91, in continuous
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli-3.2.2-py3.7.egg/octoprint_cli/api.py", line 68, in getTotalTime
TypeError: unsupported operand type(s) for //: 'NoneType' and 'int'

error while printing

keep getting this errors while printing

pi@octopi:~/octoprint-cli $ octoprint-cli continuous
Printing
Loaded File: ASX1_Part6.gcode
Progress: 15.77%
Traceback (most recent call last):
File "/home/pi/.local/bin/octoprint-cli", line 11, in
load_entry_point('octoprint-cli==3.3.0', 'console_scripts', 'octoprint-cli')()
File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli-3.3.0-py3.7.egg/octoprint_cli/main.py", line 890, in main
File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli-3.3.0-py3.7.egg/octoprint_cli/main.py", line 138, in continuous
File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli-3.3.0-py3.7.egg/octoprint_cli/main.py", line 92, in jobPrint
TypeError: unsupported type for timedelta seconds component: NoneType

For your 'Potential Features' item 'Webcam Stream'

Not a problem report, just some input. First, thank you for your work on this project, a helpful add on to OctoPrint!

For your 'Potential Features' item 'Webcam Stream' :

My work is still in progress, however I mashed up a first version of displaying the output of your program on the video streams I have from two webcams on my AnyCubic Kobra printer. I struggled to get the webcam daemon that OctoPrint uses to display video. So moved to VLC's command line tool cvlc. I added the overlay of some of the data out of your program to the two feeds. Two 640 by 480 video feeds at 15 fps keep a Raspberry Pi 3 4 core at about 60% utilization while OctoPrint is printing. I still have work to do. Below is two examples of cvlc displaying your data and the requisite bash scripts generating the data from your octoprint-cli print status command. I am currently running each of the four tasks in individual tmux sessions. Note, you need to install your app, gawk and vlc on your OctoPrint machine. Good hunting!

#put in tmux session
cvlc -v v4l2:///dev/video2:width=640:height=480:chroma=yuyv:fps=15 --sout '#transcode{vcodec=mp2v,acodec=none,fps=15,sfilter=marq{file=bed.txt,size=-2,color=16776960}}:rtp{mux=ts,sdp=rtsp://:8888/live.sdp}'

#put in tmux session
cvlc -v v4l2:///dev/video0:width=640:height=480:chroma=yuyv:fps=15 --sout '#transcode{vcodec=mp2v,acodec=none,fps=15,sfilter=marq{file=endo.txt,size=-2,color=16776960}}:rtp{mux=ts,sdp=rtsp://:8889/live.sdp}'

# put in tmux session
watch -n 5 "octoprint-cli print status | gawk -F':' '/Extruder Temp: /{print strftime(\"%H:%M:%S \"), \$0; exit}' > endo.txt"

# put in tmux session
watch -n 5 "octoprint-cli print status | gawk -F':' '/Progress: /{print strftime(\"%H:%M:%S \"), \$0; exit}' > bed.txt"

cvlc_example_01

Cannot Define config.ini Path

Discussed in #29

Originally posted by Brettem January 27, 2023
Describe the bug:
I am unable to get octoprint-cli to recognize it's own config file. I created a new directory on my local device and created a config.ini file within it using the template provided. However, no matter how I try to call the -c command I cannot define the config path so no other function will run.

To Reproduce
Steps to reproduce the behavior:

pip install octoprint-cli

octoprint-cli -c .\config.ini
>>>Invalid or Missing Arguments

octoprint-cli -c ".\config.ini"
>>>Invalid or Missing Arguments

octoprint-cli -c=.\config.ini
>>>usage: octoprint-cli [-h] [-c CONFIG_PATH] [-v]
                     {version,continuous,layers,gcode,print,connection,temp,system,files}
                     ...
>>>octoprint-cli: error: invalid choice: '.\\config.ini' (choose from 'version', 'continuous', 'layers', 'gcode', 'print', 'connection', 'temp', 'system', 'file
s')

octoprint-cli version
>>>Configuration file is not complete or does not exist

No matter what I try I am unable to get the app to recognize the config file I created. It appears that the octoprint-cli doesn't like my argument format but I'm not sure how else to configure it if I am just trying to define the path to the config file required for all positional arguments.

Expected behavior:
After cd into directory where created config file is located, run >octoprint-cli -c ".\config.ini" and config path is redefined.

Environment Information:

OS: [e.g. iOS] both OctoPi and Windows 11
Version 3.3.2 (cuurent)
Python Version: 3,8,8
Dependency versions
OctoPrint version: current
3D Printer Model: Prusa i3 Mk3S+

'octoprint-cli is not a valid command'

Describe the bug
After installation, the command is not recognised on Windows or Mac.

To Reproduce
Steps to reproduce the behavior:

  1. Try pip3 install octoprint-cli.
  2. Run octoprint-cli.
  3. You get an error message that the command does not exist.

Expected behavior
I would be able to access the command.

Screenshots
Screenshot 2024-07-08 at 20 16 30

Environment Information:

  • OS: Windows 11 / MacOS Sonoma 14.5
  • Version: 3.3.2 / 3.3.2
  • Python Version: 3.12.4 / 3.10.2
  • Dependency versions: up to date
  • OctoPrint version: latest

Additional context
I have tested this on a git clone version and the same problem arises.
Testing on a random GitHub Codespace I used a few weeks ago worked then.
Yes, config.ini is present.

Have been testing this with @DrygithTheGM as part of our project. On both our computers (see above) it does not work. Help would be greatly appreciated.

Add config to setup.py

Describe the solution you'd like
Use idk input() to ask user for settings in the setup.py script

Describe alternatives you've considered

  • Open the config.ini file in vim or nano after install has finished
  • Print out path from config file

Additional context
Need this because I can't find the directory (htop always shows .local/bin/octoprint-cli, but idk where the config.ini would be)

Crash when print bed turns off

Describe the bug
Script crashes when using octoprint-cli continuous

To Reproduce
Steps to reproduce the behavior:

  1. Turn off heatbed in octoprint settings
  2. For Nr1 goto Settings -> Printer profiles -> Edit your profile -> Printbed & Volume -> Make sure heatbed is turned off

Expected behavior
Script detects that heatbed is turned off

Screenshots
grafik

Additional context
Reproduce-steps could be wrong name, have my instance in german language so I just assume it is what it would translate to

TypeError when run in continuous mode or print status mode

Describe the bug
Running octoprint-cli continuous or octoprint-cli print status results in a traceback with a TypeError

To Reproduce
Steps to reproduce the behavior:

  1. run octoprint-cli

Expected behavior
It should display valid data and keep running.

Screenshots

pi@mpmd-pi:~ $ octoprint-cli continuous
Loaded File: Shape-Box_N150um_PLA_MPMD.gcode
Progress: 52.39%
Traceback (most recent call last):
  File "/home/pi/.local/bin/octoprint-cli", line 10, in <module>
    sys.exit(main())
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli/__main__.py", line 759, in main
    options.func(options)
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli/__main__.py", line 188, in continuous
    jobPrint()
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli/__main__.py", line 164, in jobPrint
    print(colored("Estimated Print Time: ", attrs=['bold']) + str(datetime.timedelta(seconds=data['job']['estimatedPrintTime'])).split(".")[0])
TypeError: unsupported type for timedelta seconds component: NoneType
pi@mpmd-pi:~ $ octoprint-cli print status
Printing
File: Shape-Box_N150um_PLA_MPMD.gcode
Traceback (most recent call last):
  File "/home/pi/.local/bin/octoprint-cli", line 10, in <module>
    sys.exit(main())
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli/__main__.py", line 759, in main
    options.func(options)
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli/__main__.py", line 299, in print_status
    jobPrint()
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli/__main__.py", line 285, in jobPrint
    print(colored("Estimated Total Print Time: ", attrs=['bold']) + caller.getTotalTime())
  File "/home/pi/.local/lib/python3.7/site-packages/octoprint_cli/__main__.py", line 86, in getTotalTime
    hours = int(time//3600)
TypeError: unsupported operand type(s) for //: 'NoneType' and 'int'

Environment Information:

  • OS: Octopi 0.17 based on Raspbian GNU/Linux 10 (buster) with Octoprint running python3 via the Blog entry conversion script.
  • Version: 3.2.0.post3
  • Python Version: Python 3.7.3
  • Dependency versions: requests-2.25.1, termcolor-1.1.0
  • OctoPrint version: 1.5.2, running under python3
  • 3D Printer Model: Monoprice MiniDelta with MPMD_Marlin-1.1.x firmware

Additional context
Other commands seem to work ok. Just not octoprint-cli print status or octoprint-cli continuous

pi@mpmd-pi:~ $ octoprint-cli temp status
Extruder Temp: 194.97°C
Extruder Target: 195.0°C
Bed Temp: 60.13°C
Bed Target: 60.0°C
pi@mpmd-pi:~ $ octoprint-cli connection status
Printing
Printer Profile: MPMD
Port: /dev/ttyACM0
Baudrate: 115200
pi@mpmd-pi:~ $ octoprint-cli system status
usage: octoprint-cli system [-h] {restart,restart-safe,reboot,shutdown} ...
octoprint-cli system: error: invalid choice: 'status' (choose from 'restart', 'restart-safe', 'reboot', 'shutdown')
pi@mpmd-pi:~ $ octoprint-cli files status
usage: octoprint-cli files [-h] {list,info,upload} ...
octoprint-cli files: error: invalid choice: 'status' (choose from 'list', 'info', 'upload')
pi@mpmd-pi:~ $ octoprint-cli files list
NAME                                 TYPE           SIZE
Landy                                folder
calibration                          folder
2xtire_mpmd_N150um_PLA_MPMD.gcode    machinecode    8.43 MB
Shape-Box_N150um_PLA_MPMD.gcode      machinecode    0.12 MB
tire_mpmd_n150um_pla_mpmd.gcode      machinecode    4.29 MB
wheel-rim_n150um_pla_mpmd.gcode      machinecode    4.45 MB

Free space: 25.664 GB

"Octoprint server cannot be reached

Describe the bug
A clear and concise description of what the bug is.

Hopefully this is user error, but getting a "Octoprint server cannot be reached" message upon launching the app. I use the same address and API key with multiple other apps to connect to the Octoprint instance, all working normally.

To Reproduce
Steps to reproduce the behavior:

  1. Go to '...'

  2. Click on '....'

  3. Scroll down to '....'

  4. See error

  5. pip3 install octoprint-cli

  6. create config file (~/.config/octoprint-cli) copied from sample config file. I have tried all imaginable permutations of my server address (with and without http and https, using .local name and local ip, as well as localhost running from RPi) and both my user and system API key. Also tried no quotes, soft quotes, and hard quotes around server name and api key values. Having reviewed the code, it looks like it should be able to handle my server address with/without http/https prefixes....

Expected behavior
A clear and concise description of what you expected to happen.
I enter server address and api key and running octoprint-cli connects to my Octoprint instance.

Screenshots
If applicable, add screenshots to help explain your problem.

Environment Information:

  • OS: [e.g. iOS] both OctoPi and MacOS
  • Version [e.g. 22] just downloaded (does not output version when octoprint-cli version is issued, only above error message
  • Python Version: [e.g. 3.8] 3.7.3
  • Dependency versions
  • OctoPrint version: current
  • 3D Printer Model: Chiron w/ Marlin 2 sometimes, Klipper other times
    I've tried this on MacOS and RPi (running from OctoPi image)

Additional context
Add any other context about the problem here.

Happy to provide any logs/etc, just not sure what would be useful here...

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.