Compare commits

...
17 Commits
Author SHA1 Message Date
Gina Häußge f9a9a405cd About time to declare this as a stable version, should have done this ages
ago...
2014-06-22 00:42:03 +02:00
Gina Häußge fa564c6029 Insert src folder at first position of sys.path 2014-06-21 20:16:53 +02:00
Gina Häußge 36d1522f01 Merge pull request #475 from Salandora/master
Bug fix for Emergency Stop
2014-05-22 21:53:06 +02:00
Salandora 536e17eac4 Bug fix for Emergency Stop 2014-05-22 17:56:50 +02:00
Gina Häußge 887ec45b6b Create CONTRIBUTING.md 2014-05-19 22:48:41 +02:00
Gina Häußge deb38f8455 Fixed an embarrassing merge error from waaay back. Didn't disrupt operation but caused funny error messages in the log.
Thanks to @nophead for reporting this.

Closes #433
2014-04-18 14:28:52 +02:00
Gina Häußge 293611287e New setting for repetier to always assume SD card is present (since firmware does not report whether initialization succeeded via explicit message)
Fixes #289
2014-03-15 16:30:29 +01:00
Gina Häußge 7ebbf5911c Removed the scary start up message when called via run. I'll just keep that script around for sake of simplicity of running stand alone installations out of the pull dir, so why scare people... 2014-03-15 10:20:19 +01:00
Gina Häußge d7e37cf658 origin is "sd" for files from the SD card, not "sdcard".
Fixes #411
2014-03-13 20:15:29 +01:00
Gina Häußge e068012cfb Fixed a regex matcher
(cherry picked from commit 8fbb304)
2014-03-10 13:04:47 +01:00
Gina Häußge d7f2075b1d Only list those SD files that have a ASCII filename
According to the RepRap protocol we should actually not ever get anything other than those anyways, as the protocol is defined as ASCII-only. In the future there might be a way to somehow handle such files too, for the time being this fixes issues though where non-ascii files on the SD made the whole SD file handling not work.

 Closes #381
(cherry picked from commit b115b6f)
2014-03-09 13:53:39 +01:00
Gina Häußge e5ac94a16f Merge branch 'master' into staging
Conflicts:
	run
	src/octoprint/util/comm.py
2014-03-09 13:47:49 +01:00
Gina Häußge f09d44d8a0 Hopefully fixed a race condition that could occur when pressing "Print" (file not opened yet, but comm layer tries to fetch next command)
Possible fix for #400
2014-03-03 16:58:15 +01:00
Gina Häußge 89cae22b91 Extracted all used regexes in the comm layer and precompiled them
Possible improvement of #390
2014-03-03 09:10:10 +01:00
Gina Häußge 0747336c0f Bugfix: Do not run gcode analyzer when a print is ongoing
Evaluate active flag on gcode analyzer AFTER fetching an item from the work queue, otherwise it will always start working once it finds something if the active flag was true once but then switched to false while the queue was still empty.  Thanks to @Salandora for spotting this.

Fixes #357

(manually cherry-picked from 592f3dc)
2014-02-24 10:00:11 +01:00
Gina Häußge bba625a68f Also recognize --iknowwhatimdoing when running as daemon
Fixes #337
(cherry picked from commit 417487e)
2014-01-09 20:07:27 +01:00
Gina Häußge b282a18f6b Also recognize --iknowwhatimdoing when running as daemon
Fixes #337
2014-01-09 20:06:07 +01:00
13 changed files with 130 additions and 78 deletions

No files matched your search

+13
View File
@@ -0,0 +1,13 @@
Bug Reports
-----------
**READ [How to file a bug report](https://github.com/foosel/OctoPrint/wiki/How-to-file-a-bug-report)!**.
Pull Requests
-------------
1. Please create all pull requests against the `devel` branch.
2. Create **one pull request per feature/bug fix**.
3. Create a custom branch for your feature/bug fix and use that as base for your pull request. Pull requests directly against your version of `devel` will be closed.
4. In your pull request's description, state what your pull request is doing, as in, what feature does it implement, what bug does it fix.
+1 -9
View File
@@ -1,13 +1,5 @@
#!/usr/bin/env python
print """
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!! You are using an old startup method for OctoPrint. !!!
!!! Please perform 'sudo python setup.py install' and !!!
!!! use the 'octoprint' executable instead. !!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
"""
import os
import sys
@@ -24,7 +16,7 @@ I don't know anything about).
"""
os.rename(old, os.path.join(basedir, "octoprint.backup"))
sys.path.append(os.path.join(basedir, "src"))
sys.path.insert(0, os.path.join(basedir, "src"))
import octoprint
octoprint.main()
+1 -1
View File
@@ -3,7 +3,7 @@
from setuptools import setup, find_packages
VERSION = "1.0.0-rc2"
VERSION = "1.0.0"
def params():
name = "OctoPrint"
+5 -3
View File
@@ -3,8 +3,9 @@ import sys
from octoprint.daemon import Daemon
from octoprint.server import Server
class Main(Daemon):
def __init__(self, pidfile, configfile, basedir, host, port, debug):
def __init__(self, pidfile, configfile, basedir, host, port, debug, allowRoot):
Daemon.__init__(self, pidfile)
self._configfile = configfile
@@ -12,9 +13,10 @@ class Main(Daemon):
self._host = host
self._port = port
self._debug = debug
self._allowRoot = allowRoot
def run(self):
octoprint = Server(self._configfile, self._basedir, self._host, self._port, self._debug)
octoprint = Server(self._configfile, self._basedir, self._host, self._port, self._debug, self._allowRoot)
octoprint.run()
def main():
@@ -50,7 +52,7 @@ def main():
print >> sys.stderr, "Sorry, daemon mode is only supported under Linux right now"
sys.exit(2)
daemon = Main(args.pidfile, args.config, args.basedir, args.host, args.port, args.debug)
daemon = Main(args.pidfile, args.config, args.basedir, args.host, args.port, args.debug, args.allowRoot)
if "start" == args.daemon:
daemon.start()
elif "stop" == args.daemon:
+2 -2
View File
@@ -486,8 +486,6 @@ class MetadataAnalyzer:
def _work(self):
aborted = None
while True:
self._active.wait()
if aborted is not None:
filename = aborted
aborted = None
@@ -496,6 +494,8 @@ class MetadataAnalyzer:
(priority, filename) = self._queue.get()
self._logger.debug("Processing file %s from queue (priority %d)" % (filename, priority))
self._active.wait()
try:
self._analyzeGcode(filename)
self._queue.task_done()
-32
View File
@@ -145,38 +145,6 @@ def jog():
length = request.values["extrude"]
printer.commands(["G91", "G1 E%s F%d" % (length, movementSpeedE), "G90"])
movementSpeed = settings().get(["printerParameters", "movementSpeed", ["x", "y", "z"]], asdict=True)
valid_axes = ["x", "y", "z"]
##~~ jog command
if command == "jog":
# validate all jog instructions, make sure that the values are numbers
validated_values = {}
for axis in valid_axes:
if axis in data:
value = data[axis]
if not isinstance(value, (int, long, float)):
return make_response("Not a number for axis %s: %r" % (axis, value), 400)
validated_values[axis] = value
# execute the jog commands
for axis, value in validated_values.iteritems():
# TODO make this a generic method call (printer.jog(axis, value)) to get rid of gcode here
printer.commands(["G91", "G1 %s%.4f F%d" % (axis.upper(), value, movementSpeed[axis]), "G90"])
##~~ home command
elif command == "home":
validated_values = []
axes = data["axes"]
for axis in axes:
if not axis in valid_axes:
return make_response("Invalid axis: %s" % axis, 400)
validated_values.append(axis)
# execute the home command
# TODO make this a generic method call (printer.home(axis, ...)) to get rid of gcode here
printer.commands(["G91", "G28 %s" % " ".join(map(lambda x: "%s0" % x.upper(), validated_values)), "G90"])
return jsonify(SUCCESS)
+2
View File
@@ -56,6 +56,7 @@ def getSettings():
"waitForStart": s.getBoolean(["feature", "waitForStartOnConnect"]),
"alwaysSendChecksum": s.getBoolean(["feature", "alwaysSendChecksum"]),
"sdSupport": s.getBoolean(["feature", "sdSupport"]),
"sdAlwaysAvailable": s.getBoolean(["feature", "sdAlwaysAvailable"]),
"swallowOkAfterResend": s.getBoolean(["feature", "swallowOkAfterResend"])
},
"serial": {
@@ -129,6 +130,7 @@ def setSettings():
if "waitForStart" in data["feature"].keys(): s.setBoolean(["feature", "waitForStartOnConnect"], data["feature"]["waitForStart"])
if "alwaysSendChecksum" in data["feature"].keys(): s.setBoolean(["feature", "alwaysSendChecksum"], data["feature"]["alwaysSendChecksum"])
if "sdSupport" in data["feature"].keys(): s.setBoolean(["feature", "sdSupport"], data["feature"]["sdSupport"])
if "sdAlwaysAvailable" in data["feature"].keys(): s.setBoolean(["feature", "sdAlwaysAvailable"], data["feature"]["sdAlwaysAvailable"])
if "swallowOkAfterResend" in data["feature"].keys(): s.setBoolean(["feature", "swallowOkAfterResend"], data["feature"]["swallowOkAfterResend"])
if "serial" in data.keys():
+1
View File
@@ -61,6 +61,7 @@ default_settings = {
"waitForStartOnConnect": False,
"alwaysSendChecksum": False,
"sdSupport": True,
"sdAlwaysAvailable": False,
"swallowOkAfterResend": True
},
"folder": {
@@ -43,10 +43,10 @@ function GcodeFilesViewModel(printerStateViewModel, loginStateViewModel) {
return !(file["prints"] && file["prints"]["success"] && file["prints"]["success"] > 0);
},
"sd": function(file) {
return file["origin"] && file["origin"] == "sdcard";
return file["origin"] && file["origin"] == "sd";
},
"local": function(file) {
return !(file["origin"] && file["origin"] == "sdcard");
return !(file["origin"] && file["origin"] == "sd");
}
},
"name",
@@ -32,6 +32,7 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) {
self.feature_waitForStart = ko.observable(undefined);
self.feature_alwaysSendChecksum = ko.observable(undefined);
self.feature_sdSupport = ko.observable(undefined);
self.feature_sdAlwaysAvailable = ko.observable(undefined);
self.feature_swallowOkAfterResend = ko.observable(undefined);
self.serial_port = ko.observable();
@@ -135,6 +136,7 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) {
self.feature_waitForStart(response.feature.waitForStart);
self.feature_alwaysSendChecksum(response.feature.alwaysSendChecksum);
self.feature_sdSupport(response.feature.sdSupport);
self.feature_sdAlwaysAvailable(response.feature.sdAlwaysAvailable);
self.feature_swallowOkAfterResend(response.feature.swallowOkAfterResend);
self.serial_port(response.serial.port);
@@ -195,6 +197,7 @@ function SettingsViewModel(loginStateViewModel, usersViewModel) {
"waitForStart": self.feature_waitForStart(),
"alwaysSendChecksum": self.feature_alwaysSendChecksum(),
"sdSupport": self.feature_sdSupport(),
"sdAlwaysAvailable": self.feature_sdAlwaysAvailable(),
"swallowOkAfterResend": self.feature_swallowOkAfterResend()
},
"serial": {
+7
View File
@@ -204,6 +204,13 @@
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
<input type="checkbox" data-bind="checked: feature_sdAlwaysAvailable" id="settings-featureSdAlwaysAvailable"> Always assume SD card is present <span class="label">Repetier</span>
</label>
</div>
</div>
<div class="control-group">
<div class="controls">
<label class="checkbox">
+36
View File
@@ -8,6 +8,7 @@ import sys
import time
import re
import tempfile
from flask import make_response
from octoprint.settings import settings
@@ -188,3 +189,38 @@ def silentRemove(file):
os.remove(file)
except OSError:
pass
def sanitizeAscii(line):
return unicode(line, 'ascii', 'replace').encode('ascii', 'replace').rstrip()
def filterNonAscii(line):
"""
Returns True if the line contains non-ascii characters, false otherwise
@param line the line to test
"""
try:
unicode(line, 'ascii').encode('ascii')
return False
except ValueError:
return True
def getJsonCommandFromRequest(request, valid_commands):
if not "application/json" in request.headers["Content-Type"]:
return None, None, make_response("Expected content-type JSON", 400)
data = request.json
if not "command" in data.keys() or not data["command"] in valid_commands.keys():
return None, None, make_response("Expected valid command", 400)
command = data["command"]
for parameter in valid_commands[command]:
if not parameter in data:
return None, None, make_response("Mandatory parameter %s missing for command %s" % (parameter, command), 400)
return command, data, None
+57 -29
View File
@@ -20,7 +20,7 @@ from octoprint.util.avr_isp import ispBase
from octoprint.settings import settings
from octoprint.events import eventManager
from octoprint.gcodefiles import isGcodeFileName
from octoprint.util import getExceptionString, getNewTimeout
from octoprint.util import getExceptionString, getNewTimeout, sanitizeAscii, filterNonAscii
from octoprint.util.virtual import VirtualPrinter
try:
@@ -150,6 +150,18 @@ class MachineCom(object):
# print job
self._currentFile = None
# regexes
floatPattern = "[-+]?[0-9]*\.?[0-9]+"
intPattern = "[0-9]+"
self._regex_command = re.compile("^\s*([GM]\d+)")
self._regex_float = re.compile(floatPattern)
self._regex_paramZFloat = re.compile("Z(%s)" % floatPattern)
self._regex_paramSInt = re.compile("S(%s)" % intPattern)
self._regex_paramNInt = re.compile("N(%s)" % intPattern)
self._regex_minMaxError = re.compile("Error:[0-9]\n")
self._regex_sdPrintingByte = re.compile("([0-9]*)/([0-9]*)")
self._regex_sdFileOpened = re.compile("File opened:\s*(.*?)\s+Size:\s*([0-9]*)")
def __del__(self):
self.close()
@@ -330,14 +342,14 @@ class MachineCom(object):
if self._currentFile is None:
raise ValueError("No file selected for printing")
wasPaused = self.isPaused()
self._printSection = "CUSTOM"
self._changeState(self.STATE_PRINTING)
eventManager().fire("PrintStarted", self._currentFile.getFilename())
try:
self._currentFile.start()
self._changeState(self.STATE_PRINTING)
eventManager().fire("PrintStarted", self._currentFile.getFilename())
if self.isSdFileSelected():
if wasPaused:
self.sendCommand("M26 S0")
@@ -451,6 +463,10 @@ class MachineCom(object):
if not self.isOperational():
return
self.sendCommand("M21")
if settings().getBoolean(["feature", "sdAlwaysAvailable"]):
self._sdAvailable = True
self.refreshSdFiles()
self._callback.mcSdStateChange(self._sdAvailable)
def releaseSdCard(self):
if not self.isOperational() or (self.isBusy() and self.isSdFileSelected()):
@@ -501,15 +517,19 @@ class MachineCom(object):
##~~ SD file list
# if we are currently receiving an sd file list, each line is just a filename, so just read it and abort processing
if self._sdFileList and isGcodeFileName(line.strip().lower()) and not 'End file list' in line:
self._sdFiles.append(line.strip().lower())
filename = line.strip().lower()
if filterNonAscii(filename):
self._logger.warn("Got a file from printer's SD that has a non-ascii filename (%s), that shouldn't happen according to the protocol" % filename)
else:
self._sdFiles.append(filename)
continue
##~~ Temperature processing
if ' T:' in line or line.startswith('T:'):
try:
self._temp = float(re.search("-?[0-9\.]*", line.split('T:')[1]).group(0))
self._temp = float(self._regex_float.search(line.split('T:')[1]).group(0))
if ' B:' in line:
self._bedTemp = float(re.search("-?[0-9\.]*", line.split(' B:')[1]).group(0))
self._bedTemp = float(self._regex_float.search(line.split(' B:')[1]).group(0))
self._callback.mcTempUpdate(self._temp, self._bedTemp, self._targetTemp, self._bedTargetTemp)
except ValueError:
@@ -534,7 +554,7 @@ class MachineCom(object):
# something went wrong, printer is reporting that we actually are not printing right now...
self._sdFilePos = 0
self._changeState(self.STATE_OPERATIONAL)
elif 'SD card ok' in line:
elif 'SD card ok' in line and not self._sdAvailable:
self._sdAvailable = True
self.refreshSdFiles()
self._callback.mcSdStateChange(self._sdAvailable)
@@ -546,12 +566,12 @@ class MachineCom(object):
self._callback.mcSdFiles(self._sdFiles)
elif 'SD printing byte' in line:
# answer to M27, at least on Marlin, Repetier and Sprinter: "SD printing byte %d/%d"
match = re.search("([0-9]*)/([0-9]*)", line)
match = self._regex_sdPrintingByte.search(line)
self._currentFile.setFilepos(int(match.group(1)))
self._callback.mcProgress()
elif 'File opened' in line:
# answer to M23, at least on Marlin, Repetier and Sprinter: "File opened:%s Size:%d"
match = re.search("File opened:\s*(.*?)\s+Size:\s*([0-9]*)", line)
match = self._regex_sdFileOpened.search(line)
self._currentFile = PrintingSdFileInformation(match.group(1), int(match.group(2)))
elif 'File selected' in line:
# final answer to M23, at least on Marlin, Repetier and Sprinter: "File selected"
@@ -560,7 +580,6 @@ class MachineCom(object):
eventManager().fire("FileSelected", self._currentFile.getFilename())
elif 'Writing to file' in line:
# anwer to M28, at least on Marlin, Repetier and Sprinter: "Writing to file: %s"
self._printSection = "CUSTOM"
self._changeState(self.STATE_PRINTING)
line = "ok"
elif 'Done printing file' in line:
@@ -654,6 +673,8 @@ class MachineCom(object):
self._changeState(self.STATE_OPERATIONAL)
if self._sdAvailable:
self.refreshSdFiles()
else:
self.initSdCard()
eventManager().fire("Connected", "%s at %s baud" % (self._port, self._baudrate))
else:
self._testingBaudrate = False
@@ -666,7 +687,9 @@ class MachineCom(object):
startSeen = True
elif "ok" in line and startSeen:
self._changeState(self.STATE_OPERATIONAL)
if not self._sdAvailable:
if self._sdAvailable:
self.refreshSdFiles()
else:
self.initSdCard()
eventManager().fire("Connected", "%s at %s baud" % (self._port, self._baudrate))
elif time.time() > timeout:
@@ -785,7 +808,7 @@ class MachineCom(object):
# Marlin reports an MIN/MAX temp error as "Error:x\n: Extruder switched off. MAXTEMP triggered !\n"
# But a bed temp error is reported as "Error: Temperature heated bed switched off. MAXTEMP triggered !!"
# So we can have an extra newline in the most common case. Awesome work people.
if re.match('Error:[0-9]\n', line):
if self._regex_minMaxError.match(line):
line = line.rstrip() + self._readline()
#Skip the communication errors, as those get corrected.
if 'checksum mismatch' in line \
@@ -815,7 +838,7 @@ class MachineCom(object):
if ret == '':
#self._log("Recv: TIMEOUT")
return ''
self._log("Recv: %s" % (unicode(ret, 'ascii', 'replace').encode('ascii', 'replace').rstrip()))
self._log("Recv: %s" % sanitizeAscii(ret))
return ret
def _sendNext(self):
@@ -882,7 +905,7 @@ class MachineCom(object):
return
if not self.isStreaming():
gcode = re.search("^\s*([GM]\d+)", cmd)
gcode = self._regex_command.search(cmd)
if gcode:
gcode = gcode.group(1)
@@ -932,13 +955,15 @@ class MachineCom(object):
def _gcode_G0(self, cmd):
if 'Z' in cmd:
try:
z = float(re.search('Z([0-9\.]*)', cmd).group(1))
if self._currentZ != z:
self._currentZ = z
self._callback.mcZChange(z)
except ValueError:
pass
match = self._regex_paramZFloat.search(cmd)
if match:
try:
z = float(match.group(1))
if self._currentZ != z:
self._currentZ = z
self._callback.mcZChange(z)
except ValueError:
pass
return cmd
_gcode_G1 = _gcode_G0
@@ -948,7 +973,7 @@ class MachineCom(object):
_gcode_M1 = _gcode_M0
def _gcode_M104(self, cmd):
match = re.search('S([0-9]+)', cmd)
match = self._regex_paramSInt.search(cmd)
if match:
try:
self._targetTemp = float(match.group(1))
@@ -957,7 +982,7 @@ class MachineCom(object):
return cmd
def _gcode_M140(self, cmd):
match = re.search('S([0-9]+)', cmd)
match = self._regex_paramSInt.search(cmd)
if match:
try:
self._bedTargetTemp = float(match.group(1))
@@ -975,7 +1000,7 @@ class MachineCom(object):
def _gcode_M110(self, cmd):
newLineNumber = None
match = re.search("N([0-9]+)", cmd)
match = self._regex_paramNInt.search(cmd)
if match:
try:
newLineNumber = int(match.group(1))
@@ -993,6 +1018,9 @@ class MachineCom(object):
self._resendDelta = None
return None
def _gcode_M112(self, cmd): # It's an emergency what todo? Canceling the print should be the minimum
self.cancelPrint()
return cmd
### MachineCom callback ################################################################################################
@@ -1110,7 +1138,7 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
self._firstLine = None
self._offsetCallback = offsetCallback
self._tempCommandPattern = re.compile("^\s*M(104|109|140|190)\s+S([0-9\.]+)")
self._regex_tempCommand = re.compile("^\s*M(104|109|140|190)\s+S([0-9\.]+)")
if not os.path.exists(self._filename) or not os.path.isfile(self._filename):
raise IOError("File %s does not exist" % self._filename)
@@ -1167,7 +1195,7 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
if self._offsetCallback is not None:
(tempOffset, bedTempOffset) = self._offsetCallback()
if tempOffset != 0 or bedTempOffset != 0:
tempMatch = self._tempCommandPattern.match(line)
tempMatch = self._regex_tempCommand.match(line)
if tempMatch is not None:
if tempMatch.group(1) == "104" or tempMatch.group(1) == "109":
offset = tempOffset
@@ -1189,4 +1217,4 @@ class PrintingGcodeFileInformation(PrintingFileInformation):
class StreamingGcodeFileInformation(PrintingGcodeFileInformation):
def __init__(self, filename):
PrintingGcodeFileInformation.__init__(self, filename, None)
PrintingGcodeFileInformation.__init__(self, filename, None)