mirror of
https://github.com/shmilylty/OneForAll.git
synced 2026-08-26 04:47:48 +08:00
增加open容错处理
This commit is contained in:
@@ -226,7 +226,7 @@ class Module(object):
|
||||
dpath.mkdir(parents=True, exist_ok=True)
|
||||
name = self.source + '.json'
|
||||
path = dpath.joinpath(name)
|
||||
with open(path, mode='w', encoding='utf-8') as file:
|
||||
with open(path, mode='w', encoding='utf-8', errors='ignore') as file:
|
||||
result = {'domain': self.domain,
|
||||
'name': self.module,
|
||||
'source': self.source,
|
||||
|
||||
@@ -120,7 +120,7 @@ def get_domains(target):
|
||||
elif isinstance(target, str):
|
||||
path = Path(target)
|
||||
if path.is_file():
|
||||
with open(target) as file:
|
||||
with open(target, encoding='utf-8', errors='ignore') as file:
|
||||
for line in file:
|
||||
domain = Domain(line.strip()).match()
|
||||
if domain:
|
||||
@@ -189,7 +189,7 @@ def check_format(format, count):
|
||||
|
||||
def save_data(fpath, data):
|
||||
try:
|
||||
with open(fpath, 'w', encoding="utf-8", newline='') as file:
|
||||
with open(fpath, 'w', encoding="utf-8", errors='ignore', newline='') as file:
|
||||
file.write(data)
|
||||
logger.log('ALERT', fpath)
|
||||
except TypeError:
|
||||
|
||||
@@ -26,7 +26,7 @@ class BruteSRV(Module):
|
||||
|
||||
def gen_names(self):
|
||||
path = data_storage_path.joinpath('srv_prefixes.json')
|
||||
with open(path) as file:
|
||||
with open(path, encoding='utf-8', errors='ignore') as file:
|
||||
prefixes = json.load(file)
|
||||
names = map(lambda prefix: prefix + self.domain, prefixes)
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ from common.domain import Domain
|
||||
|
||||
def get_fingerprint():
|
||||
path = config.data_storage_path.joinpath('fingerprints.json')
|
||||
with open(path) as file:
|
||||
with open(path, encoding='utf-8', errors='ignore') as file:
|
||||
fingerprints = json.load(file)
|
||||
return fingerprints
|
||||
|
||||
|
||||
Reference in New Issue
Block a user