-
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.
refactor: move crash_reports into reports
- Loading branch information
Showing
3 changed files
with
25 additions
and
19 deletions.
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 CrashReports: | ||
def __init__(self, client, crash_reports_dir): | ||
self._client = client | ||
self._crash_reports_dir = crash_reports_dir | ||
|
||
def list(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(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,22 +1,6 @@ | ||
from typing import List | ||
|
||
from pycrashreport.crash_report import CrashReport | ||
from rpcclient.darwin.crash_reports import CrashReports | ||
|
||
|
||
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) | ||
self.crash_reports = CrashReports(client, crash_reports_dir) |
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