@@ -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 )
0 commit comments