@@ -104,7 +104,12 @@ def upgrade_single_example(example, tag, directory, ref):
104
104
return_code = False
105
105
106
106
if os .path .isfile ("mbed-os.lib" ):
107
- os .system ("mv mbed-os.lib mbed-os.lib_bak" )
107
+ # Rename command will fail on some OS's if the target file already exist,
108
+ # so ensure if it does, it is deleted first.
109
+ if os .path .isfile ("mbed-os.lib_bak" ):
110
+ os .remove ("mbed-os.lib_bak" )
111
+
112
+ os .rename ("mbed-os.lib" , "mbed-os.lib_bak" )
108
113
else :
109
114
print ("!! Error trying to backup mbed-os.lib prior to updating." )
110
115
return False
@@ -144,32 +149,17 @@ def prepare_fork(arm_example):
144
149
145
150
"""
146
151
147
- ret = False
148
-
149
152
print "In " + os .getcwd ()
150
153
151
- cmd = ['git' , 'remote' , 'add' , 'armmbed' , arm_example ]
152
- return_code = run_cmd (cmd )
153
-
154
- if not return_code :
155
-
156
- cmd = ['git' , 'fetch' , 'armmbed' ]
157
- return_code = run_cmd (cmd )
158
- if not return_code :
159
-
160
- cmd = ['git' , 'reset' , '--hard' , 'armmbed/master' ]
161
- return_code = run_cmd (cmd )
162
- if not return_code :
163
-
164
- cmd = ['git' , 'push' , '-f' , 'origin' ]
165
- return_code = run_cmd (cmd )
166
- if not return_code :
167
- ret = True
168
-
169
- if not ret :
170
- print ("Preparation of the fork failed!" )
154
+ for cmd in [['git' , 'remote' , 'add' , 'armmbed' , arm_example ],
155
+ ['git' , 'fetch' , 'armmbed' ],
156
+ ['git' , 'reset' , '--hard' , 'armmbed/master' ],
157
+ ['git' , 'push' , '-f' , 'origin' ]]:
158
+ if run_cmd (cmd ):
159
+ print ("preparation of the fork failed!" )
160
+ return False
161
+ return True
171
162
172
- return ret
173
163
174
164
def upgrade_example (github , example , tag , user , ref ):
175
165
""" Clone a fork of the example specified.
0 commit comments