Review comments: Use os.rename rather that system mv command. In prepare_fork(), change nested IF to neat command loop.

pull/3585/head
Anna Bridge 2017-01-09 17:56:20 +00:00
parent 2cf96c847e
commit d0bb026aff
1 changed files with 14 additions and 24 deletions

View File

@ -104,7 +104,12 @@ def upgrade_single_example(example, tag, directory, ref):
return_code = False return_code = False
if os.path.isfile("mbed-os.lib"): if os.path.isfile("mbed-os.lib"):
os.system("mv mbed-os.lib mbed-os.lib_bak") # Rename command will fail on some OS's if the target file already exist,
# so ensure if it does, it is deleted first.
if os.path.isfile("mbed-os.lib_bak"):
os.remove("mbed-os.lib_bak")
os.rename("mbed-os.lib", "mbed-os.lib_bak")
else: else:
print("!! Error trying to backup mbed-os.lib prior to updating.") print("!! Error trying to backup mbed-os.lib prior to updating.")
return False return False
@ -144,32 +149,17 @@ def prepare_fork(arm_example):
""" """
ret = False
print "In " + os.getcwd() print "In " + os.getcwd()
cmd = ['git', 'remote', 'add', 'armmbed', arm_example] for cmd in [['git', 'remote', 'add', 'armmbed', arm_example],
return_code = run_cmd(cmd) ['git', 'fetch', 'armmbed'],
['git', 'reset', '--hard', 'armmbed/master'],
if not return_code: ['git', 'push', '-f', 'origin']]:
if run_cmd(cmd):
cmd = ['git', 'fetch', 'armmbed'] print("preparation of the fork failed!")
return_code = run_cmd(cmd) return False
if not return_code: return True
cmd = ['git', 'reset', '--hard', 'armmbed/master']
return_code = run_cmd(cmd)
if not return_code:
cmd = ['git', 'push', '-f', 'origin']
return_code = run_cmd(cmd)
if not return_code:
ret = True
if not ret:
print("Preparation of the fork failed!")
return ret
def upgrade_example(github, example, tag, user, ref): def upgrade_example(github, example, tag, user, ref):
""" Clone a fork of the example specified. """ Clone a fork of the example specified.