mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-30 10:07:14 +02:00
Use util.get_systype when checking for system
This commit is contained in:
@ -23,7 +23,6 @@ import sys
|
|||||||
from glob import glob
|
from glob import glob
|
||||||
from os.path import (basename, commonprefix, dirname, isdir, isfile, join,
|
from os.path import (basename, commonprefix, dirname, isdir, isfile, join,
|
||||||
realpath, sep)
|
realpath, sep)
|
||||||
from platform import system
|
|
||||||
|
|
||||||
import SCons.Scanner
|
import SCons.Scanner
|
||||||
from SCons.Script import ARGUMENTS, COMMAND_LINE_TARGETS, DefaultEnvironment
|
from SCons.Script import ARGUMENTS, COMMAND_LINE_TARGETS, DefaultEnvironment
|
||||||
@ -82,6 +81,8 @@ class LibBuilderFactory(object):
|
|||||||
|
|
||||||
class LibBuilderBase(object):
|
class LibBuilderBase(object):
|
||||||
|
|
||||||
|
IS_WINDOWS = "windows" in util.get_systype()
|
||||||
|
|
||||||
LDF_MODES = ["off", "chain", "deep", "chain+", "deep+"]
|
LDF_MODES = ["off", "chain", "deep", "chain+", "deep+"]
|
||||||
LDF_MODE_DEFAULT = "chain"
|
LDF_MODE_DEFAULT = "chain"
|
||||||
|
|
||||||
@ -119,7 +120,7 @@ class LibBuilderBase(object):
|
|||||||
def __contains__(self, path):
|
def __contains__(self, path):
|
||||||
p1 = self.path
|
p1 = self.path
|
||||||
p2 = path
|
p2 = path
|
||||||
if system() == "Windows":
|
if self.IS_WINDOWS:
|
||||||
p1 = p1.lower()
|
p1 = p1.lower()
|
||||||
p2 = p2.lower()
|
p2 = p2.lower()
|
||||||
return commonprefix((p1 + sep, p2)) == p1 + sep
|
return commonprefix((p1 + sep, p2)) == p1 + sep
|
||||||
|
@ -18,7 +18,6 @@ import sys
|
|||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
from os import environ
|
from os import environ
|
||||||
from os.path import isfile, join
|
from os.path import isfile, join
|
||||||
from platform import system
|
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
@ -133,7 +132,7 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument
|
|||||||
port = item['port']
|
port = item['port']
|
||||||
if upload_protocol.startswith("blackmagic") \
|
if upload_protocol.startswith("blackmagic") \
|
||||||
and "GDB" in item['description']:
|
and "GDB" in item['description']:
|
||||||
return ("\\\\.\\%s" % port if system() == "Windows"
|
return ("\\\\.\\%s" % port if "windows" in util.get_systype()
|
||||||
and port.startswith("COM") and len(port) > 4 else port)
|
and port.startswith("COM") and len(port) > 4 else port)
|
||||||
for hwid in board_hwids:
|
for hwid in board_hwids:
|
||||||
hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "")
|
hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "")
|
||||||
@ -149,7 +148,7 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument
|
|||||||
and not env.subst("$UPLOAD_PROTOCOL"):
|
and not env.subst("$UPLOAD_PROTOCOL"):
|
||||||
env.Replace(UPLOAD_PORT=_look_for_mbed_disk())
|
env.Replace(UPLOAD_PORT=_look_for_mbed_disk())
|
||||||
else:
|
else:
|
||||||
if (system() == "Linux" and not any([
|
if ("linux" in util.get_systype() and not any([
|
||||||
isfile("/etc/udev/rules.d/99-platformio-udev.rules"),
|
isfile("/etc/udev/rules.d/99-platformio-udev.rules"),
|
||||||
isfile("/lib/udev/rules.d/99-platformio-udev.rules")
|
isfile("/lib/udev/rules.d/99-platformio-udev.rules")
|
||||||
])):
|
])):
|
||||||
|
@ -431,7 +431,7 @@ def get_serial_ports(filter_hwid=False):
|
|||||||
for p, d, h in comports():
|
for p, d, h in comports():
|
||||||
if not p:
|
if not p:
|
||||||
continue
|
continue
|
||||||
if platform.system() == "Windows":
|
if "windows" in get_systype():
|
||||||
try:
|
try:
|
||||||
d = unicode(d, errors="ignore")
|
d = unicode(d, errors="ignore")
|
||||||
except TypeError:
|
except TypeError:
|
||||||
@ -443,7 +443,7 @@ def get_serial_ports(filter_hwid=False):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
# fix for PySerial
|
# fix for PySerial
|
||||||
if not result and platform.system() == "Darwin":
|
if not result and "darwin" in get_systype():
|
||||||
for p in glob("/dev/tty.*"):
|
for p in glob("/dev/tty.*"):
|
||||||
result.append({"port": p, "description": "n/a", "hwid": "n/a"})
|
result.append({"port": p, "description": "n/a", "hwid": "n/a"})
|
||||||
return result
|
return result
|
||||||
@ -455,7 +455,7 @@ get_serialports = get_serial_ports
|
|||||||
|
|
||||||
def get_logical_devices():
|
def get_logical_devices():
|
||||||
items = []
|
items = []
|
||||||
if platform.system() == "Windows":
|
if "windows" in get_systype():
|
||||||
try:
|
try:
|
||||||
result = exec_command(
|
result = exec_command(
|
||||||
["wmic", "logicaldisk", "get", "name,VolumeName"]).get(
|
["wmic", "logicaldisk", "get", "name,VolumeName"]).get(
|
||||||
|
Reference in New Issue
Block a user