M118 implemented in virtual printer

I wanted the virtual printer to process M118 gcode commands just like a real printer
it only took two lines of code!

I modified ~/oprint/lib/python2.7/site-packages/octoprint/plugins/virtual_printer/virtual.py

to add this fragment

        def _gcode_M118(self, data):
                # type: (str) -> None
                # strip off leading M118
                # and any whitespace at either end
                self._send(data[4:].strip())

at around line 486 in the code
it slots in between M109 and M140

how can I get this integrated into mainstream code?

Read the contributing guide: OctoPrint/CONTRIBUTING.md

Basically boils down to the below, but make sure you follow the guide above:

  1. Fork the OctoPrint repository at https://github.com/OctoPrint/OctoPrint

  2. Make your changes on your fork, commit and test.

  3. Create a pull request against the maintenance branch

@Charlie_Powell
cheers
v useful links :slight_smile:

1 Like

ok
I have (I think)

  • installed a development environment
  • fork from github
  • made my changes

now trying to test
worked through the instructions
got as far as

  • run the test suite from the checked out source folder via nosetests --with-doctest

nosetest not found
I've had a look around and I can't find it either
any clues?

cheers

found that I had to install Sphinx to be able to run nosetests
didn't spot that anywhere!

now I get a shed-load of errors depending on which folder I cd to before running nosetests
where SHOULD I be ruuning it?

cheers

Have just run it here from the checked out folder ('Repository root') with no issues. This is the folder that contains src, tests, docs, setup.py etc.

Nose should have been installed with OctoPrint in the development environment using pip install .[develop]. You may need to activate the virtual environment to use it.If not install with pip install nose

Also note that OctoPrint is currently in release candidate phase so you may or may not get a response to any pull request quickly.

@Charlie_Powell
thanks for that
I'll try again (more slowly and carefully! :slight_smile:

and no rush from my side

1 Like

Also keep in mind, that OctoPrint is moving over to Python 3

@Ewald_Ikemann
yup noticed that too
luckily my code is version agnostic :slight_smile:

1 Like

Where did you find to run nosetests? Because that means there's somewhere some documentation I forgot to update. OctoPrint switched to pytest.

This should work inside a checkout with activated virtualenv:

pip install -e .[develop]
pytest

@foosel
I started with this link
OctoPrint/CONTRIBUTING.md
which took me to this page
setting up development environment
that mentions nosetests

I'll try pytest now
thanks!

1 Like

Ah, perfect, thanks. I've updated that now: https://docs.octoprint.org/en/master/development/environment.html

2 Likes