ruff exceptions: os.makedirs(), sh.rmtree()

This commit is contained in:
The MMGen Project 2026-10-26 13:36:47 +00:00
commit 545a653d2c
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
5 changed files with 7 additions and 26 deletions

View file

@ -177,10 +177,7 @@ class MMGenRegtest(MMGenObject):
async def setup(self, create_wallets_only=False):
try:
os.makedirs(self.d.datadir)
except:
pass
os.makedirs(self.d.datadir, exist_ok=True)
if self.d.state != 'stopped':
await self.rpc_call('stop')
@ -326,10 +323,7 @@ class MMGenRegtest(MMGenObject):
if self.d.state != 'stopped':
await self.rpc_call('stop')
try:
os.makedirs(self.d.datadir)
except:
pass
os.makedirs(self.d.datadir, exist_ok=True)
create_data_dir(self.cfg, self.d.datadir)
os.rmdir(self.d.datadir)

View file

@ -1341,10 +1341,7 @@ class CmdTestEthdev(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
self.spawn(msg_only=True)
cmd_args = [f'--{k}={v}' for k, v in list(token_data.items())]
imsg("Compiling solidity token contract '{}' with 'solc'".format(token_data['symbol']))
try:
os.mkdir(odir)
except:
pass
os.makedirs(odir, exist_ok=True)
cmd = [
'python3',
'scripts/create-token.py',

View file

@ -540,10 +540,7 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared):
stop_test_daemons(proto.network_id, force=True, remove_datadir=True)
if remove_datadir:
from shutil import rmtree
try:
rmtree(joinpath(self.tr.data_dir, 'regtest'))
except:
pass
rmtree(joinpath(self.tr.data_dir, 'regtest'), ignore_errors=True)
if self.deterministic:
action = 'Loading'
if not os.path.exists('wallets/alice'):
@ -2250,8 +2247,7 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared):
'contains no unused addresses of address type')
def bob_dump_hex_create(self):
if not os.path.exists(self.dump_hex_subdir):
os.mkdir(self.dump_hex_subdir)
os.makedirs(self.dump_hex_subdir, exist_ok=True)
autochg_arg = self._user_sid('bob') + ':C'
return self.txcreate_ui_common(
self.spawn('mmgen-txcreate',

View file

@ -93,10 +93,7 @@ class CmdTestSeedSplit(CmdTestBase):
return t
def ss_splt(self, tdir, ofmt, spec, add_args=[], wf=None, master=None):
try:
os.mkdir(self.get_tmp_subdir(tdir))
except:
pass
os.makedirs(self.get_tmp_subdir(tdir), exist_ok=True)
t = self.spawn('mmgen-seedsplit',
['-q', '-d', self.get_tmp_subdir(tdir), '-r0', '-o', ofmt]
+ (['-L', (spec or 'label')] if ofmt == 'w' else [])

View file

@ -243,10 +243,7 @@ def chk_equal(a, b):
def init_coverage():
coverdir = os.path.join('test', 'trace')
acc_file = os.path.join('test', 'trace.acc')
try:
os.mkdir(coverdir, 0o755)
except:
pass
os.makedirs(coverdir, 0o755, exist_ok=True)
return coverdir, acc_file
def silence():