Added Bug Report button to Admin -> General.
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Wed, 28 Nov 2018 08:17:46 +0000 (00:17 -0800)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Wed, 28 Nov 2018 08:17:46 +0000 (00:17 -0800)
CHANGELOG.md
src/pug/templates/admin-general-view.pug
src/py/bbctrl/Web.py
src/stylus/style.styl

index 3c74a3e007800aaefb37a2481c240fa42d8ae1af..78de09cb20c6d824f3eecfe77b56d33863b259b2 100644 (file)
@@ -12,6 +12,7 @@ Buildbotics CNC Controller Firmware Changelog
  - Handle zero length dwell correctly.
  - Fixed problem with cached GCode file upload when file changed on disk.
  - Run simulation at low process priority.
+ - Added ``Bug Report`` button to ``Admin`` -> ``General``.
 
 ## v0.4.1
  - Fix toolpath view axes bug.
index cb099371e576a2c8cf4b444f5d3a93276b07c2ae..37040dc595a1cfde95911acf7977d0afe238897b 100644 (file)
@@ -49,8 +49,7 @@ script#admin-general-view-template(type="text/x-template")
       h3(slot="header") Success
       p(slot="body") Configuration restored.
 
-    button.pure-button.pure-button-primary(@click="confirmReset = true")
-      | Reset
+    button.pure-button.pure-button-primary(@click="confirmReset = true") Reset
     message(:show.sync="confirmReset")
       h3(slot="header") Reset to default configuration?
       p(slot="body") All configuration changes will be lost.
@@ -65,3 +64,5 @@ script#admin-general-view-template(type="text/x-template")
     h2 Debugging
     a(href="/api/log", target="_blank")
       button.pure-button.pure-button-primary View Log
+    a(href="/api/bugreport")
+      button.pure-button.pure-button-primary Bug Report
index 0e2f0f162dbb4539927aaa0fa8e4a8180e379de0..92d664b5799c75572f25d219287c7c9c79136101 100644 (file)
@@ -103,6 +103,46 @@ class LogHandler(tornado.web.RequestHandler):
         self.set_header('Content-Type', 'text/plain')
 
 
+class BugReportHandler(tornado.web.RequestHandler):
+    def __init__(self, app, request, **kwargs):
+        super(BugReportHandler, self).__init__(app, request, **kwargs)
+        self.app = app
+
+
+    def get(self):
+        import tarfile, io
+
+        buf = io.BytesIO()
+        tar = tarfile.open(mode = 'w:bz2', fileobj = buf)
+
+        def check_add(path, arcname = None):
+            if os.path.isfile(path):
+                if arcname is None: arcname = path
+                tar.add(path, self.basename + '/' + arcname)
+
+        def check_add_basename(path):
+            check_add(path, os.path.basename(path))
+
+        check_add_basename(self.app.ctrl.args.log)
+        check_add_basename(self.app.ctrl.args.log + '.1')
+        check_add_basename(self.app.ctrl.args.log + '.2')
+        check_add_basename(self.app.ctrl.args.log + '.3')
+        check_add('config.json')
+        check_add('upload/' + self.app.ctrl.state.get('selected', ''))
+
+        tar.close()
+
+        self.write(buf.getvalue())
+
+
+    def set_default_headers(self):
+        fmt = socket.gethostname() + '-%Y%m%d-%H%M%S'
+        self.basename = datetime.datetime.now().strftime(fmt)
+        filename = self.basename + '.tar.bz2'
+        self.set_header('Content-Disposition', 'filename="%s"' % filename)
+        self.set_header('Content-Type', 'application/x-bzip2')
+
+
 class HostnameHandler(bbctrl.APIHandler):
     def get(self): self.write_json(socket.gethostname())
 
@@ -403,6 +443,7 @@ class Web(tornado.web.Application):
         handlers = [
             (r'/websocket', WSConnection),
             (r'/api/log', LogHandler),
+            (r'/api/bugreport', BugReportHandler),
             (r'/api/reboot', RebootHandler),
             (r'/api/hostname', HostnameHandler),
             (r'/api/wifi', WifiHandler),
index 3e3197b8701ad3e07a30db9dd54dd43c614a9dc3..8ebfc27ac0abb241ee71cc51f65c13917f2806ea 100644 (file)
@@ -754,6 +754,9 @@ tt.save
   h2:not(:first-of-type)
     margin-top 2em
 
+  a
+    text-decoration none
+
 
 .upgrade-version
   display inline-block