-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |