Browse Source

pylint integration: `gc.platform` -> `sys.platform`

The MMGen Project 1 year ago
parent
commit
0a1e3c3c98

+ 2 - 6
mmgen/cfg.py

@@ -55,16 +55,12 @@ class GlobalConstants(Lockable):
 	prog_name = os.path.basename(sys.argv[0])
 	is_txprog = prog_name == 'mmgen-regtest' or prog_name.startswith('mmgen-tx')
 
-	for k in ('linux','win','msys'):
-		if sys.platform.startswith(k):
-			platform = { 'linux':'linux', 'win':'win', 'msys':'win' }[k]
-			break
-	else:
+	if sys.platform not in ('linux','win32'):
 		die2(1,f'{sys.platform!r}: platform not supported by {proj_name}')
 
 	if os.getenv('HOME'):   # Linux or MSYS2
 		home_dir = os.getenv('HOME')
-	elif platform == 'win': # Windows without MSYS2 - not supported
+	elif sys.platform == 'win32': # Windows without MSYS2 - not supported
 		die2(1,f'$HOME not set!  {proj_name} for Windows must be run in MSYS2 environment')
 	else:
 		die2(2,'$HOME is not set!  Unable to determine home directory')

+ 2 - 2
mmgen/color.py

@@ -47,8 +47,8 @@ def nocolor(s):
 
 def set_vt100():
 	'hack to put term into VT100 mode under MSWin'
-	from .cfg import gc
-	if gc.platform == 'win':
+	import sys
+	if sys.platform == 'win32':
 		from subprocess import run
 		run([],shell=True)
 

+ 8 - 8
mmgen/daemon.py

@@ -20,7 +20,7 @@
 daemon: Daemon control interface for the MMGen suite
 """
 
-import os,time,importlib
+import sys,os,time,importlib
 from subprocess import run,PIPE,CompletedProcess
 from collections import namedtuple
 
@@ -54,8 +54,8 @@ class Daemon(Lockable):
 	def __init__(self,cfg,opts=None,flags=None):
 
 		self.cfg = cfg
-		self.platform = gc.platform
-		if self.platform == 'win':
+		self.platform = sys.platform
+		if self.platform == 'win32':
 			self.use_pidfile = False
 			self.use_threads = True
 
@@ -65,11 +65,11 @@ class Daemon(Lockable):
 
 	def exec_cmd_thread(self,cmd):
 		import threading
-		tname = ('exec_cmd','exec_cmd_win_console')[self.platform == 'win' and self.new_console_mswin]
+		tname = ('exec_cmd','exec_cmd_win_console')[self.platform == 'win32' and self.new_console_mswin]
 		t = threading.Thread(target=getattr(self,tname),args=(cmd,))
 		t.daemon = True
 		t.start()
-		if self.platform == 'win':
+		if self.platform == 'win32':
 			Msg_r(' \b') # blocks w/o this...crazy
 		return True
 
@@ -119,7 +119,7 @@ class Daemon(Lockable):
 		if self.use_pidfile:
 			with open(self.pidfile) as fp:
 				return fp.read().strip()
-		elif self.platform == 'win':
+		elif self.platform == 'win32':
 			# Assumes only one running instance of given daemon.  If multiple daemons are running,
 			# the first PID in the list is returned and self.pids is set to the PID list.
 			ss = f'{self.exec_fn}.exe'
@@ -155,7 +155,7 @@ class Daemon(Lockable):
 	@property
 	def stop_cmd(self):
 		return (
-			['kill','-Wf',self.pid] if self.platform == 'win' else
+			['kill','-Wf',self.pid] if self.platform == 'win32' else
 			['kill','-9',self.pid] if self.force_kill else
 			['kill',self.pid] )
 
@@ -486,7 +486,7 @@ class CoinDaemon(Daemon):
 		assert self.test_suite, 'datadir removal restricted to test suite'
 		if self.state == 'stopped':
 			run([
-				('rm' if gc.platform == 'win' else '/bin/rm'),
+				('rm' if self.platform == 'win32' else '/bin/rm'),
 				'-rf',
 				self.datadir ])
 			set_vt100()

+ 2 - 3
mmgen/filename.py

@@ -20,7 +20,7 @@
 filename: File and MMGenFile classes and methods for the MMGen suite
 """
 
-import os
+import sys,os
 from .util import die,get_extension
 
 class File:
@@ -43,8 +43,7 @@ class File:
 		import stat
 		if stat.S_ISBLK(st.st_mode):
 			mode = (os.O_RDONLY,os.O_RDWR)[bool(write)]
-			from .cfg import gc
-			if gc.platform == 'win':
+			if sys.platform == 'win32':
 				mode |= os.O_BINARY
 			try:
 				fd = os.open(fn, mode)

+ 5 - 5
mmgen/fileutil.py

@@ -22,7 +22,6 @@ fileutil: Routines that read, write, execute or stat files
 
 import sys,os
 
-from .cfg import gc
 from .color import set_vt100
 from .util import (
 	msg,
@@ -41,7 +40,7 @@ def check_or_create_dir(path):
 		if os.getenv('MMGEN_TEST_SUITE'):
 			from subprocess import run
 			run([
-				('rm' if gc.platform == 'win' else '/bin/rm'),
+				('rm' if sys.platform == 'win32' else '/bin/rm'),
 				'-rf',
 				path ])
 			set_vt100()
@@ -206,9 +205,10 @@ def write_data_to_file(
 			else:
 				msg('Redirecting output to file')
 
-		if binary and gc.platform == 'win':
-			import msvcrt
-			msvcrt.setmode(sys.stdout.fileno(),os.O_BINARY)
+		if binary:
+			if sys.platform == 'win32': # condition on separate line for pylint
+				import msvcrt
+				msvcrt.setmode(sys.stdout.fileno(),os.O_BINARY)
 
 		# MSWin workaround. See msg_r()
 		try:

+ 1 - 2
mmgen/main.py

@@ -29,9 +29,8 @@ def launch(mod,package='mmgen'):
 		mod = 'addrgen'
 
 	import sys,os
-	from .cfg import gc
 
-	if gc.platform == 'linux' and sys.stdin.isatty():
+	if sys.platform == 'linux' and sys.stdin.isatty():
 		import termios,atexit
 		fd = sys.stdin.fileno()
 		old = termios.tcgetattr(fd)

+ 3 - 2
mmgen/main_passgen.py

@@ -21,6 +21,8 @@ mmgen-passgen: Generate a series or range of passwords from an MMGen
                deterministic wallet
 """
 
+import sys,time
+
 from .cfg import gc,Config
 from .addrlist import AddrIdxList
 from .passwdlist import PasswordList
@@ -181,7 +183,6 @@ if keypress_confirm( cfg, 'Encrypt password list?' ):
 	af.encrypt()
 	af.write(binary=True,desc='encrypted password list')
 else:
-	if cfg.test_suite_popen_spawn and gc.platform == 'win':
-		import time
+	if cfg.test_suite_popen_spawn and sys.platform == 'win32':
 		time.sleep(0.1)
 	af.write(desc='password list')

+ 1 - 1
mmgen/main_tool.py

@@ -268,7 +268,7 @@ def process_args(cmd,cmd_args,cls):
 			die(1,"'Binary input data must be supplied via STDIN")
 
 		if have_stdin_input and arg_type == 'str' and isinstance(arg,bytes):
-			NL = '\r\n' if gc.platform == 'win' else '\n'
+			NL = '\r\n' if sys.platform == 'win32' else '\n'
 			arg = arg.decode()
 			if arg[-len(NL):] == NL: # rstrip one newline
 				arg = arg[:-len(NL)]

+ 3 - 3
mmgen/proto/btc/daemon.py

@@ -29,7 +29,7 @@ class bitcoin_core_daemon(CoinDaemon):
 	nonstd_datadir = False
 	datadirs = {
 		'linux': [gc.home_dir,'.bitcoin'],
-		'win':   [os.getenv('APPDATA'),'Bitcoin']
+		'win32': [os.getenv('APPDATA'),'Bitcoin']
 	}
 
 	def init_datadir(self):
@@ -130,7 +130,7 @@ class bitcoin_cash_node_daemon(bitcoin_core_daemon):
 	nonstd_datadir = True
 	datadirs = {
 		'linux': [gc.home_dir,'.bitcoin-bchn'],
-		'win':   [os.getenv('APPDATA'),'Bitcoin_ABC']
+		'win32': [os.getenv('APPDATA'),'Bitcoin_ABC']
 	}
 
 	def set_comment_args(self,rpc,coinaddr,lbl):
@@ -159,5 +159,5 @@ class litecoin_core_daemon(bitcoin_core_daemon):
 	cfg_file_hdr = '# Litecoin Core config file\n'
 	datadirs = {
 		'linux': [gc.home_dir,'.litecoin'],
-		'win':   [os.getenv('APPDATA'),'Litecoin']
+		'win32': [os.getenv('APPDATA'),'Litecoin']
 	}

+ 3 - 3
mmgen/proto/eth/daemon.py

@@ -63,7 +63,7 @@ class openethereum_daemon(ethereum_daemon):
 	cfg_file = 'parity.conf'
 	datadirs = {
 		'linux': [gc.home_dir,'.local','share','io.parity.ethereum'],
-		'win':   [os.getenv('LOCALAPPDATA'),'Parity','Ethereum']
+		'win32': [os.getenv('LOCALAPPDATA'),'Parity','Ethereum']
 	}
 
 	def init_subclass(self):
@@ -100,7 +100,7 @@ class geth_daemon(ethereum_daemon):
 	version_info_arg = 'version'
 	datadirs = {
 		'linux': [gc.home_dir,'.ethereum','geth'],
-		'win':   [os.getenv('LOCALAPPDATA'),'Geth'] # FIXME
+		'win32': [os.getenv('LOCALAPPDATA'),'Geth'] # FIXME
 	}
 
 	def init_subclass(self):
@@ -136,7 +136,7 @@ class erigon_daemon(geth_daemon):
 	version_info_arg = '--version'
 	datadirs = {
 		'linux': [gc.home_dir,'.local','share','erigon'],
-		'win':   [os.getenv('LOCALAPPDATA'),'Erigon'] # FIXME
+		'win32': [os.getenv('LOCALAPPDATA'),'Erigon'] # FIXME
 	}
 
 	def init_subclass(self):

+ 4 - 4
mmgen/proto/xmr/daemon.py

@@ -28,7 +28,7 @@ class monero_daemon(CoinDaemon):
 	cfg_file = 'bitmonero.conf'
 	datadirs = {
 		'linux': [gc.home_dir,'.bitmonero'],
-		'win':   ['/','c','ProgramData','bitmonero']
+		'win32': ['/','c','ProgramData','bitmonero']
 	}
 
 	def init_datadir(self):
@@ -65,13 +65,13 @@ class monero_daemon(CoinDaemon):
 			['--no-igd'],
 			[f'--data-dir={self.datadir}', self.non_dfl_datadir],
 			[f'--pidfile={self.pidfile}', self.platform == 'linux'],
-			['--detach',                  not (self.opt.no_daemonize or self.platform=='win')],
+			['--detach',                  not (self.opt.no_daemonize or self.platform=='win32')],
 			['--offline',                 not self.opt.online],
 		)
 
 	@property
 	def stop_cmd(self):
-		if self.platform == 'win':
+		if self.platform == 'win32':
 			return ['kill','-Wf',self.pid]
 		elif contains_any( self.start_cmd, ['--restricted-rpc','--public-node'] ):
 			return ['kill',self.pid]
@@ -164,7 +164,7 @@ class MoneroWalletDaemon(RPCDaemon):
 			[f'--daemon-port={self.monerod_port}',    not self.monerod_addr],
 			[f'--proxy={self.proxy}',                self.proxy],
 			[f'--pidfile={self.pidfile}',            self.platform == 'linux'],
-			['--detach',                             not (self.opt.no_daemonize or self.platform=='win')],
+			['--detach',                             not (self.opt.no_daemonize or self.platform=='win32')],
 			['--stagenet',                           self.network == 'testnet'],
 			['--allow-mismatched-daemon-version',    test_suite],
 		)

+ 3 - 4
mmgen/rpc.py

@@ -20,11 +20,10 @@
 rpc: Cryptocoin RPC library for the MMGen suite
 """
 
-import re,base64,json,asyncio,importlib
+import sys,re,base64,json,asyncio,importlib
 from decimal import Decimal
 from collections import namedtuple
 
-from .cfg import gc
 from .util import msg,die,fmt,fmt_list,pp_fmt,oneshot_warning
 from .base_obj import AsyncInit
 from .obj import NonNegativeInt
@@ -264,7 +263,7 @@ class RPCClient(MMGenObject):
 		self.name = type(self).__name__
 
 		# aiohttp workaround, and may speed up RPC performance overall on some systems:
-		if gc.platform == 'win' and host == 'localhost':
+		if sys.platform == 'win32' and host == 'localhost':
 			host = '127.0.0.1'
 
 		global dmsg_rpc,dmsg_rpc_backend
@@ -291,7 +290,7 @@ class RPCClient(MMGenObject):
 	def _get_backend(self,backend):
 		backend_id = backend or self.cfg.rpc_backend
 		if backend_id == 'auto':
-			return {'linux':RPCBackends.httplib,'win':RPCBackends.requests}[gc.platform](self)
+			return {'linux':RPCBackends.httplib,'win32':RPCBackends.requests}[sys.platform](self)
 		else:
 			return getattr(RPCBackends,backend_id)(self)
 

+ 6 - 6
mmgen/term.py

@@ -27,18 +27,18 @@ from collections import namedtuple
 
 from .util import msg,msg_r,die
 
-try:
+if sys.platform == 'linux':
 	import tty,termios
 	from select import select
-	_platform = 'linux'
-except ImportError:
+elif sys.platform == 'win32':
 	try:
 		import msvcrt
-		_platform = 'mswin'
 	except:
 		die(2,'Unable to set terminal mode')
 	if not sys.stdin.isatty():
 		msvcrt.setmode(sys.stdin.fileno(),os.O_BINARY)
+else:
+	die(2,f'{sys.platform!r}: unsupported platform')
 
 _term_dimensions = namedtuple('terminal_dimensions',['width','height'])
 
@@ -285,8 +285,8 @@ class MMGenTermMSWinStub(MMGenTermMSWin):
 def get_term():
 	return {
 		'linux': (MMGenTermLinux if sys.stdin.isatty() else MMGenTermLinuxStub),
-		'mswin': (MMGenTermMSWin if sys.stdin.isatty() else MMGenTermMSWinStub),
-	}[_platform]
+		'win32': (MMGenTermMSWin if sys.stdin.isatty() else MMGenTermMSWinStub),
+	}[sys.platform]
 
 def init_term(cfg,noecho=False):
 

+ 2 - 4
mmgen/tool/fileutil.py

@@ -20,10 +20,9 @@
 tool.fileutil: File routines for the 'mmgen-tool' utility
 """
 
-import os
+import sys,os
 
 from .common import tool_cmd_base
-from ..cfg import gc
 from ..util import msg,msg_r,die,suf,make_full_path
 from ..crypto import Crypto
 
@@ -40,7 +39,7 @@ class tool_cmd(tool_cmd_base):
 
 		ivsize,bsize,mod = ( Crypto.aesctr_iv_len, 4096, 4096*8 )
 		n,carry = 0,b' '*ivsize
-		flgs = os.O_RDONLY|os.O_BINARY if gc.platform == 'win' else os.O_RDONLY
+		flgs = os.O_RDONLY|os.O_BINARY if sys.platform == 'win32' else os.O_RDONLY
 		f = os.open(filename,flgs)
 		for ch in incog_id:
 			if ch not in '0123456789ABCDEF':
@@ -56,7 +55,6 @@ class tool_cmd(tool_cmd_base):
 						continue
 					msg(f'\rIncog data for ID {incog_id} found at offset {n+i-ivsize}')
 					if not keep_searching:
-						import sys
 						sys.exit(0)
 			carry = d[len(d)-ivsize:]
 			n += bsize

+ 4 - 3
mmgen/tool/util.py

@@ -20,7 +20,8 @@
 tool.util: Utility commands for the 'mmgen-tool' utility
 """
 
-from ..cfg import gc
+import sys,os
+
 from .common import tool_cmd_base
 
 class tool_cmd(tool_cmd_base):
@@ -122,8 +123,8 @@ class tool_cmd(tool_cmd_base):
 
 	def unhexdump(self,infile:str):
 		"decode hexdump from file (use '-' for stdin) (warning: outputs binary data)"
-		if gc.platform == 'win':
-			import sys,os,msvcrt
+		if sys.platform == 'win32':
+			import msvcrt
 			msvcrt.setmode( sys.stdout.fileno(), os.O_BINARY )
 		from ..fileutil import get_data_from_file
 		from ..util2 import decode_pretty_hexdump

+ 2 - 3
mmgen/tw/json.py

@@ -12,7 +12,7 @@
 tw.json: export and import tracking wallet to JSON format
 """
 
-import os,json
+import sys,os,json
 from collections import namedtuple
 
 from ..util import msg,ymsg,fmt,suf,die,make_timestamp,make_chksum_8
@@ -54,8 +54,7 @@ class TwJSON:
 				from ..addrlist import AddrIdxList
 				prune_id = AddrIdxList(idx_list=self.pruned).id_str
 				fn = get_fn(prune_id)
-				from ..cfg import gc
-				mf = 255 if gc.platform == 'win' else os.statvfs(self.cfg.outdir or os.curdir).f_namemax
+				mf = 255 if sys.platform == 'win32' else os.statvfs(self.cfg.outdir or os.curdir).f_namemax
 				if len(fn) > mf:
 					fn = get_fn(f'idhash={make_chksum_8(prune_id.encode()).lower()}')
 			else:

+ 2 - 2
mmgen/tw/view.py

@@ -171,7 +171,7 @@ class TwView(MMGenObject,metaclass=AsyncInit):
 			'\x1b[7~': 'm_top',
 			'\x1b[8~': 'm_bot',
 		},
-		'win': {
+		'win32': {
 			'\xe0H': 'm_cursor_up',
 			'\xe0P': 'm_cursor_down',
 			'\xe0I': 'm_pg_up',
@@ -526,7 +526,7 @@ class TwView(MMGenObject,metaclass=AsyncInit):
 				for k in self.scroll_keys['vi']:
 					assert k not in self.key_mappings, f'{k!r} is in key_mappings'
 				self.key_mappings.update(self.scroll_keys['vi'])
-				self.key_mappings.update(self.scroll_keys[gc.platform])
+				self.key_mappings.update(self.scroll_keys[sys.platform])
 			return self.key_mappings
 
 		scroll = self.scroll = self.cfg.scroll

+ 2 - 2
mmgen/util.py

@@ -94,7 +94,7 @@ class Util:
 			msg(f'{capfirst(desc2)} OK ({val2})')
 		return True
 
-if gc.platform == 'win':
+if sys.platform == 'win32':
 	def msg_r(s):
 		try:
 			gv.stderr.write(s)
@@ -457,5 +457,5 @@ def wrap_ripemd160(called=[]):
 		called.append(True)
 
 def exit_if_mswin(feature):
-	if gc.platform == 'win':
+	if sys.platform == 'win32':
 		die(2, capfirst(feature) + ' not supported on the MSWin / MSYS2 platform' )

+ 3 - 4
mmgen/wallet/incog_hidden.py

@@ -12,9 +12,8 @@
 wallet.incog_hidden: hidden incognito wallet class
 """
 
-import os
+import sys,os
 
-from ..cfg import gc
 from ..seed import Seed
 from ..util import msg,die,capfirst
 from ..util2 import parse_bytespec
@@ -73,7 +72,7 @@ class wallet(wallet):
 		d.target_data_len = self._get_incog_data_len(self.cfg.seed_len or Seed.dfl_len)
 		self._check_valid_offset(self.infile,'read')
 
-		flgs = os.O_RDONLY|os.O_BINARY if gc.platform == 'win' else os.O_RDONLY
+		flgs = os.O_RDONLY|os.O_BINARY if sys.platform == 'win32' else os.O_RDONLY
 		fh = os.open(self.infile.name,flgs)
 		os.lseek(fh,int(d.hincog_offset),os.SEEK_SET)
 		self.fmt_data = os.read(fh,d.target_data_len)
@@ -136,7 +135,7 @@ class wallet(wallet):
 					message = '',
 					action  = f'alter file {f.name!r}' )
 
-		flgs = os.O_RDWR|os.O_BINARY if gc.platform == 'win' else os.O_RDWR
+		flgs = os.O_RDWR|os.O_BINARY if sys.platform == 'win32' else os.O_RDWR
 		fh = os.open(f.name,flgs)
 		os.lseek(fh, int(d.hincog_offset), os.SEEK_SET)
 		os.write(fh, self.fmt_data)

+ 2 - 2
test/hashfunc.py

@@ -112,7 +112,7 @@ class TestKeccak(TestHashFunc):
 		from mmgen.contrib.keccak import keccak_256
 		self.t_cls = keccak_256
 		from mmgen.pyversion import python_version
-		if python_version >= '3.11' or gc.platform == 'win':
+		if python_version >= '3.11' or sys.platform == 'win32':
 			class hashlib:
 				@staticmethod
 				def keccak_256(data):
@@ -175,7 +175,7 @@ class TestSha512(TestSha2):
 		0x431d67c49c100d4c, 0x4cc5d4becb3e42b6, 0x597f299cfc657e2a, 0x5fcb6fab3ad6faec, 0x6c44198c4a475817 )
 
 from test.include.common import getrand,set_globals
-from mmgen.cfg import Config,gc
+from mmgen.cfg import Config
 
 set_globals(Config())
 

+ 4 - 4
test/misc/term.py

@@ -21,13 +21,13 @@ commands = [
 	'get_char_one',
 	'get_char_one_raw',
 ]
-if gc.platform == 'linux':
+if sys.platform == 'linux':
 	commands.extend([
 		'get_char',
 		'get_char_immed_chars',
 		'get_char_raw',
 	])
-elif gc.platform == 'win':
+elif sys.platform == 'win32':
 	commands.extend([
 		'get_char_one_char_immed_chars',
 	])
@@ -40,7 +40,7 @@ opts_data = {
 -h, --help     Print this help message
 """,
 	'notes': f"""
-available commands for platform {gc.platform!r}:
+available commands for platform {sys.platform!r}:
 {fmt_list(commands,fmt='col',indent='    ')}
 """
 	}
@@ -120,7 +120,7 @@ def _tt_get_char(raw=False,one_char=False,immed_chars=''):
 			if one_char else
 		'echoed as a FULL CONTROL SEQUENCE.'
 	)
-	if gc.platform == 'win':
+	if sys.platform == 'win32':
 		if raw:
 			m3 = 'The Escape and F1-F12 keys will be returned as two-character strings.'
 		else:

+ 3 - 3
test/scrambletest.py

@@ -21,13 +21,13 @@ test/scrambletest.py: seed scrambling and addrlist data generation tests for all
                       supported coins + passwords
 """
 
-import os,time
+import sys,os,time
 from subprocess import run,PIPE
 from collections import namedtuple
 
 import include.test_init
 
-from mmgen.cfg import gc,Config
+from mmgen.cfg import Config
 from mmgen.util import msg,msg_r,bmsg,die
 
 opts_data = {
@@ -129,7 +129,7 @@ def do_coin_tests():
 	for tname,tdata in (
 			tuple(bitcoin_data.items()) +
 			tuple(altcoin_data.items() if not cfg.no_altcoin else []) ):
-		if tname == 'zec_zcash_z' and gc.platform == 'win':
+		if tname == 'zec_zcash_z' and sys.platform == 'win32':
 			msg("Skipping 'zec_zcash_z' test for Windows platform")
 			continue
 		coin,mmtype = tname.split('_',1) if '_' in tname else (tname,None)

+ 6 - 6
test/test.py

@@ -30,7 +30,7 @@ def create_shm_dir(data_dir,trash_dir):
 	# under '/dev/shm' and put datadir and tmpdirs here.
 	import shutil
 	from subprocess import run
-	if gc.platform == 'win':
+	if sys.platform == 'win32':
 		for tdir in (data_dir,trash_dir):
 			try:
 				os.listdir(tdir)
@@ -222,7 +222,7 @@ cfg.skipping_deps = cfg.resuming or 'skip_deps' in po.user_opts
 
 cmd_args = cfg._args
 
-if cfg.pexpect_spawn and gc.platform == 'win':
+if cfg.pexpect_spawn and sys.platform == 'win32':
 	die(1,'--pexpect-spawn option not supported on Windows platform, exiting')
 
 if cfg.daemon_id and cfg.daemon_id in cfg.blacklisted_daemons.split():
@@ -343,7 +343,7 @@ def clean(usr_dirs=None,clean_overlay=True):
 		iqmsg(green(f'Cleaned directory {os.path.relpath(overlay_tree_dir)!r}'))
 
 def create_tmp_dirs(shm_dir):
-	if gc.platform == 'win':
+	if sys.platform == 'win32':
 		for cfg in sorted(cfgs):
 			mk_tmpdir(cfgs[cfg]['tmpdir'])
 	else:
@@ -569,7 +569,7 @@ class TestSuiteRunner:
 			omsg(f'INFO → Writing coverage files to {coverdir!r}')
 			self.pre_args = ['python3','-m','trace','--count','--coverdir='+coverdir,'--file='+accfile]
 		else:
-			self.pre_args = ['python3'] if gc.platform == 'win' else []
+			self.pre_args = ['python3'] if sys.platform == 'win32' else []
 
 		if cfg.pexpect_spawn:
 			omsg('INFO → Using pexpect.spawn() for real terminal emulation')
@@ -649,7 +649,7 @@ class TestSuiteRunner:
 					clr1,clr2 = (nocolor,nocolor) if cfg.print_cmdline else (green,cyan)
 					omsg(
 						clr1('Executing: ') +
-						clr2(repr(cmd_disp) if gc.platform == 'win' else cmd_disp)
+						clr2(repr(cmd_disp) if sys.platform == 'win32' else cmd_disp)
 					)
 			else:
 				omsg_r('{a}Testing {b}: {c}'.format(
@@ -694,7 +694,7 @@ class TestSuiteRunner:
 
 		ts_cls = CmdGroupMgr().load_mod(gname)
 
-		if gc.platform == 'win' and ts_cls.win_skip:
+		if sys.platform == 'win32' and ts_cls.win_skip:
 			omsg(f'Skipping test {gname!r} for Windows platform')
 			return False
 

+ 1 - 2
test/test_py_d/common.py

@@ -22,7 +22,6 @@ test.test_py_d.common: Shared routines and data for the test.py test suite
 
 import sys,os
 
-from mmgen.cfg import gc
 from mmgen.color import green,blue
 from mmgen.util import msg
 
@@ -55,7 +54,7 @@ from mmgen.obj import MMGenTxComment,TwComment
 tx_comment_jp = text_jp
 tx_comment_zh = text_zh
 
-lcg = ascii_cyr_gr if gc.platform == 'win' else lat_cyr_gr # MSYS2 popen_spawn issue
+lcg = ascii_cyr_gr if sys.platform == 'win32' else lat_cyr_gr # MSYS2 popen_spawn issue
 tx_comment_lat_cyr_gr = lcg[:MMGenTxComment.max_len] # 72 chars
 
 tw_comment_zh         = text_zh[:TwComment.max_screen_width // 2]

+ 2 - 3
test/test_py_d/ts_autosign.py

@@ -20,11 +20,10 @@
 test.test_py_d.ts_autosign: Autosign tests for the test.py test suite
 """
 
-import os,shutil
+import sys,os,shutil
 from subprocess import run
 from pathlib import Path
 
-from mmgen.cfg import gc
 from mmgen.color import red,green,blue,purple
 from mmgen.util import msg,suf,die
 from mmgen.led import LEDControl
@@ -162,7 +161,7 @@ class TestSuiteAutosignBase(TestSuiteBase):
 		self.bad_msg_count = 0
 
 	def __del__(self):
-		if gc.platform == 'win' or self.tr is None:
+		if sys.platform == 'win32' or self.tr is None:
 			return
 		if self.simulate or not self.live:
 			LEDControl.delete_dummy_control_files()

+ 2 - 3
test/test_py_d/ts_base.py

@@ -20,9 +20,8 @@
 test.test_py_d.ts_base: Base class for the test.py test suite
 """
 
-import os
+import sys,os
 
-from mmgen.cfg import gc
 from mmgen.util import msg
 
 from ..include.common import cfg,write_to_file,read_from_file
@@ -91,7 +90,7 @@ class TestSuiteBase:
 			msg(f'{fn}: file does not exist or could not be deleted')
 
 	def skip_for_win(self):
-		if gc.platform == 'win':
+		if sys.platform == 'win32':
 			msg(f'Skipping test {self.test_name!r}: not supported on MSys2 platform')
 			return True
 		else:

+ 2 - 3
test/test_py_d/ts_cfgfile.py

@@ -10,9 +10,8 @@
 test.test_py_d.ts_cfgfile: CfgFile tests for the MMGen test.py test suite
 """
 
-import os,time,shutil
+import sys,os,time,shutil
 
-from mmgen.cfg import gc
 from mmgen.color import yellow
 from mmgen.cfgfile import CfgFileSampleSys,CfgFileSampleUsr,cfg_file_sample
 
@@ -158,7 +157,7 @@ class TestSuiteCfgFile(TestSuiteBase):
 		write_to_file(self.path('usr'),'\n'.join(d) + '\n')
 		return self.old_sample_common(
 			old_set       = True,
-			pexpect_spawn = not gc.platform == 'win')
+			pexpect_spawn = not sys.platform == 'win32')
 
 	def _autoset_opts(self,args=[],text='rpc_backend aiohttp\n'):
 		write_to_file( self.path('usr'), text )

+ 2 - 3
test/test_py_d/ts_ethdev.py

@@ -20,12 +20,11 @@
 test.test_py_d.ts_ethdev: Ethdev tests for the test.py test suite
 """
 
-import os,re,shutil,asyncio,json
+import sys,os,re,shutil,asyncio,json
 from decimal import Decimal
 from collections import namedtuple
 from subprocess import run,PIPE,DEVNULL
 
-from mmgen.cfg import gc
 from mmgen.color import yellow,blue,cyan,set_vt100
 from mmgen.util import msg,rmsg,die
 
@@ -1373,7 +1372,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
 	def edit_comment1(self):
 		return self.edit_comment(out_num=del_addrs[0],comment_text=tw_comment_zh[:3])
 	def edit_comment2(self):
-		spawn = not gc.platform == 'win'
+		spawn = not sys.platform == 'win32'
 		return self.edit_comment(
 				out_num       = del_addrs[0],
 				comment_text  = tw_comment_zh[3:],

+ 4 - 4
test/test_py_d/ts_input.py

@@ -10,7 +10,7 @@
 test.test_py_d.ts_input: user input tests for the MMGen test.py test suite
 """
 
-import os
+import sys,os
 
 from mmgen.cfg import gc
 from mmgen.util import fmt,capfirst,remove_whitespace
@@ -238,7 +238,7 @@ class TestSuiteInput(TestSuiteBase):
 		return t
 
 	def _input_func(self,func_name,arg_dfls,func_args,text,expect,term):
-		if term and gc.platform == 'win':
+		if term and sys.platform == 'win32':
 			return ('skip_warn','pexpect_spawn not supported on Windows platform')
 		func_args = dict(zip(arg_dfls.keys(),func_args))
 		t = self.spawn(
@@ -287,7 +287,7 @@ class TestSuiteInput(TestSuiteBase):
 		return self._get_char(['prompt> ','',True,5],'x','x',False)
 
 	def get_char2(self):
-		expect = 'x' if gc.platform == 'win' else 'xxxxx'
+		expect = 'x' if sys.platform == 'win32' else 'xxxxx'
 		return self._get_char(['prompt> ','',True,5],'xxxxx',expect,False)
 
 	def get_char3(self):
@@ -333,7 +333,7 @@ class TestSuiteInput(TestSuiteBase):
 		return self._line_input(['prompt> ',True,'foobarbaz',True],Ctrl_U+'foobar','foobar',True)
 
 	def _password_entry(self,prompt,opts=[],term=False):
-		if term and gc.platform == 'win':
+		if term and sys.platform == 'win32':
 			return ('skip_warn','pexpect_spawn not supported on Windows platform')
 		t = self.spawn( 'test/misc/input_func.py', opts + ['passphrase'], cmd_dir='.', pexpect_spawn=term )
 		imsg(f'Terminal: {term}')

+ 2 - 3
test/test_py_d/ts_misc.py

@@ -22,7 +22,6 @@ test.test_py_d.ts_misc: Miscellaneous test groups for the test.py test suite
 
 import sys,os,re,time
 
-from mmgen.cfg import gc
 from mmgen.util import ymsg
 
 from ..include.common import cfg,start_test_daemons,stop_test_daemons,imsg
@@ -187,7 +186,7 @@ class TestSuiteHelp(TestSuiteBase):
 		if self.proto.coin not in ('BTC','XMR') and 'xmrwallet' in scripts:
 			scripts.remove('xmrwallet')
 
-		if gc.platform == 'win' and 'autosign' in scripts:
+		if sys.platform == 'win32' and 'autosign' in scripts:
 			scripts.remove('autosign')
 
 		for s in sorted(scripts):
@@ -300,7 +299,7 @@ class TestSuiteOutput(TestSuiteBase):
 
 	def oneshot_warning(self,pexpect_spawn=None):
 		t = self.spawn('test/misc/oneshot_warning.py',cmd_dir='.',pexpect_spawn=pexpect_spawn)
-		nl = '\r\n' if gc.platform == 'win' or t.pexpect_spawn else '\n'
+		nl = '\r\n' if sys.platform == 'win32' or t.pexpect_spawn else '\n'
 		for s in (
 			f'pw{nl}wg1',
 			'foo is experimental',

+ 2 - 3
test/test_py_d/ts_tool.py

@@ -10,9 +10,8 @@
 test.test_py_d.ts_tool: tool tests for the MMGen test.py test suite
 """
 
-import os
+import sys,os
 
-from mmgen.cfg import gc
 from mmgen.util import suf
 from mmgen.color import cyan
 
@@ -86,7 +85,7 @@ class TestSuiteTool(TestSuiteMain,TestSuiteBase):
 		vmsg(f'Incog ID: {cyan(i_id)}')
 		t = self.spawn('mmgen-tool',['-d',self.tmpdir,'find_incog_data',f1,i_id])
 		o = t.expect_getend(f'Incog data for ID {i_id} found at offset ')
-		if not gc.platform == 'win':
+		if not sys.platform == 'win32':
 			os.unlink(f1) # causes problems with MSYS2
 		cmp_or_die(hincog_offset,int(o))
 		return t

+ 3 - 4
test/test_py_d/ts_xmrwallet.py

@@ -20,11 +20,10 @@
 test.test_py_d.ts_xmrwallet: xmrwallet tests for the test.py test suite
 """
 
-import os,time,re,atexit,asyncio,shutil
+import sys,os,time,re,atexit,asyncio,shutil
 from subprocess import run,PIPE
 from collections import namedtuple
 
-from mmgen.cfg import gc
 from mmgen.util import msg,fmt,async_run,capfirst,is_int,die,list_gen
 from mmgen.obj import MMGenRange
 from mmgen.amt import XMRAmt
@@ -58,7 +57,7 @@ def stop_miner_wallet_daemon(self):
 	async_run(self.users['miner'].wd_rpc.stop_daemon())
 
 def kill_proxy(cls,args):
-	if gc.platform == 'linux':
+	if sys.platform == 'linux':
 		omsg(f'Killing SSH SOCKS server at localhost:{cls.socks_port}')
 		cmd = [ 'pkill', '-f', ' '.join(args) ]
 		run(cmd)
@@ -840,7 +839,7 @@ class TestSuiteXMRWallet(TestSuiteBase):
 		h = await self._get_height()
 		imsg_r(f'Chain height: {h} ')
 
-		max_iterations,height_threshold = (300,80) if gc.platform == 'win' else (50,300)
+		max_iterations,height_threshold = (300,80) if sys.platform == 'win32' else (50,300)
 
 		for count in range(max_iterations):
 			bal_info = await get_balance(dest,count)

+ 2 - 2
test/tooltest.py

@@ -25,7 +25,7 @@ from subprocess import run,PIPE
 
 import include.test_init
 
-from mmgen.cfg import Config,gc
+from mmgen.cfg import Config
 from mmgen.color import red,yellow,green,blue,cyan
 from mmgen.util import msg,msg_r,Msg,die
 
@@ -152,7 +152,7 @@ spawn_cmd = [
 if cfg.coverage:
 	d,f = init_coverage()
 	spawn_cmd = ['python3','-m','trace','--count','--coverdir='+d,'--file='+f] + spawn_cmd
-elif gc.platform == 'win':
+elif sys.platform == 'win32':
 	spawn_cmd = ['python3'] + spawn_cmd
 
 add_spawn_args = ['--data-dir='+tcfg['tmpdir']] + ['--{}{}'.format(

+ 3 - 3
test/tooltest2.py

@@ -31,7 +31,7 @@ import include.test_init
 
 from test.include.common import set_globals,end_msg,sample_text,init_coverage
 
-from mmgen.cfg import Config,gc
+from mmgen.cfg import Config
 from mmgen.color import green,blue,purple,cyan
 from mmgen.util import msg,msg_r,Msg,is_hex_str,async_run,die
 
@@ -41,7 +41,7 @@ from mmgen.xmrseed import is_xmrseed
 
 skipped_tests = ['mn2hex_interactive']
 
-NL = ('\n','\r\n')[gc.platform=='win']
+NL = ('\n','\r\n')[sys.platform=='win32']
 
 def is_str(s):
 	return isinstance(s,str)
@@ -888,7 +888,7 @@ async def run_test(cls,gid,cmd_name):
 		elif cfg.fork:
 			cmd_out = fork_cmd(cmd_name,args,opts,stdin_input)
 		else:
-			if stdin_input and gc.platform == 'win':
+			if stdin_input and sys.platform == 'win32':
 				msg('Skipping for MSWin - no os.fork()')
 				continue
 			method = getattr(cls(cfg,cmdname=cmd_name,proto=proto,mmtype=mmtype),cmd_name)

+ 1 - 1
test/unit_tests.py

@@ -186,7 +186,7 @@ def run_test(test,subtest=None):
 			if cfg.no_altcoin_deps and subtest in altcoin_deps:
 				cfg._util.qmsg(gray(f'Invoked with --no-altcoin-deps, so skipping subtest {subtest_disp!r}'))
 				continue
-			if gc.platform == 'win' and subtest in win_skip:
+			if sys.platform == 'win32' and subtest in win_skip:
 				cfg._util.qmsg(gray(f'Skipping subtest {subtest_disp!r} for Windows platform'))
 				continue
 			elif platform.machine() == 'aarch64' and subtest in arm_skip:

+ 4 - 4
test/unit_tests_d/ut_dep.py

@@ -7,9 +7,9 @@ test.unit_tests_d.ut_dep: dependency unit tests for the MMGen suite
   No data verification is performed.
 """
 
+import sys
 from subprocess import run,PIPE
 
-from mmgen.cfg import gc
 from mmgen.util import msg,ymsg,gmsg
 from mmgen.exception import NoLEDSupport
 
@@ -40,15 +40,15 @@ class unit_tests:
 
 	def pycryptodomex(self,name,ut): # ETH,XMR
 		from mmgen.pyversion import python_version
-		if python_version >= '3.11' or gc.platform == 'win':
+		if python_version >= '3.11' or sys.platform == 'win32':
 			try:
 				from mmgen.util import load_cryptodomex
 			except Exception as e:
 				msg(str(e))
 				ymsg('Please install the ‘pycryptodome’ or ‘pycryptodomex’ package on your system')
 				return False
-		elif gc.platform != 'win':
-			ut.skip_msg(f'platform {gc.platform!r}')
+		elif sys.platform != 'win32':
+			ut.skip_msg(f'platform {sys.platform!r}')
 		else:
 			ut.skip_msg(f'Python version {python_version}')
 		return True

+ 3 - 4
test/unit_tests_d/ut_rpc.py

@@ -4,9 +4,8 @@
 test.unit_tests_d.ut_rpc: RPC unit test for the MMGen suite
 """
 
-import os,time
+import sys,os,time
 
-from mmgen.cfg import gc
 from mmgen.color import yellow,cyan
 from mmgen.util import msg,gmsg,async_run,make_timestr,pp_fmt,die
 from mmgen.protocol import init_proto
@@ -125,7 +124,7 @@ def run_test(network_ids,test_cf_auth=False,daemon_ids=None):
 		if not cfg.no_daemon_stop:
 			d.stop()
 
-		if test_cf_auth and gc.platform != 'win':
+		if test_cf_auth and sys.platform != 'win32':
 			cfg_file_auth_test(d.proto,d)
 			cfg_file_auth_test(d.proto,d,bad_auth=True)
 
@@ -211,7 +210,7 @@ class unit_tests:
 					password = 'foo',
 					seed     = xmrseed().fromhex('beadface'*8,tostr=True) )
 
-				if gc.platform == 'win':
+				if sys.platform == 'win32':
 					wd.stop()
 					wd.start()
 

+ 2 - 3
test/unit_tests_d/ut_testdep.py

@@ -4,10 +4,9 @@
 test.unit_tests_d.ut_testdep: test dependency unit tests for the MMGen suite
 """
 
-import os
+import sys,os
 from subprocess import run,PIPE
 
-from mmgen.cfg import gc
 from mmgen.util import ymsg
 
 sec = 'deadbeef' * 8
@@ -51,7 +50,7 @@ class unit_tests:
 		return True
 
 	def ethkey(self,name,ut):
-		if gc.platform == 'linux' and os.uname().machine != 'x86_64':
+		if sys.platform == 'linux' and os.uname().machine != 'x86_64':
 			distro = [l for l in open('/etc/os-release').read().split('\n') if l.startswith('ID=')][0][3:]
 			if distro != 'archarm':
 				ut.skip_msg(f'distro {distro!r} on architecture {os.uname().machine!r}')