(self, ticketNo=None, message=None)
| 623 | return True |
| 624 | |
| 625 | def sendLogs(self, ticketNo=None, message=None): |
| 626 | import zipfile |
| 627 | |
| 628 | from tempfile import gettempdir |
| 629 | |
| 630 | try: |
| 631 | boxId = boxrouterManager().boxId |
| 632 | |
| 633 | #Create the zip file |
| 634 | zipFilename = '%s/%s-logs.zip' % (gettempdir(), boxId) |
| 635 | zipf = zipfile.ZipFile(zipFilename, 'w') |
| 636 | |
| 637 | for root, dirs, files in os.walk(self._settings.getBaseFolder("logs")): |
| 638 | for file in files: |
| 639 | zipf.write(os.path.join(root, file), file) |
| 640 | |
| 641 | zipf.close() |
| 642 | |
| 643 | except Exception as e: |
| 644 | self._logger.error('Error while zipping logs: %s' % e) |
| 645 | return False |
| 646 | |
| 647 | zipf = open(zipFilename, 'rb') |
| 648 | |
| 649 | #send the file to the server |
| 650 | r = requests.post( |
| 651 | '%s/astrobox/software/logs' % roConfig('cloud.apiHost'), |
| 652 | data = { 'ticket': ticketNo, 'message': message, 'boxId': boxId}, |
| 653 | files = {'file': (zipFilename, zipf)}, |
| 654 | auth = self._checkAuth(), |
| 655 | headers = self._requestHeaders |
| 656 | ) |
| 657 | |
| 658 | zipf.close() |
| 659 | |
| 660 | #remove the file |
| 661 | os.remove(zipFilename) |
| 662 | |
| 663 | if r.status_code == 200: |
| 664 | return True |
| 665 | else: |
| 666 | self._logger.error('Error while sending logs: %d' % r.status_code) |
| 667 | return False |
| 668 | |
| 669 | def clearLogs(self): |
| 670 | activeLogFiles = ['astrobox.log', 'serial.log', 'electron.log', 'touch.log'] |
nothing calls this directly
no test coverage detected