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