Commit 6cb8ff76 authored by Guillaume Seguin's avatar Guillaume Seguin

Fix #532, add sdlisting_echo property, rename listing to sdlisting

parent 08bc92b1
...@@ -126,7 +126,8 @@ class pronsole(cmd.Cmd): ...@@ -126,7 +126,8 @@ class pronsole(cmd.Cmd):
self.filename = None self.filename = None
self.rpc_server = None self.rpc_server = None
self.curlayer = 0 self.curlayer = 0
self.listing = 0 self.sdlisting = 0
self.sdlisting_echo = 0
self.sdfiles = [] self.sdfiles = []
self.paused = False self.paused = False
self.sdprinting = 0 self.sdprinting = 0
...@@ -1045,23 +1046,24 @@ class pronsole(cmd.Cmd): ...@@ -1045,23 +1046,24 @@ class pronsole(cmd.Cmd):
def help_resume(self): def help_resume(self):
self.log(_("Resumes a paused print.")) self.log(_("Resumes a paused print."))
def listfiles(self, line, echo = False): def listfiles(self, line):
if "Begin file list" in line: if "Begin file list" in line:
self.listing = 1 self.sdlisting = 1
elif "End file list" in line: elif "End file list" in line:
self.listing = 0 self.sdlisting = 0
self.recvlisteners.remove(self.listfiles) self.recvlisteners.remove(self.listfiles)
if echo: if self.sdlisting_echo:
self.log(_("Files on SD card:")) self.log(_("Files on SD card:"))
self.log("\n".join(self.sdfiles)) self.log("\n".join(self.sdfiles))
elif self.listing: elif self.sdlisting:
self.sdfiles.append(line.strip().lower()) self.sdfiles.append(line.strip().lower())
def _do_ls(self, echo): def _do_ls(self, echo):
# FIXME: this was 2, but I think it should rather be 0 as in do_upload # FIXME: this was 2, but I think it should rather be 0 as in do_upload
self.listing = 0 self.sdlisting = 0
self.sdlisting_echo = echo
self.sdfiles = [] self.sdfiles = []
self.recvlisteners.append(lambda l: self.listfiles(l, echo)) self.recvlisteners.append(self.listfiles)
self.p.send_now("M20") self.p.send_now("M20")
def do_ls(self, l): def do_ls(self, l):
...@@ -1201,7 +1203,7 @@ class pronsole(cmd.Cmd): ...@@ -1201,7 +1203,7 @@ class pronsole(cmd.Cmd):
if report_type == REPORT_TEMP: if report_type == REPORT_TEMP:
self.status.update_tempreading(l) self.status.update_tempreading(l)
tstring = l.rstrip() tstring = l.rstrip()
if tstring != "ok" and not self.listing \ if tstring != "ok" and not self.sdlisting \
and not self.monitoring and report_type == REPORT_NONE: and not self.monitoring and report_type == REPORT_NONE:
if tstring[:5] == "echo:": if tstring[:5] == "echo:":
tstring = tstring[5:].lstrip() tstring = tstring[5:].lstrip()
......
...@@ -1213,7 +1213,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -1213,7 +1213,7 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
if not self.p.online: if not self.p.online:
self.sdfiles = [] self.sdfiles = []
return return
self.listing = 0 self.sdlisting = 0
self.sdfiles = [] self.sdfiles = []
self.recvlisteners.append(self.listfiles) self.recvlisteners.append(self.listfiles)
self.p.send_now("M21") self.p.send_now("M21")
...@@ -1672,12 +1672,12 @@ Printrun. If not, see <http://www.gnu.org/licenses/>.""" ...@@ -1672,12 +1672,12 @@ Printrun. If not, see <http://www.gnu.org/licenses/>."""
def listfiles(self, line, ignored = False): def listfiles(self, line, ignored = False):
if "Begin file list" in line: if "Begin file list" in line:
self.listing = 1 self.sdlisting = 1
elif "End file list" in line: elif "End file list" in line:
self.listing = 0 self.sdlisting = 0
self.recvlisteners.remove(self.listfiles) self.recvlisteners.remove(self.listfiles)
wx.CallAfter(self.filesloaded) wx.CallAfter(self.filesloaded)
elif self.listing: elif self.sdlisting:
self.sdfiles.append(line.strip().lower()) self.sdfiles.append(line.strip().lower())
def waitforsdresponse(self, l): def waitforsdresponse(self, l):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment