Commit 361b32cb authored by Didier 'OdyX' Raboud's avatar Didier 'OdyX' Raboud

Imported Upstream version 3.15.2

parent f1226f71

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.

......@@ -153,9 +153,13 @@ basedir = $(hplipdir)/base
dist_base_DATA = base/maint.py base/codes.py base/g.py base/pml.py base/status.py \
base/__init__.py base/mfpdtf.py base/utils.py base/wifi.py base/LedmWifi.py \
base/device.py base/logger.py base/slp.py base/exif.py base/strings.py base/magic.py \
base/imagesize.py base/pexpect.py base/models.py base/mdns.py base/tui.py base/dime.py \
base/ldif.py base/vcard.py base/module.py base/pkit.py base/queues.py base/password.py \
base/services.py base/os_utils.py base/smart_install.py base/avahi.py base/validation.py
base/imagesize.py base/models.py base/validation.py base/sixext.py base/avahi.py \
base/mdns.py base/tui.py base/dime.py base/ldif.py base/vcard.py base/module.py \
base/pkit.py base/queues.py base/password.py base/services.py base/os_utils.py \
base/smart_install.py base/six.py
basepexpectdir = $(hplipdir)/base/pexpect
dist_basepexpect_DATA=base/pexpect/__init__.py
# installer
installdir = $(hplipdir)/installer
......@@ -248,7 +252,7 @@ dist_prnt_DATA = prnt/cups.py prnt/__init__.py prnt/ldl.py prnt/pcl.py prnt/colo
cupsextdir = $(pyexecdir)
cupsext_LTLIBRARIES = cupsext.la
cupsext_la_LDFLAGS = -module -avoid-version
cupsext_la_SOURCES = prnt/cupsext/cupsext.c
cupsext_la_SOURCES = prnt/cupsext/cupsext.c prnt/cupsext/cupsext.h
cupsext_la_CFLAGS = -I$(PYTHONINCLUDEDIR)
cupsext_la_LIBADD = -lcups
......
This diff is collapsed.
......@@ -31,7 +31,7 @@ import re
import getopt
import operator
import os
#from __future__ import absolute_import
# Local
from base.g import *
from base import device, status, utils, maint, tui, module
......@@ -100,7 +100,7 @@ def aioUI1():
def type10and11and14Align(pattern, align_type):
controls = maint.align10and11and14Controls(pattern, align_type)
values = []
s_controls = controls.keys()
s_controls = list(controls.keys())
s_controls.sort()
for line in s_controls:
......@@ -142,6 +142,9 @@ try:
device_uri = mod.getDeviceUri(device_uri, printer_name,
filter={'align-type': (operator.ne, ALIGN_TYPE_NONE)})
if not device_uri:
sys.exit(1)
if mode == GUI_MODE:
if not utils.canEnterGUIMode4():
log.error("%s -u/--gui requires Qt4 GUI support. Entering interactive mode." % __mod__)
......@@ -150,7 +153,7 @@ try:
if mode == INTERACTIVE_MODE:
try:
d = device.Device(device_uri, printer_name)
except Error, e:
except Error as e:
log.error("Unable to open device: %s" % e.msg)
sys.exit(0)
......@@ -236,7 +239,6 @@ try:
#try:
if 1:
app = QApplication(sys.argv)
dlg = AlignDialog(None, device_uri)
dlg.show()
try:
......
This diff is collapsed.
......@@ -20,13 +20,12 @@
#
import sys
from g import *
from .g import *
import socket
from subprocess import Popen, PIPE
from base import utils
from . import utils
from .sixext import to_string_utf8
def is_ipv6(a):
return ':' in a
def detectNetworkDevices(ttl=4, timeout=10):
found_devices = {}
......@@ -35,40 +34,35 @@ def detectNetworkDevices(ttl=4, timeout=10):
log.error("Avahi-browse is not installed")
return found_devices
addr4 = []
addr6 = []
# Obtain all the resolved services which has service type '_printer._tcp' from avahi-browse
p = Popen(['avahi-browse', '-kprt', '_printer._tcp'], stdout=PIPE)
for line in p.stdout:
output = to_string_utf8(p.communicate()[0])
for line in output.splitlines():
if line.startswith('='):
bits = line.split(';')
if is_ipv6(bits[7]) and bits[2] == 'IPv6':
addr6.append([bits[7], bits[8]])
# We don't support IPv6 yet
continue
elif bits[2] == 'IPv4':
addr4.append([bits[7], bits[8]])
ip = bits[7]
port = bits[8]
# Run through the offered addresses and see if we have a bound local
# address for it.
try:
res = socket.getaddrinfo(ip, port, 0, 0, 0, socket.AI_ADDRCONFIG)
if res:
y = {'num_devices' : 1, 'num_ports': 1, 'product_id' : '', 'mac': '',
'status_code': 0, 'device2': '0', 'device3': '0', 'note': ''}
y['ip'] = ip
y['hn'] = bits[6].replace('.local', '')
details = bits[9].split('" "')
for item in details:
key, value = item.split('=', 1)
if key == 'ty':
y['mdns'] = value
y['device1'] = "MFG:Hewlett-Packard;MDL:%s;CLS:PRINTER;" % value
found_devices[y['ip']] = y
log.debug("ip=%s hn=%s ty=%s" %(ip,y['hn'], y['mdns']))
except socket.gaierror:
pass
if bits[2] == 'IPv4' and len(bits[7].split('.')) == 4:
ip = bits[7]
port = bits[8]
# Run through the offered addresses and see if we have a bound local
# address for it.
try:
res = socket.getaddrinfo(ip, port, 0, 0, 0, socket.AI_ADDRCONFIG)
if res:
y = {'num_devices' : 1, 'num_ports': 1, 'product_id' : '', 'mac': '',
'status_code': 0, 'device2': '0', 'device3': '0', 'note': ''}
y['ip'] = ip
y['hn'] = bits[6].replace('.local', '')
details = bits[9].split('" "')
for item in details:
key, value = item.split('=', 1)
if key == 'ty':
y['mdns'] = value
y['device1'] = "MFG:Hewlett-Packard;MDL:%s;CLS:PRINTER;" % value
break
found_devices[y['ip']] = y
log.debug("ip=%s hn=%s ty=%s" %(ip,y['hn'], y['mdns']))
except socket.gaierror:
pass
log.debug("Found %d devices" % len(found_devices))
return found_devices
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2003-2009 Hewlett-Packard Development Company, L.P.
......@@ -84,6 +85,9 @@ ERROR_INCORRECT_PASSWORD = 109
ERROR_UNKNOWN_VALIDATION_ERROR = 110
ERROR_NO_SI_DEVICE = 111
ERROR_FAILED_TO_DISABLE_SI = 112
# If you add new codes, also add the appropriate description
# to g.py for exception description strings.
# Thank you, The Management
......
This diff is collapsed.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# (c) Copyright 2003-2008 Hewlett-Packard Development Company, L.P.
......@@ -23,7 +24,7 @@
import struct
# Local
from g import *
from .g import *
# DIME constants
TYPE_T_MIME = 0x01
......@@ -86,21 +87,21 @@ class Message(object):
if data_len % block_size == 0:
return data_len
else:
return (data_len/block_size+1)*block_size
return (int(data_len/block_size+1))*block_size
if __name__ == "__main__":
log.set_level("debug")
import cStringIO
import io
m = Message()
m.add_record(Record("cid:id0", "http://schemas.xmlsoap.org/soap/envelope/",
TYPE_T_URI, "<test>test</test>"))
m.add_record(Record("test2", "text/xml", TYPE_T_MIME, "<test>test2</test>"))
output = cStringIO.StringIO()
output = io.StringIO()
m.generate(output)
......
import collections
# Library to extract EXIF information in digital camera image files
#
# Contains code from "exifdump.py" originally written by Thierry Bousch
......@@ -639,7 +640,7 @@ def s2n_motorola(str):
# extract multibyte integer in Intel format (big endian)
def s2n_intel(str):
x=0
y=0L
y=to_long(0)
for c in str:
x=x | (ord(c) << y)
y=y+8
......@@ -759,8 +760,7 @@ class EXIF_header:
field_type=self.s2n(entry+2, 2)
if not 0 < field_type < len(FIELD_TYPES):
# unknown field type
raise ValueError, \
'unknown type %d in tag 0x%04X' % (field_type, tag)
raise ValueError('unknown type %d in tag 0x%04X' % (field_type, tag))
typelen=FIELD_TYPES[field_type][0]
count=self.s2n(entry+4, 4)
offset=entry+8
......@@ -798,7 +798,7 @@ class EXIF_header:
tag_name=tag_entry[0]
if len(tag_entry) != 1:
# optional 2nd tag element is present
if callable(tag_entry[1]):
if isinstance(tag_entry[1], collections.Callable):
# call mapping function
printable=tag_entry[1](values)
else:
......@@ -813,8 +813,8 @@ class EXIF_header:
values, field_offset,
count*typelen)
if self.debug:
print ' %s: %s' % (tag_name,
repr(self.tags[ifd_name+' '+tag_name]))
print(' %s: %s' % (tag_name,
repr(self.tags[ifd_name+' '+tag_name])))