diff options
Diffstat (limited to 'standardskriver')
-rwxr-xr-x | standardskriver | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/standardskriver b/standardskriver index d56f882..bf61898 100755 --- a/standardskriver +++ b/standardskriver @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python3 # Copyright (C) 2013, Linnea Skogtvedt <linnea@linuxavdelingen.no> # Copyright (C) 2015-2017, Mike Gabriel <mike.gabriel@das-netzwerkteam.de> @@ -61,7 +61,7 @@ import re from socket import gethostname, getfqdn import netaddr from optparse import OptionParser -import ConfigParser +import configparser # if configured, check on what site location we are currently running... site_id = None @@ -80,12 +80,12 @@ parser.add_option('-n', '--dryrun', action='store_true', help='only show what wo options, args = parser.parse_args() if not os.path.exists(CFG_FILE): - print >>sys.stderr, 'Configuration file %s is missing.' % CFG_FILE - print >>sys.stderr, 'To create it, redirect the following example to %s and edit the file.' % CFG_FILE - print CFG_FILE_EXAMPLE + print('Configuration file %s is missing.' % CFG_FILE, file=sys.stderr) + print('To create it, redirect the following example to %s and edit the file.' % CFG_FILE, file=sys.stderr) + print(CFG_FILE_EXAMPLE) sys.exit(1) -cfg = ConfigParser.RawConfigParser() +cfg = configparser.RawConfigParser() # hack: mac addrs contain :, which clashes with cfg syntax cfg.OPTCRE = re.compile( r'(?P<option>[^=\s][^=]*)' # very permissive! @@ -102,7 +102,7 @@ if cfg.get('settings', 'enable') != "yes": for x in cfg.get('settings', 'order').split(): if not x in ('machine', 'groups'): - print 'invalid value {val} in settings/order'.format(val=x) + print('invalid value {val} in settings/order'.format(val=x)) sys.exit(1) hostnames = [] @@ -135,7 +135,7 @@ def get_group_match(): try: for group, printer in cfg.items(section): if group.strip('@') in groups: return printer - except ConfigParser.NoSectionError: + except configparser.NoSectionError: pass return None @@ -155,7 +155,7 @@ def get_machine_match(): myaddrs = netaddr.IPSet(ipaddrs) if machines & myaddrs: return printer - except ConfigParser.NoSectionError: + except configparser.NoSectionError: pass return None @@ -171,7 +171,7 @@ except IndexError: # no match if cfg.getboolean('settings', 'delete lpoptions'): lpoptions_filename = os.path.expanduser('~/.cups/lpoptions') if options.dryrun: - print 'would delete %s' % lpoptions_filename + print('would delete %s' % lpoptions_filename) else: try: os.unlink(lpoptions_filename) @@ -181,6 +181,6 @@ except IndexError: # no match args = ['lpoptions', '-d', printer] if options.dryrun: - print 'would call %s' % (' '.join(args)) + print('would call %s' % (' '.join(args))) else: subprocess.call(args) |