Skip to content

Commit

Permalink
darwin: add reports
Browse files Browse the repository at this point in the history
  • Loading branch information
doronz88 committed Feb 19, 2022
1 parent 34be367 commit cc2e92b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/rpcclient/rpcclient/darwin/reports.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from typing import List

from pycrashreport.crash_report import CrashReport


class Reports:
def __init__(self, client, crash_reports_dir):
self._client = client
self._crash_reports_dir = crash_reports_dir

def list_crash_reports(self, prefixed='') -> List[CrashReport]:
result = []
for entry in self._client.fs.scandir(self._crash_reports_dir):
if entry.is_file() and entry.name.endswith('.ips') and entry.name.startswith(prefixed):
with self._client.fs.open(entry.path, 'r') as f:
result.append(CrashReport(f.readall().decode(), filename=entry.path))
return result

def clear_crash_reports(self, prefixed=''):
for entry in self._client.fs.scandir(self._crash_reports_dir):
if entry.is_file() and entry.name.endswith('.ips') and entry.name.startswith(prefixed):
self._client.fs.remove(entry.path)
5 changes: 4 additions & 1 deletion src/rpcclient/rpcclient/macos/client.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
from rpcclient.darwin.client import DarwinClient
from rpcclient.macos.bluetooth import Bluetooth
from rpcclient.darwin.reports import Reports

CRASH_REPORTS_DIR = '/Library/Logs/DiagnosticReports'


class MacosClient(DarwinClient):

def __init__(self, sock, sysname: str, hostname: str, port: int = None):
super().__init__(sock, sysname, hostname, port)

self.bluetooth = Bluetooth(self)
self.crash_reports = Reports(self, CRASH_REPORTS_DIR)

0 comments on commit cc2e92b

Please sign in to comment.