Skip to content

Commit b1e0e7d

Browse files
author
David Noble
committed
examples\searchcommands_app\setup.py fixes for Windows
Also improved a message in testlib.py
1 parent 08fb4bb commit b1e0e7d

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

examples/searchcommands_app/setup.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ def patch_os():
2222

2323
def islink(path):
2424
attributes = get_file_attributes(path)
25-
if attributes == -1:
26-
raise OSError(format_error())
27-
return (attributes & 0x400) != 0 # 0x400 == FILE_ATTRIBUTE_REPARSE_POINT
25+
return attributes != -1 and (attributes & 0x400) != 0 # 0x400 == FILE_ATTRIBUTE_REPARSE_POINT
2826

2927
os.path.islink = islink
3028

@@ -207,17 +205,13 @@ def run(self):
207205
commands_conf = os.path.join(self.build_dir, 'default', 'commands.conf')
208206
source = os.path.join(self.build_dir, 'default', 'commands-scpv{}.conf'.format(self.scp_version))
209207

210-
if os.path.exists(commands_conf) and os.path.islink(commands_conf):
208+
if os.path.isfile(commands_conf) or os.path.islink(commands_conf):
211209
os.remove(commands_conf)
212-
else:
213-
try:
214-
os.path.islink(commands_conf)
215-
except OSError:
216-
pass
217-
else:
218-
os.remove(commands_conf)
210+
elif os.path.exists(commands_conf):
211+
message = 'Cannot create a link at "{}" because a file by that name already exists.'.format(commands_conf)
212+
raise SystemError(message)
219213

220-
os.symlink(source, commands_conf)
214+
shutil.copy(source, commands_conf)
221215
self._make_archive()
222216
return
223217

@@ -339,8 +333,11 @@ def run(self):
339333
commands_conf = os.path.join(self.app_source, 'default', 'commands.conf')
340334
source = os.path.join(self.app_source, 'default', 'commands-scpv{}.conf'.format(self.scp_version))
341335

342-
if os.path.exists(commands_conf) or os.path.islink(commands_conf):
336+
if os.path.islink(commands_conf):
343337
os.remove(commands_conf)
338+
elif os.path.exists(commands_conf):
339+
message = 'Cannot create a link at "{}" because a file by that name already exists.'.format(commands_conf)
340+
raise SystemError(message)
344341

345342
os.symlink(source, commands_conf)
346343
os.symlink(self.app_source, target)

tests/testlib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -257,8 +257,8 @@ def tearDown(self):
257257
self.service.apps.delete(appName)
258258
wait(lambda: appName not in self.service.apps)
259259
except HTTPError as error:
260-
if error.status != 500:
260+
if not (os.name == 'nt' and error.status == 500):
261261
raise
262-
print 'Ignoring teardown error because it is likely spurious: {}'.format(error)
262+
print 'Ignoring failure to delete {} during tear down: {}'.format(appName, error)
263263
if self.service.restart_required:
264264
self.clear_restart_message()

0 commit comments

Comments
 (0)