Skip to content

Commit f6434dd

Browse files
committed
Fixes based on feedback in the PR - #119
1 parent 1b80d56 commit f6434dd

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

mbed/mbed.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def isdetached():
506506
return Git.getbranch() == "HEAD"
507507

508508
# Finds default remote
509-
def getremote(rtype='fetch'):
509+
def getremote():
510510
remote = None
511511
remotes = Git.getremotes('push')
512512
for r in remotes:
@@ -825,7 +825,7 @@ class Program(object):
825825
is_cwd = False
826826
is_repo = False
827827

828-
def __init__(self, path=None, warnings=False):
828+
def __init__(self, path=None, print_warning=False):
829829
path = os.path.abspath(path or os.getcwd())
830830

831831
self.path = os.getcwd()
@@ -843,11 +843,12 @@ def __init__(self, path=None, warnings=False):
843843

844844
self.name = os.path.basename(self.path)
845845

846-
if warnings:
847-
if self.is_cwd:
848-
warning(
849-
"Could not mbed program in current path. Assuming current dir.\n"
850-
"You can fix this by calling \"mbed new .\" in the root dir of your program")
846+
# is_cwd flag indicates that current dir is assumed to be root, not root repo
847+
if self.is_cwd:
848+
err = (
849+
"Could not find mbed program in current path. Assuming current dir.\n"
850+
"You can fix this by calling \"mbed new .\" in the root dir of your program")
851+
return warning(err) if print_warning else error(err)
851852

852853
# Sets config value
853854
def set_cfg(self, var, val):
@@ -1381,7 +1382,7 @@ def compile(toolchain=None, mcu=None, source=False, build=False, compile_library
13811382
# Gather remaining arguments
13821383
args = remainder
13831384
# Find the root of the program
1384-
program = Program(os.getcwd(), True)
1385+
program = Program(os.getcwd(), False)
13851386
# Remember the original path. this is needed for compiling only the libraries and tests for the current folder.
13861387
orig_path = os.getcwd()
13871388

@@ -1410,6 +1411,7 @@ def compile(toolchain=None, mcu=None, source=False, build=False, compile_library
14101411

14111412
if not source or len(source) == 0:
14121413
source = [os.path.relpath(root_path, orig_path)]
1414+
14131415
if compile_tests:
14141416
# Compile tests
14151417
if not build:
@@ -1459,7 +1461,7 @@ def test(tlist=False):
14591461
# Gather remaining arguments
14601462
args = remainder
14611463
# Find the root of the program
1462-
program = Program(os.getcwd(), True)
1464+
program = Program(os.getcwd(), False)
14631465
# Change directories to the program root to use mbed OS tools
14641466
with cd(program.path):
14651467
if not program.get_tools_dir():
@@ -1485,7 +1487,7 @@ def export(ide=None, mcu=None):
14851487
# Gather remaining arguments
14861488
args = remainder
14871489
# Find the root of the program
1488-
program = Program(os.getcwd(), True)
1490+
program = Program(os.getcwd(), False)
14891491
# Change directories to the program root to use mbed OS tools
14901492
with cd(program.path):
14911493
if not program.get_tools_dir():
@@ -1515,7 +1517,7 @@ def export(ide=None, mcu=None):
15151517
help='Set default target for the current program.')
15161518
def target_(name=None):
15171519
# Find the root of the program
1518-
program = Program(os.getcwd(), True)
1520+
program = Program(os.getcwd(), False)
15191521
# Change directories to the program root to use mbed OS tools
15201522
with cd(program.path):
15211523
if name is None:
@@ -1530,7 +1532,7 @@ def target_(name=None):
15301532
help='Sets default toolchain for the current program.')
15311533
def toolchain_(name=None):
15321534
# Find the root of the program
1533-
program = Program(os.getcwd(), True)
1535+
program = Program(os.getcwd(), False)
15341536
# Change directories to the program root to use mbed OS tools
15351537
with cd(program.path):
15361538
if name is None:

0 commit comments

Comments
 (0)