Commit 2d2e1dd5 authored by Didier 'OdyX' Raboud's avatar Didier 'OdyX' Raboud

Imported Upstream version 0.9.6

parent b901b910
This diff is collapsed.
......@@ -4,10 +4,11 @@
# (c) 2004-2005 Copyright Hewlett-Packard Development Company, LP
#
SUBDIRS = prnt/hpijs
SUBDIRS = . prnt/hpijs
INCLUDES = -Iprnt/hpijs -Iip
hplipdir = $(datadir)/hplip
rundir = /var/run
docdir = $(datadir)/doc/$(distdir)
doc_DATA = hplip_readme.html hplip_overview.png COPYING
......@@ -32,11 +33,11 @@ hpiod_SOURCES = io/hpiod/hpiod.cpp io/hpiod/channel.cpp io/hpiod/device.cpp io/h
# base
basedir = $(hplipdir)/base
dist_base_SCRIPTS = base/maint.py base/codes.py base/g.py base/mfpdtf2.py base/pml.py base/status.py base/async.py \
dist_base_SCRIPTS = base/maint.py base/codes.py base/g.py base/mfpdtf2.py base/pml.py base/status.py \
base/__init__.py base/mfpdtf.py base/utils.py base/async_qt.py base/kirbybase.py base/service.py \
base/device.py base/logger.py base/msg.py base/slp.py base/exif.py base/strings.py base/magic.py \
base/imagesize.py base/subproc.py
# fax
faxdir = $(hplipdir)/fax
dist_fax_SCRIPTS = fax/fax.py fax/__init__.py
......@@ -54,7 +55,8 @@ ldldir = $(hplipdir)/data/ldl
psdir = $(hplipdir)/data/ps
icondir = $(hplipdir)/data
dist_ps_DATA = data/ps/testpage.ps.gz data/ps/clean_page.pdf.gz
dist_xml_DATA = data/xml/models.xml
#dist_xml_DATA = data/xml/models.xml
dist_xml_DATA = data/xml/*.xml
dist_images_DATA = data/images/*
dist_pcl_DATA = data/pcl/align1_8xx.pcl.gz data/pcl/align1_9xx.pcl.gz data/pcl/align2_8xx.pcl.gz data/pcl/align3_8xx.pcl.gz data/pcl/align4_8xx.pcl.gz \
data/pcl/align5_8xx.pcl.gz data/pcl/align2_9xx.pcl.gz data/pcl/align3_9xx.pcl.gz data/pcl/align4_450.pcl.gz data/pcl/align6_450.pcl.gz \
......@@ -123,19 +125,21 @@ dist_ui_SCRIPTS = ui/alignform.py \
ui/cleaningform2_base.py ui/cleaningform2.py ui/colorcalform2_base.py ui/colorcalform2.py ui/colorcal4form.py \
ui/colorcal4form_base.py ui/colorcal4form_base.ui ui/printerform.py ui/printerform_base.ui ui/printerform_base.py \
ui/faxaddrbookgroupsform_base.py ui/faxaddrbookgroupeditform_base.py ui/faxaddrbookform_base.py \
ui/faxaddrbookform.py ui/faxaddrbookeditform_base.py ui/align10form.py ui/align10form_base.py
ui/faxaddrbookform.py ui/faxaddrbookeditform_base.py ui/align10form.py ui/align10form_base.py \
ui/informationform_base.py ui/informationform.py ui/supportform_base.py ui/supportform.py
dist_noinst_DATA = ui/unloadform_base.ui ui/colorcalform2_base.ui ui/settingsdialog_base.ui ui/aligntype6form1_base.ui \
ui/aboutdlg_base.ui ui/imagepropertiesdlg_base.ui ui/paperedgealignform_base.ui ui/aligntype6form2_base.ui \
ui/nodevicesform_base.ui ui/cleaningform_base.ui ui/colorcalform_base.ui ui/devmgr4_base.ui ui/loadpaperform_base.ui \
ui/cleaningform2_base.ui ui/waitform_base.ui ui/coloradjform_base.ui ui/faxaddrbookeditform_base.ui \
ui/faxaddrbookform_base.ui ui/faxaddrbookgroupeditform_base.ui ui/faxaddrbookgroupsform_base.ui \
plugins/powersettingsdialog_base.ui ui/align10form_base.ui
ui/align10form_base.ui ui/informationform_base.ui ui/supportform_base.ui \
plugins/powersettingsdialog_base.ui
# ui plugins
pluginsdir = $(hplipdir)/plugins
dist_plugins_SCRIPTS = plugins/dj450.py plugins/__init__.py plugins/powersettings.py plugins/powersettingsdialog.py \
plugins/powersettingsdialog_base.py
plugins/powersettingsdialog_base.py plugins/Deskjet_460.py
build-pcardext:
cd pcard/pcardext; \
......@@ -181,8 +185,10 @@ install-data-hook: test-destdir
echo -e " longtitle=\"HPLIP Device Manager\" \\" >> $(srcdir)/$(ICON_FILE); \
echo -e " mimetypes=\"\" accept_url=\"false\" multiple_files=\"true\"" >> $(srcdir)/$(ICON_FILE); \
fi
$(INSTALL_DATA) $(srcdir)/$(ICON_FILE) $(DESTDIR)$(icondir); \
rm -f $(srcdir)/$(ICON_FILE)
if [ "$(ICON_FILE)" != "" ]; then \
$(INSTALL_DATA) $(srcdir)/$(ICON_FILE) $(DESTDIR)$(icondir); \
rm -f $(srcdir)/$(ICON_FILE); \
fi
#
# Do full install if not rpm_install.
if [ "$(rpm_install)" = "no" ]; then \
......@@ -218,7 +224,7 @@ install-data-hook: test-destdir
#
# Edit hpiod.conf in destdir.
echo -e "\n[$(PACKAGE)]\nversion=$(VERSION)\njdprobe=0\n" >> $(DESTDIR)$(hplipdir)/$(PACKAGE).conf
echo -e "[dirs]\nhome=$(hplipdir)\n" >> $(DESTDIR)$(hplipdir)/$(PACKAGE).conf
echo -e "[dirs]\nhome=$(hplipdir)\nrun=$(rundir)\n" >> $(DESTDIR)$(hplipdir)/$(PACKAGE).conf
#
# Edit hpiod.sh in destdir.
sed 's:HPIODDIR=:HPIODDIR=$(sbindir):' < $(DESTDIR)$(hplipdir)/$(PACKAGE).sh > $(DESTDIR)$(hplipdir)/$(PACKAGE).tmp; \
......@@ -250,9 +256,14 @@ test-destdir:
if [ ! -f $(DESTDIR)/etc/sane.d/dll.conf ]; then \
touch $(DESTDIR)/etc/sane.d/dll.conf; \
fi; \
$(mkinstalldirs) $(DESTDIR)/usr/lib/sane; \
$(mkinstalldirs) $(DESTDIR)$(sanedir); \
$(mkinstalldirs) $(DESTDIR)/usr/share/applications; \
fi
dist-hook:
if [ "$(SHADOW)" != "" ]; then \
cp -f data/xml/unreleased/*.xml $(distdir)/data/xml/; \
fi
.PHONY: build-pcardext build-cupsext test-destdir
......@@ -287,9 +287,10 @@ sharedstatedir = @sharedstatedir@
subdirs = @subdirs@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
SUBDIRS = prnt/hpijs
SUBDIRS = . prnt/hpijs
INCLUDES = -Iprnt/hpijs -Iip
hplipdir = $(datadir)/hplip
rundir = /var/run
docdir = $(datadir)/doc/$(distdir)
doc_DATA = hplip_readme.html hplip_overview.png COPYING
dist_hplip_DATA = $(doc_DATA) hplip.conf
......@@ -308,7 +309,7 @@ hpiod_SOURCES = io/hpiod/hpiod.cpp io/hpiod/channel.cpp io/hpiod/device.cpp io/h
# base
basedir = $(hplipdir)/base
dist_base_SCRIPTS = base/maint.py base/codes.py base/g.py base/mfpdtf2.py base/pml.py base/status.py base/async.py \
dist_base_SCRIPTS = base/maint.py base/codes.py base/g.py base/mfpdtf2.py base/pml.py base/status.py \
base/__init__.py base/mfpdtf.py base/utils.py base/async_qt.py base/kirbybase.py base/service.py \
base/device.py base/logger.py base/msg.py base/slp.py base/exif.py base/strings.py base/magic.py \
base/imagesize.py base/subproc.py
......@@ -328,7 +329,8 @@ ldldir = $(hplipdir)/data/ldl
psdir = $(hplipdir)/data/ps
icondir = $(hplipdir)/data
dist_ps_DATA = data/ps/testpage.ps.gz data/ps/clean_page.pdf.gz
dist_xml_DATA = data/xml/models.xml
#dist_xml_DATA = data/xml/models.xml
dist_xml_DATA = data/xml/*.xml
dist_images_DATA = data/images/*
dist_pcl_DATA = data/pcl/align1_8xx.pcl.gz data/pcl/align1_9xx.pcl.gz data/pcl/align2_8xx.pcl.gz data/pcl/align3_8xx.pcl.gz data/pcl/align4_8xx.pcl.gz \
data/pcl/align5_8xx.pcl.gz data/pcl/align2_9xx.pcl.gz data/pcl/align3_9xx.pcl.gz data/pcl/align4_450.pcl.gz data/pcl/align6_450.pcl.gz \
......@@ -402,20 +404,22 @@ dist_ui_SCRIPTS = ui/alignform.py \
ui/cleaningform2_base.py ui/cleaningform2.py ui/colorcalform2_base.py ui/colorcalform2.py ui/colorcal4form.py \
ui/colorcal4form_base.py ui/colorcal4form_base.ui ui/printerform.py ui/printerform_base.ui ui/printerform_base.py \
ui/faxaddrbookgroupsform_base.py ui/faxaddrbookgroupeditform_base.py ui/faxaddrbookform_base.py \
ui/faxaddrbookform.py ui/faxaddrbookeditform_base.py ui/align10form.py ui/align10form_base.py
ui/faxaddrbookform.py ui/faxaddrbookeditform_base.py ui/align10form.py ui/align10form_base.py \
ui/informationform_base.py ui/informationform.py ui/supportform_base.py ui/supportform.py
dist_noinst_DATA = ui/unloadform_base.ui ui/colorcalform2_base.ui ui/settingsdialog_base.ui ui/aligntype6form1_base.ui \
ui/aboutdlg_base.ui ui/imagepropertiesdlg_base.ui ui/paperedgealignform_base.ui ui/aligntype6form2_base.ui \
ui/nodevicesform_base.ui ui/cleaningform_base.ui ui/colorcalform_base.ui ui/devmgr4_base.ui ui/loadpaperform_base.ui \
ui/cleaningform2_base.ui ui/waitform_base.ui ui/coloradjform_base.ui ui/faxaddrbookeditform_base.ui \
ui/faxaddrbookform_base.ui ui/faxaddrbookgroupeditform_base.ui ui/faxaddrbookgroupsform_base.ui \
plugins/powersettingsdialog_base.ui ui/align10form_base.ui
ui/align10form_base.ui ui/informationform_base.ui ui/supportform_base.ui \
plugins/powersettingsdialog_base.ui
# ui plugins
pluginsdir = $(hplipdir)/plugins
dist_plugins_SCRIPTS = plugins/dj450.py plugins/__init__.py plugins/powersettings.py plugins/powersettingsdialog.py \
plugins/powersettingsdialog_base.py
plugins/powersettingsdialog_base.py plugins/Deskjet_460.py
all: all-recursive
......@@ -1581,6 +1585,9 @@ distdir: $(DISTFILES)
|| exit 1; \
fi; \
done
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$(top_distdir)" distdir="$(distdir)" \
dist-hook
-find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
......@@ -1791,13 +1798,13 @@ uninstall-info: uninstall-info-recursive
check-am clean clean-cupsPROGRAMS clean-generic \
clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \
clean-noinstPROGRAMS clean-recursive clean-sbinPROGRAMS ctags \
ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-shar \
dist-tarZ dist-zip distcheck distclean distclean-compile \
distclean-generic distclean-libtool distclean-recursive \
distclean-tags distcleancheck distdir distuninstallcheck dvi \
dvi-am html html-am info info-am install install-am \
install-cupsPROGRAMS install-data install-data-am \
install-data-hook install-dist_baseSCRIPTS \
ctags-recursive dist dist-all dist-bzip2 dist-gzip dist-hook \
dist-shar dist-tarZ dist-zip distcheck distclean \
distclean-compile distclean-generic distclean-libtool \
distclean-recursive distclean-tags distcleancheck distdir \
distuninstallcheck dvi dvi-am html html-am info info-am \
install install-am install-cupsPROGRAMS install-data \
install-data-am install-data-hook install-dist_baseSCRIPTS \
install-dist_cmdSCRIPTS install-dist_faxSCRIPTS \
install-dist_hplipDATA install-dist_hplipSCRIPTS \
install-dist_imagesDATA install-dist_ldlDATA \
......@@ -1869,8 +1876,10 @@ install-data-hook: test-destdir
echo -e " longtitle=\"HPLIP Device Manager\" \\" >> $(srcdir)/$(ICON_FILE); \
echo -e " mimetypes=\"\" accept_url=\"false\" multiple_files=\"true\"" >> $(srcdir)/$(ICON_FILE); \
fi
$(INSTALL_DATA) $(srcdir)/$(ICON_FILE) $(DESTDIR)$(icondir); \
rm -f $(srcdir)/$(ICON_FILE)
if [ "$(ICON_FILE)" != "" ]; then \
$(INSTALL_DATA) $(srcdir)/$(ICON_FILE) $(DESTDIR)$(icondir); \
rm -f $(srcdir)/$(ICON_FILE); \
fi
#
# Do full install if not rpm_install.
if [ "$(rpm_install)" = "no" ]; then \
......@@ -1905,7 +1914,7 @@ install-data-hook: test-destdir
#
# Edit hpiod.conf in destdir.
echo -e "\n[$(PACKAGE)]\nversion=$(VERSION)\njdprobe=0\n" >> $(DESTDIR)$(hplipdir)/$(PACKAGE).conf
echo -e "[dirs]\nhome=$(hplipdir)\n" >> $(DESTDIR)$(hplipdir)/$(PACKAGE).conf
echo -e "[dirs]\nhome=$(hplipdir)\nrun=$(rundir)\n" >> $(DESTDIR)$(hplipdir)/$(PACKAGE).conf
#
# Edit hpiod.sh in destdir.
sed 's:HPIODDIR=:HPIODDIR=$(sbindir):' < $(DESTDIR)$(hplipdir)/$(PACKAGE).sh > $(DESTDIR)$(hplipdir)/$(PACKAGE).tmp; \
......@@ -1937,10 +1946,15 @@ test-destdir:
if [ ! -f $(DESTDIR)/etc/sane.d/dll.conf ]; then \
touch $(DESTDIR)/etc/sane.d/dll.conf; \
fi; \
$(mkinstalldirs) $(DESTDIR)/usr/lib/sane; \
$(mkinstalldirs) $(DESTDIR)$(sanedir); \
$(mkinstalldirs) $(DESTDIR)/usr/share/applications; \
fi
dist-hook:
if [ "$(SHADOW)" != "" ]; then \
cp -f data/xml/unreleased/*.xml $(distdir)/data/xml/; \
fi
.PHONY: build-pcardext build-cupsext test-destdir
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
......
This diff is collapsed.
......@@ -25,8 +25,8 @@
# CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
# ======================================================================
#
# $Revision: 1.9 $
# $Date: 2005/02/02 21:54:48 $
# $Revision: 1.10 $
# $Date: 2005/10/07 20:57:07 $
# $Author: dwelch $
#
# (c) Copyright 2003-2004 Hewlett-Packard Development Company, L.P.
......@@ -119,21 +119,7 @@ class dispatcher( QObject ):
self.socket = None
def __repr__ (self):
status = [self.__class__.__module__+"."+self.__class__.__name__]
if self.accepting and self.addr:
status.append ('listening')
elif self.connected:
status.append ('connected')
if self.addr is not None:
try:
status.append ('%s:%d' % self.addr)
except TypeError:
status.append (repr(self.addr))
return '<%s at %#x>' % (' '.join (status), id (self))
def add_channel ( self ):
#print "add_channel"
global channels
channels[ self._fileno ] = self
......@@ -148,16 +134,12 @@ class dispatcher( QObject ):
self.sock_write_notifier.setEnabled( False )
def del_channel( self ):
#print "del_channel"
QObject.disconnect( self.sock_read_notifier, SIGNAL( "activated(int)" ), self.handle_read_event )
QObject.disconnect( self.sock_write_notifier, SIGNAL( "activated(int)" ), self.handle_write_event )
self.sock_write_notifier.setEnabled( False )
self.sock_read_notifier.setEnabled( False )
#del self.sock_read_notifier
#del self.sock_write_notifier
global channels
try:
del channels[ self._fileno ]
......@@ -206,8 +188,11 @@ class dispatcher( QObject ):
def connect( self, address ):
self.connected = False
err = self.socket.connect_ex( address )
if err in ( EINPROGRESS, EALREADY, EWOULDBLOCK ):
return
print "1"
r, w, e = select.select([], [self.socket.fileno()], [], 5.0)
err = self.socket.getsockopt(socket.SOL_SOCKET, socket.SO_ERROR)
if err in (0, EISCONN):
self.addr = address
self.connected = True
......@@ -235,9 +220,7 @@ class dispatcher( QObject ):
self.sock_write_notifier.setEnabled( True )
return 0
else:
#self.sock_write_notifier.setEnabled( True )
raise socket.error, why
#return 0
else: # write succeeded
self.sock_write_notifier.setEnabled( False )
return result
......@@ -280,12 +263,8 @@ class dispatcher( QObject ):
elif not self.connected:
self.handle_connect()
self.connected = True
#if self.handle_read():
# self.sock_write_notifier.setEnabled( True )
self.handle_read()
else:
#if self.handle_read():
# self.sock_write_notifier.setEnabled( True )
self.handle_read()
def handle_write_event( self ):
......@@ -311,7 +290,8 @@ class dispatcher( QObject ):
raise Error
def handle_connect( self ):
raise Error
#raise Error
pass
def handle_accept( self ):
raise Error
......
#!/usr/bin/env python
#
# $Revision: 1.33 $
# $Date: 2005/08/18 17:48:54 $
# $Revision: 1.34 $
# $Date: 2005/09/14 22:49:39 $
# $Author: dwelch $
#
# (c) Copyright 2003-2004 Hewlett-Packard Development Company, L.P.
......@@ -500,6 +500,7 @@ COLOR_CAL_TYPE_DESKJET_450 = 1
COLOR_CAL_TYPE_MALIBU_CRICK = 2
COLOR_CAL_TYPE_STRINGRAY_LONGBOW_TORNADO = 3
COLOR_CAL_TYPE_CONNERY = 4
COLOR_CAL_TYPE_COUSTEAU = 5
# status-types
STATUS_TYPE_NONE = 0
......
#!/usr/bin/env python
#
# $Revision: 1.96 $
# $Date: 2005/08/23 17:52:37 $
# $Revision: 1.99 $
# $Date: 2005/10/10 21:38:29 $
# $Author: dwelch $
#
# (c) Copyright 2003-2005 Hewlett-Packard Development Company, L.P.
......@@ -417,17 +417,6 @@ class BaseDevice(object):
# **************************************************************************** #
default_pics = {'deskjet' : 'default_deskjet.png',
'business' : 'default_business_inkjet.png',
'psc' : 'default_psc.png',
'laserjet' : 'default_laserjet.png',
'officejet' : 'default_officejet.png',
'photosmart' : 'default_photosmart.png',
'default' : 'default_printer.png',
}
# **************************************************************************** #
class Device(BaseDevice):
def __init__(self, device_uri=None, printer_name=None,
hpssd_sock=None, callback=None,
......@@ -447,18 +436,6 @@ class Device(BaseDevice):
callback)
self.cups_printers = cups_printers
self.icon_file = os.path.join(prop.image_dir, self.model + ".png")
if not os.path.exists(self.icon_file):
for p in default_pics:
if self.model.find(p) >= 0:
f = default_pics[p]
break
else:
f = default_pics['default']
self.icon_file = os.path.join(prop.image_dir, f)
if not self.cups_printers:
printers = cups.getPrinters()
......@@ -1379,6 +1356,11 @@ class ServerDevice(BaseDevice):
except Error, e:
pass
try:
status_desc = self.string_query_func(self.status_code)
except Error:
status_desc = ''
self.dq.update({
'back-end' : self.back_end,
'is-hp' : self.is_hp,
......@@ -1387,7 +1369,7 @@ class ServerDevice(BaseDevice):
'port' : self.port,
'cups-printers' : ','.join(self.cups_printers),
'status-code' : self.status_code,
'status-desc' : self.string_query_func(self.status_code),
'status-desc' : status_desc,
'deviceid' : self.raw_deviceID,
'panel' : 0,
'panel-line1' : '',
......@@ -1402,6 +1384,12 @@ class ServerDevice(BaseDevice):
r_type = self.mq.get('r-type', 0)
tech_type = self.mq.get('tech-type', TECH_TYPE_NONE)
status_type = self.mq.get('status-type', STATUS_TYPE_NONE)
io_mode = self.mq.get('io-mode', IO_MODE_UNI)
# Turn off status if local connection and bi-di not avail.
if io_mode == IO_MODE_UNI and self.back_end != 'net':
status_type = STATUS_TYPE_NONE
agents = []
if self.device_state != DEVICE_STATE_NOT_FOUND:
......@@ -1443,11 +1431,11 @@ class ServerDevice(BaseDevice):
try:
self.dq.update({'status-desc' : self.string_query_func(status_code),
'error-state' : STATUS_TO_ERROR_STATE_MAP.get(status_code, ERROR_STATE_CLEAR),
'error-state' : STATUS_TO_ERROR_STATE_MAP.get(status_code, ERROR_STATE_CLEAR),
})
except KeyError:
except (KeyError, Error):
self.dq.update({'status-desc' : '',
'error-state' : ERROR_STATE_CLEAR,
'error-state' : ERROR_STATE_CLEAR,
})
r_value, rg, rr, r_value_str = 0, '000', '000000', '000000000'
......@@ -1510,10 +1498,11 @@ class ServerDevice(BaseDevice):
agent_level_trigger = agent.get('level-trigger',
AGENT_LEVEL_TRIGGER_SUFFICIENT_0)
query = 'agent_%s_%s' % (AGENT_types.get(agent_type, 'unknown'),
AGENT_kinds.get(agent_kind, 'unknown'))
log.debug(query)
try:
agent_desc = self.string_query_func('agent_%s_%s' %
(AGENT_types.get(agent_type, 'unknown'),
AGENT_kinds.get(agent_kind, 'unknown')))
agent_desc = self.string_query_func(query)
except Error:
agent_desc = ''
......@@ -1538,10 +1527,11 @@ class ServerDevice(BaseDevice):
agent_health = AGENT_HEALTH_MISINSTALLED
agent_level_trigger = AGENT_LEVEL_TRIGGER_ALMOST_DEFINITELY_OUT
query = 'agent_%s_%s' % (AGENT_types.get(mq_agent_type, 'unknown'),
AGENT_kinds.get(mq_agent_kind, 'unknown'))
log.debug(query)
try:
agent_desc = self.string_query_func('agent_%s_%s' %
(AGENT_types.get(mq_agent_type, 'unknown'),
AGENT_kinds.get(mq_agent_kind, 'unknown')))
agent_desc = self.string_query_func(query)
except Error:
agent_desc = ''
......@@ -1563,8 +1553,9 @@ class ServerDevice(BaseDevice):
})
query = 'agent_%s_%s' % (AGENT_types.get(mq_agent_type, 'unknown'),
AGENT_kinds.get(mq_agent_kind, 'unknown'))
AGENT_kinds.get(mq_agent_kind, 'unknown'))
log.debug(query)
try:
self.dq['agent%d-desc' % a] = self.string_query_func(query)
except Error:
......@@ -1587,7 +1578,11 @@ class ServerDevice(BaseDevice):
code = agent_type + STATUS_PRINTER_LOW_TONER_BASE
self.dq['status-code'] = code
self.dq['status-desc'] = self.string_query_func(code)
try:
self.dq['status-desc'] = self.string_query_func(code)
except Error:
self.dq['status-desc'] = ''
self.dq['error-state'] = STATUS_TO_ERROR_STATE_MAP.get(code, ERROR_STATE_LOW_SUPPLIES)
self.createHistory(code)
......@@ -1595,6 +1590,8 @@ class ServerDevice(BaseDevice):
# OK
query = 'agent_health_%s' % AGENT_healths.get(agent_health, 'unknown')
log.debug(query)
try:
self.dq['agent%d-health-desc' % a] = self.string_query_func(query)
except Error:
......@@ -1617,11 +1614,11 @@ class ServerDevice(BaseDevice):
mq_agent_type = self.mq.get('r%d-agent%d-type' % (r_value, a), 0)
mq_agent_sku = self.mq.get('r%d-agent%d-sku' % (r_value, a), '')
query = 'agent_%s_%s' % (AGENT_types.get(mq_agent_type, 'unknown'),
AGENT_kinds.get(mq_agent_kind, 'unknown'))
log.debug(query)
try:
agent_desc = self.string_query_func('agent_%s_%s' %
(AGENT_types.get(mq_agent_type, 'unknown'),
AGENT_kinds.get(mq_agent_kind, 'unknown')))
agent_desc = self.string_query_func(query)
except Error:
agent_desc = ''
......
#!/usr/bin/env python
#
# $Revision: 1.27 $
# $Date: 2005/07/28 16:55:50 $
# $Revision: 1.31 $
# $Date: 2005/10/05 20:54:12 $
# $Author: dwelch $
#
# (c) Copyright 2003-2004 Hewlett-Packard Development Company, L.P.
......@@ -42,8 +42,8 @@ from codes import *
import logger
# System wide logger
log = logger.Logger( '', logger.Logger.LOG_LEVEL_INFO, logger.Logger.LOG_TO_CONSOLE )
log.set_level( 'info' )
log = logger.Logger('', logger.Logger.LOG_LEVEL_INFO, logger.Logger.LOG_TO_CONSOLE)
log.set_level('info')
MINIMUM_PYQT_MAJOR_VER = 3
MINIMUM_PYQT_MINOR_VER = 8
......@@ -53,19 +53,22 @@ MINIMUM_QT_MINOR_VER = 0
# System wide properties
class Properties(dict):
def __getattr__( self, attr ):
def __getattr__(self, attr):
if attr in self.keys():
return self.__getitem__( attr )
return self.__getitem__(attr)
else:
return ""
def __setattr__( self, attr, val ):
self.__setitem__( attr, val )
def __setattr__(self, attr, val):
self.__setitem__(attr, val)
prop = Properties()
# Language settings
locale.setlocale( locale.LC_ALL, '' )
try:
locale.setlocale(locale.LC_ALL, '')
except locale.Error:
log.error("Unable to set locale.")
try:
t, prop.encoding = locale.getdefaultlocale()
......@@ -74,39 +77,44 @@ except ValueError:
prop.encoding = 'ISO8859-1'
try:
prop.lang_code = t[ :2 ].lower()
prop.lang_code = t[:2].lower()
except TypeError:
prop.lang_code = 'en'
# Config file: directories and ports
prop.config_file = '/etc/hp/hplip.conf'
if os.path.exists( prop.config_file ):
if os.path.exists(prop.config_file):
config = ConfigParser.ConfigParser()
config.read( prop.config_file )
config.read(prop.config_file)
try:
prop.hpssd_cfg_port = config.getint( "hpssd", "port" )
prop.hpssd_cfg_port = config.getint("hpssd", "port")
except:
prop.hpssd_cfg_port = 0
try:
prop.version = config.get( 'hplip', 'version' )
prop.version = config.get('hplip', 'version')
except:
prop.version = ''
try:
prop.home_dir = config.get( 'dirs', 'home' )
prop.home_dir = config.get('dirs', 'home')
except:
prop.home_dir = os.path.realpath(os.path.normpath(os.getcwd()))
try:
prop.run_dir = config.get('dirs', 'run')
except:
prop.home_dir = os.path.realpath( os.path.normpath( os.getcwd() ) )
prop.run_dir = '/var/run'
try:
prop.hpiod_port = int( file( '/var/run/hpiod.port', 'r' ).read() )
prop.hpiod_port = int(file(os.path.join(prop.run_dir, 'hpiod.port'), 'r').read())
except:
prop.hpiod_port = 0
try:
prop.hpssd_port = int( file( '/var/run/hpssd.port', 'r' ).read() )
prop.hpssd_port = int(file(os.path.join(prop.run_dir, 'hpssd.port'), 'r').read())
except:
prop.hpssd_port = 0
......@@ -118,10 +126,11 @@ prop.hpguid_host = 'localhost'
prop.username = pwd.getpwuid(os.getuid())[0]
prop.data_dir = os.path.join( prop.home_dir, 'data' )
prop.i18n_dir = os.path.join( prop.home_dir, 'data', 'qm' )
prop.image_dir = os.path.join( prop.home_dir, 'data', 'images' )
prop.html_dir = os.path.join( prop.home_dir, 'data', 'html', prop.lang_code )
prop.data_dir = os.path.join(prop.home_dir, 'data')
prop.i18n_dir = os.path.join(prop.home_dir, 'data', 'qm')
prop.image_dir = os.path.join(prop.home_dir, 'data', 'images')
prop.xml_dir = os.path.join(prop.home_dir, 'data', 'xml')
#prop.html_dir = os.path.join(prop.home_dir, 'data', 'html', prop.lang_code)
prop.max_message_len = 8192
prop.max_message_read = 65536
......@@ -132,9 +141,9 @@ prop.ppd_search_pattern = 'HP-*.ppd.*'
prop.ppd_download_url = 'http://www.linuxprinting.org/ppd-o-matic.cgi'
prop.ppd_file_suffix = '-hpijs.ppd'
prop.errors_file = os.path.join( prop.home_dir, 'data', 'xml', 'errors.xml' )
prop.strings_file = os.path.join( prop.home_dir, 'data', 'xml', 'strings.xml' )
prop.models_file = os.path.join( prop.home_dir, 'data', 'xml', 'models.xml' )
prop.errors_file = os.path.join(prop.home_dir, 'data', 'xml', 'errors.xml')
prop.strings_file = os.path.join(prop.home_dir, 'data', 'xml', 'strings.xml')
prop.models_file = os.path.join(prop.home_dir, 'data', 'xml', 'models.xml')
# Spinner, ala Gentoo Portage
spinner = "\|/-\|/-"
......@@ -144,8 +153,8 @@ spinpos = 0
def update_spinner():
global spinner, spinpos
if sys.stdout.isatty():
sys.stdout.write( "\b" + spinner[ spinpos ] )
spinpos=( spinpos + 1 ) % 8
sys.stdout.write("\b" + spinner[spinpos])
spinpos=(spinpos + 1) % 8
sys.stdout.flush()
......@@ -205,12 +214,12 @@ ERROR_STRINGS = {
ERROR_UNSUPPORTED_MODEL : "Unsupported printer model.",
}
class Error( Exception ):
def __init__( self, opt=ERROR_INTERNAL ):
class Error(Exception):
def __init__(self, opt=ERROR_INTERNAL):
self.opt = opt
self.msg = ERROR_STRINGS.get( opt, ERROR_STRINGS[ ERROR_INTERNAL ] )
log.debug( "Exception: %d (%s)" % ( opt, self.msg ) )
Exception.__init__( self, self.msg, opt )
self.msg = ERROR_STRINGS.get(opt, ERROR_STRINGS[ERROR_INTERNAL])
log.debug("Exception: %d (%s)" % (opt