Skip to content

Commit

Permalink
Merge pull request #2 from foosel/devel
Browse files Browse the repository at this point in the history
update my fork
  • Loading branch information
javivi001 committed Aug 15, 2015
2 parents cc62e49 + 833a618 commit 0101f0b
Show file tree
Hide file tree
Showing 31 changed files with 1,022 additions and 356 deletions.
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,31 @@
(like the Software Update Plugin or the Plugin Manager) and core functionality
to perform these common administrative tasks without the user needing to define
everything redundantly.
* `pip` helper now adjusts `pip install` parameters corresponding to detected
`pip` version:
* Removes `--process-dependency-links` when it's not needed
* Adds `--no-use-wheel` when it's needed
* Detects and reports on completely broken versions
* Better tracking of printer connection state for plugins and scripts:
* Introduced three new Events `Connecting`, `Disconnecting` and
`PrinterStateChanged`.
* Introduced new GCODE script `beforePrinterDisconnected` which will get sent
before a (controlled) disconnect from the printer. This can be used to send
some final commands to the printer before the connection goes down, e.g.
`M117 Bye from OctoPrint`.
* The communication layer will now wait for the send queue to be fully processed
before disconnecting from the printer for good. This way it is ensured that
the `beforePrinterDisconnected` script or any further GCODE injected into it
will actually get sent.
* Additional baud rates to allow for connecting can now be specified along side
additional serial ports via the settings dialog and the configuration file.
* Documentation improvements

### Bug Fixes

* It's not possible anymore to select files that are not machinecode files (e.g.
GCODE) for printing on the file API.
* Changes to a user's personal settings via the UI now propagate across sessions.

## 1.2.4 (2015-07-23)

Expand Down
26 changes: 26 additions & 0 deletions docs/configuration/config_yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -611,6 +611,32 @@ Use the following settings to configure the serial connection to the printer:
additionalPorts:
- /dev/myPrinterSymlink
# Use this to define additional baud rates to offer for connecting to serial ports. Must be a
# valid integer. Defaults to not set
additionalBaudrates:
- 123456
# Commands which are known to take a long time to be acknowledged by the firmware. E.g.
# homing, dwelling, auto leveling etc. Defaults to the below commands.
longRunningCommands:
- G4
- G28
- G29
- G30
- G32
- M400
- M226
# Commands which need to always be send with a checksum. Defaults to only M110
checksumRequiringCommands:
- M110
# Command to send in order to initiate a handshake with the printer.
# Defaults to "M110 N0" which simply resets the line numbers in the firmware and which
# should be acknowledged with a simple "ok".
helloCommand:
- M110 N0
.. _sec-configuration-config_yaml-server:

Server
Expand Down
17 changes: 17 additions & 0 deletions docs/events/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ ClientClosed
Printer communication
---------------------

Connecting
The server is attempting to connect to the printer.

Connected
The server has connected to the printer.

Expand All @@ -114,6 +117,11 @@ Connected
* ``port``: the connected serial port
* ``baudrate``: the baud rate

Disconnecting
The server is going to disconnect from the printer. Note that this
event might not always be sent when the server and printer get disconnected
from each other. Do not depend on this for critical life cycle management.

Disconnected
The server has disconnected from the printer

Expand All @@ -124,6 +132,15 @@ Error

* ``error``: the error string

PrinterStateChanged
The state of the printer changed.

Payload:

* ``state_id``: Id of the new state. See
:func:`~octoprint.printer.PrinterInterface.get_state_id` for possible values.
* ``state_string``: Text representation of the new state.

File handling
-------------

Expand Down
4 changes: 4 additions & 0 deletions docs/features/gcode_scripts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ Predefined Scripts
The following GCODE scripts are sent by OctoPrint automatically:

* ``afterPrinterConnected``: Sent after OctoPrint successfully connected to a printer. Defaults to an empty script.
* ``beforePrinterDisconnected``: Sent just before OctoPrint (actively) closes the connection to the printer. Defaults
to an empty script. Note that this will *not* be sent for unexpected connection cut offs, e.g. in case of errors
on the serial line, only when the user clicks the "Disconnect" button or the printer requests a disconnect via an
:ref:`action command <sec-features-action_commands>` .
* ``beforePrintStarted``: Sent just before a print job is started. Defaults to an empty script.
* ``afterPrintCancelled``: Sent just after a print job was cancelled. Defaults to the
:ref:`bundled script listed below <sec-features-gcode_scripts-bundled>`.
Expand Down
5 changes: 5 additions & 0 deletions src/octoprint/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,14 @@ class Events(object):
STARTUP = "Startup"

# connect/disconnect to printer
CONNECTING = "Connecting"
CONNECTED = "Connected"
DISCONNECTING = "Disconnecting"
DISCONNECTED = "Disconnected"

# State changes
PRINTER_STATE_CHANGED = "PrinterStateChanged"

# connect/disconnect by client
CLIENT_OPENED = "ClientOpened"
CLIENT_CLOSED = "ClientClosed"
Expand Down
6 changes: 5 additions & 1 deletion src/octoprint/filemanager/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ def register_slicingprogress_callback(self, callback):
self._slicing_progress_callbacks.append(callback)

def unregister_slicingprogress_callback(self, callback):
self._slicing_progress_callbacks.remove(callback)
try:
self._slicing_progress_callbacks.remove(callback)
except ValueError:
# callback was not registered
pass

def _determine_analysis_backlog(self, storage_type, storage_manager):
counter = 0
Expand Down
11 changes: 8 additions & 3 deletions src/octoprint/plugins/softwareupdate/updaters/pip.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import pkg_resources

from octoprint.util.pip import PipCaller, UnknownPip
from .. import exceptions

logger = logging.getLogger("octoprint.plugins.softwareupdate.updaters.pip")
console_logger = logging.getLogger("octoprint.plugins.softwareupdate.updaters.pip.console")
Expand Down Expand Up @@ -41,7 +42,7 @@ def perform_update(target, check, target_version, log_cb=None):

pip_caller = _get_pip_caller(command=pip_command)
if pip_caller is None:
raise RuntimeError("Can't run pip")
raise exceptions.UpdateError("Can't run pip", None)

def _log_call(*lines):
_log(lines, prefix=" ", stream="call")
Expand Down Expand Up @@ -70,11 +71,15 @@ def _log(lines, prefix=None, stream=None):
if "dependency_links" in check and check["dependency_links"]:
pip_args += ["--process-dependency-links"]

pip_caller.execute(*pip_args)
returncode, stdout, stderr = pip_caller.execute(*pip_args)
if returncode != 0:
raise exceptions.UpdateError("Error while executing pip install", (stdout, stderr))

logger.debug(u"Target: %s, executing pip install %s --ignore-reinstalled --force-reinstall --no-deps" % (target, install_arg))
pip_args += ["--ignore-installed", "--force-reinstall", "--no-deps"]

pip_caller.execute(*pip_args)
returncode, stdout, stderr = pip_caller.execute(*pip_args)
if returncode != 0:
raise exceptions.UpdateError("Error while executing pip install --force-reinstall", (stdout, stderr))

return "ok"
9 changes: 8 additions & 1 deletion src/octoprint/plugins/virtual_printer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ def virtual_printer_factory(self, comm_instance, port, baudrate, read_timeout):
if not self._settings.global_get_boolean(["devel", "virtualPrinter", "enabled"]):
return None

import logging
import logging.handlers

seriallog_handler = logging.handlers.RotatingFileHandler(self._settings.get_plugin_logfile_path(postfix="serial"), maxBytes=2*1024*1024)
seriallog_handler.setFormatter(logging.Formatter("%(asctime)s %(message)s"))
seriallog_handler.setLevel(logging.DEBUG)

from . import virtual
serial_obj = virtual.VirtualPrinter(read_timeout=float(read_timeout))
serial_obj = virtual.VirtualPrinter(seriallog_handler=seriallog_handler, read_timeout=float(read_timeout))
return serial_obj

__plugin_name__ = "Virtual Printer"
Expand Down
Loading

0 comments on commit 0101f0b

Please sign in to comment.