platform-specific imports

This commit is contained in:
Damien Elmes 2019-12-16 17:51:33 +10:00
parent c9820fae99
commit d2f4450dc0
4 changed files with 10 additions and 11 deletions

View file

@ -128,7 +128,7 @@ create table meta (dirMod int, lastUsn int); insert into meta values (0, 0);
if not isWin: if not isWin:
return return
# pylint: disable=import-error # pylint: disable=import-error
import win32api, win32file import win32api, win32file # pytype: disable=import-error
try: try:
name = win32file.GetVolumeNameForVolumeMountPoint(self._dir[:3]) name = win32file.GetVolumeNameForVolumeMountPoint(self._dir[:3])
except: except:

View file

@ -58,8 +58,7 @@ class MPVTimeoutError(MPVError):
from anki.utils import isWin from anki.utils import isWin
if isWin: if isWin:
# pylint: disable=import-error # pylint: disable=import-error
import win32file, win32pipe, pywintypes, winerror import win32file, win32pipe, pywintypes, winerror # pytype: disable=import-error
class MPVBase: class MPVBase:
"""Base class for communication with the mpv media player via unix socket """Base class for communication with the mpv media player via unix socket
based JSON IPC. based JSON IPC.

View file

@ -66,13 +66,13 @@ processingChain = [
# don't show box on windows # don't show box on windows
if sys.platform == "win32": if sys.platform == "win32":
si = subprocess.STARTUPINFO() si = subprocess.STARTUPINFO() # pytype: disable=module-attr
try: try:
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW si.dwFlags |= subprocess.STARTF_USESHOWWINDOW # pytype: disable=module-attr
except: except:
# pylint: disable=no-member # pylint: disable=no-member
# python2.7+ # python2.7+
si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW # pytype: disable=module-attr
else: else:
si = None si = None
@ -153,7 +153,7 @@ def cleanupMPV():
# which prevents renaming or deleting the profile # which prevents renaming or deleting the profile
def cleanupOldMplayerProcesses(): def cleanupOldMplayerProcesses():
# pylint: disable=import-error # pylint: disable=import-error
import psutil import psutil # pytype: disable=import-error
exeDir = os.path.dirname(os.path.abspath(sys.argv[0])) exeDir = os.path.dirname(os.path.abspath(sys.argv[0]))

View file

@ -334,12 +334,12 @@ def call(argv, wait=True, **kwargs):
"Execute a command. If WAIT, return exit code." "Execute a command. If WAIT, return exit code."
# ensure we don't open a separate window for forking process on windows # ensure we don't open a separate window for forking process on windows
if isWin: if isWin:
si = subprocess.STARTUPINFO() si = subprocess.STARTUPINFO() # pytype: disable=module-attr
try: try:
si.dwFlags |= subprocess.STARTF_USESHOWWINDOW si.dwFlags |= subprocess.STARTF_USESHOWWINDOW # pytype: disable=module-attr
except: except:
# pylint: disable=no-member # pylint: disable=no-member
si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW si.dwFlags |= subprocess._subprocess.STARTF_USESHOWWINDOW # pytype: disable=module-attr
else: else:
si = None si = None
# run # run
@ -396,7 +396,7 @@ def platDesc():
elif isWin: elif isWin:
theos = "win:%s" % (platform.win32_ver()[0]) theos = "win:%s" % (platform.win32_ver()[0])
elif system == "Linux": elif system == "Linux":
import distro import distro # pytype: disable=import-error
r = distro.linux_distribution(full_distribution_name=False) r = distro.linux_distribution(full_distribution_name=False)
theos = "lin:%s:%s" % (r[0], r[1]) theos = "lin:%s:%s" % (r[0], r[1])
else: else: