mirror of
https://github.com/nmap/nmap.git
synced 2025-12-06 04:31:29 +00:00
Fix Python2-isms in uninstallers. Closes #2580
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#Nmap Changelog ($Id$); -*-text-*-
|
||||
|
||||
o Additional Python 3 update fixes by Sam James, Daniel Miller.
|
||||
|
||||
o [GH#1807][GH#1176][Ndiff] Updated Ndiff to Python 3. [Brian Quigley]
|
||||
|
||||
o [GH#2088][GH#1176][Zenmap] Updated Zenmap to Python 3 and PyGObject. [Jakub Kulík]
|
||||
|
||||
@@ -155,13 +155,13 @@ Installing your distribution's python-dev package may solve this problem.""")
|
||||
#!/usr/bin/env python
|
||||
import errno, os, os.path, sys
|
||||
|
||||
print 'Uninstall %(name)s'
|
||||
print('Uninstall %(name)s')
|
||||
|
||||
answer = raw_input('Are you sure that you want to uninstall '
|
||||
'%(name)s (yes/no) ')
|
||||
|
||||
if answer != 'yes' and answer != 'y':
|
||||
print 'Not uninstalling.'
|
||||
print('Not uninstalling.')
|
||||
sys.exit(0)
|
||||
|
||||
""" % {'name': APP_NAME}
|
||||
@@ -177,8 +177,8 @@ if answer != 'yes' and answer != 'y':
|
||||
# This should never happen (everything gets installed
|
||||
# inside the root), but if it does, be safe and don't
|
||||
# delete anything.
|
||||
uninstaller += ("print '%s was not installed inside "
|
||||
"the root %s; skipping.'\n" % (output, self.root))
|
||||
uninstaller += ("print('%s was not installed inside "
|
||||
"the root %s; skipping.')\n" % (output, self.root))
|
||||
continue
|
||||
output = path_strip_prefix(output, self.root)
|
||||
assert os.path.isabs(output)
|
||||
@@ -202,24 +202,24 @@ for path in INSTALLED_FILES:
|
||||
dirs.append(path)
|
||||
# Delete the files.
|
||||
for file in files:
|
||||
print "Removing '%s'." % file
|
||||
print("Removing '%s'." % file)
|
||||
try:
|
||||
os.remove(file)
|
||||
except OSError, e:
|
||||
print >> sys.stderr, ' Error: %s.' % str(e)
|
||||
print(' Error: %s.' % str(e), file=sys.stderr)
|
||||
# Delete the directories. First reverse-sort the normalized paths by
|
||||
# length so that child directories are deleted before their parents.
|
||||
dirs = [os.path.normpath(dir) for dir in dirs]
|
||||
dirs.sort(key = len, reverse = True)
|
||||
for dir in dirs:
|
||||
try:
|
||||
print "Removing the directory '%s'." % dir
|
||||
print("Removing the directory '%s'." % dir)
|
||||
os.rmdir(dir)
|
||||
except OSError, e:
|
||||
if e.errno == errno.ENOTEMPTY:
|
||||
print "Directory '%s' not empty; not removing." % dir
|
||||
print("Directory '%s' not empty; not removing." % dir)
|
||||
else:
|
||||
print >> sys.stderr, str(e)
|
||||
print(str(e), file=sys.stderr)
|
||||
"""
|
||||
|
||||
uninstaller_file = open(uninstaller_filename, 'w')
|
||||
|
||||
@@ -215,13 +215,13 @@ class my_install(install):
|
||||
#!/usr/bin/env python3
|
||||
import errno, os, os.path, sys
|
||||
|
||||
print 'Uninstall %(name)s %(version)s'
|
||||
print('Uninstall %(name)s %(version)s')
|
||||
|
||||
answer = raw_input('Are you sure that you want to uninstall '
|
||||
'%(name)s %(version)s? (yes/no) ')
|
||||
|
||||
if answer != 'yes' and answer != 'y':
|
||||
print 'Not uninstalling.'
|
||||
print('Not uninstalling.')
|
||||
sys.exit(0)
|
||||
|
||||
""" % {'name': APP_DISPLAY_NAME, 'version': VERSION}
|
||||
@@ -237,8 +237,8 @@ if answer != 'yes' and answer != 'y':
|
||||
# This should never happen (everything gets installed
|
||||
# inside the root), but if it does, be safe and don't
|
||||
# delete anything.
|
||||
uninstaller += ("print '%s was not installed inside "
|
||||
"the root %s; skipping.'\n" % (output, self.root))
|
||||
uninstaller += ("print('%s was not installed inside "
|
||||
"the root %s; skipping.')\n" % (output, self.root))
|
||||
continue
|
||||
output = path_strip_prefix(output, self.root)
|
||||
assert os.path.isabs(output)
|
||||
@@ -262,24 +262,24 @@ for path in INSTALLED_FILES:
|
||||
dirs.append(path)
|
||||
# Delete the files.
|
||||
for file in files:
|
||||
print "Removing '%s'." % file
|
||||
print("Removing '%s'." % file)
|
||||
try:
|
||||
os.remove(file)
|
||||
except OSError as e:
|
||||
print >> sys.stderr, ' Error: %s.' % str(e)
|
||||
print(' Error: %s.' % str(e), file=sys.stderr)
|
||||
# Delete the directories. First reverse-sort the normalized paths by
|
||||
# length so that child directories are deleted before their parents.
|
||||
dirs = [os.path.normpath(dir) for dir in dirs]
|
||||
dirs.sort(key = len, reverse = True)
|
||||
for dir in dirs:
|
||||
try:
|
||||
print "Removing the directory '%s'." % dir
|
||||
print("Removing the directory '%s'." % dir)
|
||||
os.rmdir(dir)
|
||||
except OSError as e:
|
||||
if e.errno == errno.ENOTEMPTY:
|
||||
print "Directory '%s' not empty; not removing." % dir
|
||||
print("Directory '%s' not empty; not removing." % dir)
|
||||
else:
|
||||
print >> sys.stderr, str(e)
|
||||
print(str(e), file=sys.stderr)
|
||||
"""
|
||||
|
||||
uninstaller_file = open(uninstaller_filename, 'w')
|
||||
@@ -419,7 +419,7 @@ for dir in dirs:
|
||||
with open(INSTALLED_FILES_NAME, "w") as f:
|
||||
for output in self.get_installed_files():
|
||||
assert "\n" not in output
|
||||
print >> f, output
|
||||
print(output, file=f)
|
||||
|
||||
|
||||
class my_uninstall(Command):
|
||||
|
||||
Reference in New Issue
Block a user