Skip to content

Commit

Permalink
Fix Python2-isms in uninstallers. Closes #2580
Browse files Browse the repository at this point in the history
  • Loading branch information
bonsaiviking committed Dec 14, 2022
1 parent bc381ae commit 87778f7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -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]
Expand Down
18 changes: 9 additions & 9 deletions ndiff/setup.py
Expand Up @@ -155,13 +155,13 @@ def create_uninstaller(self):
#!/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}
Expand All @@ -177,8 +177,8 @@ def create_uninstaller(self):
# 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)
Expand All @@ -202,24 +202,24 @@ def create_uninstaller(self):
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')
Expand Down
20 changes: 10 additions & 10 deletions zenmap/setup.py
Expand Up @@ -215,13 +215,13 @@ def create_uninstaller(self):
#!/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}
Expand All @@ -237,8 +237,8 @@ def create_uninstaller(self):
# 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)
Expand All @@ -262,24 +262,24 @@ def create_uninstaller(self):
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')
Expand Down Expand Up @@ -419,7 +419,7 @@ def write_installed_files(self):
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):
Expand Down

0 comments on commit 87778f7

Please sign in to comment.