• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ARMmbed / mbed-os-tools / #457

24 Aug 2024 09:15PM UTC coverage: 0.0% (-59.9%) from 59.947%
#457

push

coveralls-python

web-flow
Merge 7c6dbce13 into c467d6f14

0 of 4902 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/mbed_os_tools/detect/main.py
1

2
# Copyright (c) 2018, Arm Limited and affiliates.
3
# SPDX-License-Identifier: Apache-2.0
4
#
5
# Licensed under the Apache License, Version 2.0 (the "License");
6
# you may not use this file except in compliance with the License.
7
# You may obtain a copy of the License at
8
#
9
#     http://www.apache.org/licenses/LICENSE-2.0
10
#
11
# Unless required by applicable law or agreed to in writing, software
12
# distributed under the License is distributed on an "AS IS" BASIS,
13
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
# See the License for the specific language governing permissions and
15
# limitations under the License.
16

17
import os
×
18
import sys
×
19
import platform
×
20

21
# Make sure that any global generic setup is run
22
from . import lstools_base  # noqa: F401
×
23

24
import logging
×
25

26
logger = logging.getLogger("mbedls.main")
×
27
logger.addHandler(logging.NullHandler())
×
28
del logging
×
29

30

31
def create(**kwargs):
×
32
    """! Factory used to create host OS specific mbed-lstools object
33

34
    :param kwargs: keyword arguments to pass along to the constructors
35
    @return Returns MbedLsTools object or None if host OS is not supported
36

37
    """
38
    result = None
×
39
    mbed_os = mbed_os_support()
×
40
    if mbed_os is not None:
×
41
        if mbed_os == "Windows7":
×
42
            from .windows import MbedLsToolsWin7
×
43

44
            result = MbedLsToolsWin7(**kwargs)
×
45
        elif mbed_os == "LinuxGeneric":
×
46
            from .linux import MbedLsToolsLinuxGeneric
×
47

48
            result = MbedLsToolsLinuxGeneric(**kwargs)
×
49
        elif mbed_os == "Darwin":
×
50
            from .darwin import MbedLsToolsDarwin
×
51

52
            result = MbedLsToolsDarwin(**kwargs)
×
53
    return result
×
54

55

56
def mbed_os_support():
×
57
    """! Function used to determine if host OS is supported by mbed-lstools
58

59
    @return Returns None if host OS is not supported else return OS short name
60

61
    @details This function should be ported for new OS support
62
    """
63
    result = None
×
64
    os_info = mbed_lstools_os_info()
×
65
    if os_info[0] == "nt" and os_info[1] == "Windows":
×
66
        result = "Windows7"
×
67
    elif os_info[0] == "posix" and os_info[1] == "Linux":
×
68
        result = "LinuxGeneric"
×
69
    elif os_info[0] == "posix" and os_info[1] == "Darwin":
×
70
        result = "Darwin"
×
71
    return result
×
72

73

74
def mbed_lstools_os_info():
×
75
    """! Returns information about host OS
76

77
    @return Returns tuple with information about OS and host platform
78
    """
79
    result = (
×
80
        os.name,
81
        platform.system(),
82
        platform.release(),
83
        platform.version(),
84
        sys.platform,
85
    )
86
    return result
×
87

88

89
def mock_platform(mbeds, args):
×
90
    for token in args.mock.split(","):
×
91
        if ":" in token:
×
92
            oper = "+"  # Default
×
93
            mid, platform_name = token.split(":")
×
94
            if mid and mid[0] in ["+", "-"]:
×
95
                oper = mid[0]  # Operation (character)
×
96
                mid = mid[1:]  # We remove operation character
×
97
            mbeds.mock_manufacture_id(mid, platform_name, oper=oper)
×
98
        elif token and token[0] in ["-", "!"]:
×
99
            # Operations where do not specify data after colon: --mock=-1234,-7678
100
            oper = token[0]
×
101
            mid = token[1:]
×
102
            mbeds.mock_manufacture_id(mid, "dummy", oper=oper)
×
103
        else:
104
            logger.error("Could not parse mock from token: '%s'", token)
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc