diff options
author | Didier Raboud <odyx@debian.org> | 2016-01-04 16:43:51 +0100 |
---|---|---|
committer | Didier Raboud <odyx@debian.org> | 2016-01-04 16:43:51 +0100 |
commit | d2347c83fe9fb2053998235b0e81e93dbc888598 (patch) | |
tree | b0d64153826ed4bccdf888471261464cc0b65483 /makeuri.py | |
parent | adcfeaed777a5a8ac231413ec9130705bb042e0a (diff) |
Imported Upstream version 2.7.10
Diffstat (limited to 'makeuri.py')
-rwxr-xr-x | makeuri.py | 55 |
1 files changed, 18 insertions, 37 deletions
diff --git a/makeuri.py b/makeuri.py index 043f9ab19..6015e387b 100755 --- a/makeuri.py +++ b/makeuri.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # -# (c) Copyright 2003-2006 Hewlett-Packard Development Company, L.P. +# (c) Copyright 2003-2007 Hewlett-Packard Development Company, L.P. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -30,7 +30,6 @@ import re import getopt import socket - # Local from base.g import * from base.codes import * @@ -72,12 +71,12 @@ USAGE = [ (__doc__, "", "name", True), def usage(typ='text'): if typ == 'text': utils.log_title(__title__, __version__) - + utils.format_text(USAGE, typ, __title__, 'hp-makeuri', __version__) sys.exit(0) - - + + log.set_module('hp-makeuri') try: @@ -91,7 +90,8 @@ try: 'port=', ] ) -except getopt.GetoptError: +except getopt.GetoptError, e: + log.error(e.msg) usage() sys.exit(1) @@ -108,13 +108,13 @@ for o, a in opts: if o in ('-h', '--help'): usage() - + elif o == '--help-rest': usage('rest') - + elif o == '--help-man': usage('man') - + elif o == '--help-desc': print __doc__, sys.exit(0) @@ -123,13 +123,13 @@ for o, a in opts: log_level = a.lower().strip() if not log.set_level(log_level): usage() - + elif o in ('-c', '--cups'): cups_quiet_mode = True - + elif o in ('-s', '--sane'): sane_quiet_mode = True - + elif o in ('-f', '--fax'): fax_quiet_mode = True @@ -139,45 +139,29 @@ for o, a in opts: except ValueError: log.error("Invalid port number. Must be between 1 and 3 inclusive.") usage() - + elif o == '-g': log.set_level('debug') - + quiet_mode = cups_quiet_mode or sane_quiet_mode or fax_quiet_mode if quiet_mode: log.set_level('warn') - + utils.log_title(__title__, __version__) if len(args) != 1: log.error("You must specify one SERIAL NO., IP, USB ID or DEVNODE on the command line.") usage() - + param = args[0] if 'localhost' in param.lower(): log.error("Invalid hostname") usage() -hpiod_sock = None -try: - hpiod_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - hpiod_sock.connect((prop.hpiod_host, prop.hpiod_port)) -except socket.error: - log.error("Unable to connect to hpiod.") - sys.exit(1) - -hpssd_sock = None -try: - hpssd_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - hpssd_sock.connect((prop.hpssd_host, prop.hpssd_port)) -except socket.error: - log.error("Unable to connect to hpssd.") - sys.exit(1) - -cups_uri, sane_uri, fax_uri = device.makeuri(hpiod_sock, hpssd_sock, param, jd_port) +cups_uri, sane_uri, fax_uri = device.makeURI(param, jd_port) if not cups_uri: log.error("Device not found") @@ -195,7 +179,7 @@ if sane_uri: print "SANE URI:", sane_uri elif not sane_uri and sane_quiet_mode: log.error("Device does not support scan.") - + if fax_uri: if fax_quiet_mode: print fax_uri @@ -204,7 +188,4 @@ if fax_uri: elif not fax_uri and fax_quiet_mode: log.error("Device does not support fax.") -hpiod_sock.close() -hpssd_sock.close() - sys.exit(0) |