Merge branch 'master' of https://github.com/foosel/OctoPrint
commit
9353681248
|
@ -358,8 +358,6 @@ class MetadataAnalyzer:
|
|||
def _work(self):
|
||||
aborted = None
|
||||
while True:
|
||||
self._active.wait()
|
||||
|
||||
if aborted is not None:
|
||||
filename = aborted
|
||||
aborted = None
|
||||
|
@ -368,6 +366,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()
|
||||
|
|
|
@ -568,83 +568,6 @@ class Printer():
|
|||
def isLoading(self):
|
||||
return self._gcodeLoader is not None
|
||||
|
||||
class GcodeLoader(threading.Thread):
|
||||
"""
|
||||
The GcodeLoader takes care of loading a gcode-File from disk and parsing it into a gcode object in a separate
|
||||
thread while constantly notifying interested listeners about the current progress.
|
||||
The progress is returned as a float value between 0 and 1 which is to be interpreted as the percentage of completion.
|
||||
"""
|
||||
|
||||
def __init__(self, filename, progressCallback, loadedCallback):
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
self._progressCallback = progressCallback
|
||||
self._loadedCallback = loadedCallback
|
||||
|
||||
self._filename = filename
|
||||
self._gcodeList = None
|
||||
|
||||
def run(self):
|
||||
#Send an initial M110 to reset the line counter to zero.
|
||||
prevLineType = lineType = "CUSTOM"
|
||||
gcodeList = ["M110 N0"]
|
||||
filesize = os.stat(self._filename).st_size
|
||||
with open(self._filename, "r") as file:
|
||||
for line in file:
|
||||
if line.startswith(";TYPE:"):
|
||||
lineType = line[6:].strip()
|
||||
if ";" in line:
|
||||
line = line[0:line.find(";")]
|
||||
line = line.strip()
|
||||
if len(line) > 0:
|
||||
if prevLineType != lineType:
|
||||
gcodeList.append((line, lineType, ))
|
||||
else:
|
||||
gcodeList.append(line)
|
||||
prevLineType = lineType
|
||||
self._onLoadingProgress(float(file.tell()) / float(filesize))
|
||||
|
||||
self._gcodeList = gcodeList
|
||||
self._loadedCallback(self._filename, self._gcodeList)
|
||||
|
||||
def _onLoadingProgress(self, progress):
|
||||
self._progressCallback(self._filename, progress, "loading")
|
||||
|
||||
def _onParsingProgress(self, progress):
|
||||
self._progressCallback(self._filename, progress, "parsing")
|
||||
|
||||
class SdFileStreamer(threading.Thread):
|
||||
def __init__(self, comm, filename, file, progressCallback, finishCallback):
|
||||
threading.Thread.__init__(self)
|
||||
|
||||
self._comm = comm
|
||||
self._filename = filename
|
||||
self._file = file
|
||||
self._progressCallback = progressCallback
|
||||
self._finishCallback = finishCallback
|
||||
|
||||
def run(self):
|
||||
if self._comm.isBusy():
|
||||
return
|
||||
|
||||
name = self._filename[:self._filename.rfind(".")]
|
||||
sdFilename = name[:8].lower() + ".gco"
|
||||
try:
|
||||
size = os.stat(self._file).st_size
|
||||
with open(self._file, "r") as f:
|
||||
self._comm.startSdFileTransfer(sdFilename)
|
||||
for line in f:
|
||||
if ";" in line:
|
||||
line = line[0:line.find(";")]
|
||||
line = line.strip()
|
||||
if len(line) > 0:
|
||||
self._comm.sendCommand(line)
|
||||
time.sleep(0.001) # do not send too fast
|
||||
self._progressCallback(sdFilename, float(f.tell()) / float(size))
|
||||
finally:
|
||||
self._comm.endSdFileTransfer(sdFilename)
|
||||
self._finishCallback(sdFilename)
|
||||
|
||||
class StateMonitor(object):
|
||||
def __init__(self, ratelimit, updateCallback, addTemperatureCallback, addLogCallback, addMessageCallback):
|
||||
self._ratelimit = ratelimit
|
||||
|
|
|
@ -59,7 +59,7 @@ default_settings = {
|
|||
"waitForStartOnConnect": False,
|
||||
"alwaysSendChecksum": False,
|
||||
"sdSupport": True,
|
||||
"swallowOkAfterResend": False
|
||||
"swallowOkAfterResend": True
|
||||
},
|
||||
"folder": {
|
||||
"uploads": None,
|
||||
|
|
|
@ -23,7 +23,12 @@ function NavigationViewModel(loginStateViewModel, appearanceViewModel, settingsV
|
|||
}
|
||||
if (action.confirm) {
|
||||
$("#confirmation_dialog .confirmation_dialog_message").text(action.confirm);
|
||||
$("#confirmation_dialog .confirmation_dialog_acknowledge").click(function(e) {e.preventDefault(); $("#confirmation_dialog").modal("hide"); callback(); });
|
||||
$("#confirmation_dialog .confirmation_dialog_acknowledge").unbind("click");
|
||||
$("#confirmation_dialog .confirmation_dialog_acknowledge").bind("click", function(e) {
|
||||
e.preventDefault();
|
||||
$("#confirmation_dialog").modal("hide");
|
||||
callback();
|
||||
});
|
||||
$("#confirmation_dialog").modal("show");
|
||||
} else {
|
||||
callback();
|
||||
|
|
|
@ -206,7 +206,7 @@
|
|||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label class="checkbox">
|
||||
<input type="checkbox" data-bind="checked: feature_swallowOkAfterResend" id="settings-swallowOkAfterResend"> Swallow the first "ok" after a resend response <span class="label">Repetier</span>
|
||||
<input type="checkbox" data-bind="checked: feature_swallowOkAfterResend" id="settings-swallowOkAfterResend"> Swallow the first "ok" after a resend response
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -260,13 +260,13 @@
|
|||
<span class="add-on">°C</span>
|
||||
</div>
|
||||
<div class="span2">
|
||||
<button title="Remove profile" class="btn btn-danger" data-bind="click: $parent.removeTemperatureProfile"><i class="icon-trash"></i></button>
|
||||
<a title="Remove profile" class="btn btn-danger" data-bind="click: $parent.removeTemperatureProfile"><i class="icon-trash"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="offset9 span2">
|
||||
<button title="Add Profile" class="btn btn-primary" data-bind="click: addTemperatureProfile"><i class="icon-plus"></i></button>
|
||||
<a title="Add Profile" class="btn btn-primary" data-bind="click: addTemperatureProfile"><i class="icon-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
@ -286,13 +286,13 @@
|
|||
<input type="text" class="span12" data-bind="value: regex">
|
||||
</div>
|
||||
<div class="span2">
|
||||
<button title="Remove Filter" class="btn btn-danger" data-bind="click: $parent.removeTerminalFilter"><i class="icon-trash"></i></button>
|
||||
<a title="Remove Filter" class="btn btn-danger" data-bind="click: $parent.removeTerminalFilter"><i class="icon-trash"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row-fluid">
|
||||
<div class="offset10 span2">
|
||||
<button title="Add Filter" class="btn btn-primary" data-bind="click: addTerminalFilter"><i class="icon-plus"></i></button>
|
||||
<a title="Add Filter" class="btn btn-primary" data-bind="click: addTerminalFilter"><i class="icon-plus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -28,7 +28,7 @@ def isAllowedFile(filename, extensions):
|
|||
def getFormattedTimeDelta(d):
|
||||
if d is None:
|
||||
return None
|
||||
hours = d.seconds // 3600
|
||||
hours = d.days * 24 + d.seconds // 3600
|
||||
minutes = (d.seconds % 3600) // 60
|
||||
seconds = d.seconds % 60
|
||||
return "%02d:%02d:%02d" % (hours, minutes, seconds)
|
||||
|
|
7
run
7
run
|
@ -4,7 +4,7 @@ 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 +12,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 +51,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:
|
||||
|
|
Loading…
Reference in New Issue