Improved system type detection

This commit is contained in:
Ivan Kravets
2014-07-31 16:20:31 +03:00
parent e81723f73c
commit 3bd1fe51ab
5 changed files with 13 additions and 14 deletions

View File

@ -12,7 +12,6 @@ from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
from platformio.util import reset_serialport
env = DefaultEnvironment()
env.Replace(

View File

@ -7,13 +7,11 @@
"""
from os.path import join
from platform import system
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
DefaultEnvironment)
from platformio.util import get_system
env = DefaultEnvironment()
env.Replace(
@ -55,7 +53,7 @@ env.Replace(
UPLOADER=join("$PLATFORMTOOLS_DIR", "mspdebug", "mspdebug"),
UPLOADERFLAGS=[
"$UPLOAD_PROTOCOL" if get_system() != "windows32" else "tilib",
"$UPLOAD_PROTOCOL" if system() != "Windows" else "tilib",
"--force-reset"
],
UPLOADCMD='$UPLOADER $UPLOADERFLAGS "prog $SOURCES"'

View File

@ -11,7 +11,6 @@ from os.path import join
from SCons.Script import (AlwaysBuild, Builder, COMMAND_LINE_TARGETS, Default,
DefaultEnvironment)
env = DefaultEnvironment()
env.Replace(

View File

@ -14,7 +14,7 @@ from platformio.downloader import FileDownloader
from platformio.exception import (InvalidPackageVersion, NonSystemPackage,
UnknownPackage)
from platformio.unpacker import FileUnpacker
from platformio.util import get_home_dir, get_system
from platformio.util import get_home_dir, get_systype
class PackageManager(object):
@ -66,11 +66,11 @@ class PackageManager(object):
raise UnknownPackage(name)
# check system platform
system = get_system()
builds = ([b for b in manifest[name] if b['system'] == "all" or system
systype = get_systype()
builds = ([b for b in manifest[name] if b['system'] == "all" or systype
in b['system']])
if not builds:
raise NonSystemPackage(name, system)
raise NonSystemPackage(name, systype)
if version:
for b in builds:

View File

@ -4,7 +4,7 @@
from os import name as os_name
from os import getcwd, getenv, listdir, utime
from os.path import dirname, expanduser, isfile, join, realpath
from platform import architecture, system
from platform import system, uname
from subprocess import PIPE, Popen
from time import sleep
@ -18,8 +18,11 @@ except ImportError:
from ConfigParser import ConfigParser
def get_system():
return (system() + architecture()[0][:-3]).lower()
def get_systype():
if system() == "Windows":
return "windows"
data = uname()
return ("%s_%s" % (data[0], data[4])).lower()
def get_home_dir():
@ -61,7 +64,7 @@ def change_filemtime(path, time):
def exec_command(args):
use_shell = get_system() == "windows32"
use_shell = system() == "Windows"
p = Popen(args, stdout=PIPE, stderr=PIPE, shell=use_shell)
out, err = p.communicate()
return dict(out=out.strip(), err=err.strip())