Skip to content
This repository has been archived by the owner on Oct 26, 2023. It is now read-only.

Commit

Permalink
Merge pull request #156 from lathama/python3-lowpass
Browse files Browse the repository at this point in the history
Python3 lowpass changes, zero impact to Python 2.6+
  • Loading branch information
psychomario committed Jun 29, 2017
2 parents cf19bea + d22c094 commit 7dfe388
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
4 changes: 3 additions & 1 deletion pypxe/dhcp.py
Expand Up @@ -122,7 +122,9 @@ def __init__(self, **server_settings):
import_safe[packed_mac] = imported[lease]
self.leases.update(import_safe)
self.logger.info('Loaded leases from {0}'.format(self.save_leases_file))
except IOError, ValueError:
except IOError:
pass
except ValueError:
pass

signal.signal(signal.SIGINT, self.export_leases)
Expand Down
9 changes: 5 additions & 4 deletions pypxe/server.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
import threading
import io
import os
import sys
import json
Expand Down Expand Up @@ -141,12 +142,12 @@ def main():
del settings['DUMP_CONFIG']
del settings['DUMP_CONFIG_MERGED']
del settings['JSON_CONFIG']
print json.dumps(settings, sort_keys=True, indent=4)
print(json.dumps(settings, sort_keys=True, indent=4))
sys.exit()

if args.JSON_CONFIG: # load from configuration file if specified
try:
config_file = open(args.JSON_CONFIG, 'rb')
config_file = io.open(args.JSON_CONFIG, 'r')
except IOError:
sys.exit('Failed to open {0}'.format(args.JSON_CONFIG))
try:
Expand All @@ -162,14 +163,14 @@ def main():

# warn the user that they are starting PyPXE as non-root user
if os.getuid() != 0:
print >> sys.stderr, '\nWARNING: Not root. Servers will probably fail to bind.\n'
print(sys.stderr, '\nWARNING: Not root. Servers will probably fail to bind.\n')


# ideally this would be in dhcp itself, but the chroot below *probably*
# breaks the ability to open the config file.
if args.STATIC_CONFIG:
try:
static_config = open(args.STATIC_CONFIG, 'rb')
static_config = io.open(args.STATIC_CONFIG, 'r')
except IOError:
sys.exit("Failed to open {0}".format(args.STATIC_CONFIG))
try:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -9,7 +9,7 @@

# Python 3 unsupported
if version_info >= (3,):
print "Sorry, PyPXE doesn't support Python 3."
print("Sorry, PyPXE doesn't support Python 3.")
exit(1)

# require argparse on Python <2.7
Expand Down

0 comments on commit 7dfe388

Please sign in to comment.