Commit f1226f71 authored by Didier 'OdyX' Raboud's avatar Didier 'OdyX' Raboud

Imported Upstream version 3.14.6

parent 14523d05

Too many changes to show.

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

This diff is collapsed.
......@@ -505,7 +505,7 @@ def readXmlTagDataFromURI(dev,URI,xmlRootNode,xmlReqDataNode,timeout=5):
strResp = utils.unchunck_xml_data(strResp)
pos = strResp.find(xmlRootNode,0,len(strResp))
repstr = strResp[pos:].strip()
repstr = repstr.replace('\r',' ').replace('\t',' ').replace('\n',' ') # To remove formating characters from the received xml
repstr = repstr.replace('\r','').replace('\t','').replace('\n','') # To remove formating characters from the received xml
repstr = repstr.rstrip('0') # To remove trailing zero from the received xml
try:
parser_object = utils.extendedExpat()
......@@ -514,7 +514,7 @@ def readXmlTagDataFromURI(dev,URI,xmlRootNode,xmlReqDataNode,timeout=5):
reqDataElementList = root_element.getElementsByTagName(xmlReqDataNode)
for node in reqDataElementList:
repstr = node.toString()
repstr = repstr.replace('\r',' ').replace('\t',' ').replace('\n',' ') # To remove formating characters from the received xml
repstr = repstr.replace('\r','').replace('\t','').replace('\n','') # To remove formating characters from the received xml
params = utils.XMLToDictParser().parseXML(repstr)
paramsList.append(params)
except xml.parsers.expat.ExpatError, e:
......@@ -566,7 +566,7 @@ def readXmlDataFromURI(dev,URI,xmlRootNode,xmlChildNode,timeout=5):
strResp = utils.unchunck_xml_data(strResp)
pos = strResp.find(xmlRootNode,0,len(strResp))
repstr = strResp[pos:].strip()
repstr = repstr.replace('\r',' ').replace('\t',' ').replace('\n',' ') # To remove formating characters from the received xml
repstr = repstr.replace('\r','').replace('\t','').replace('\n','') # To remove formating characters from the received xml
repstr = repstr.rstrip('0') # To remove trailing zero from the received xml
elementCount = repstr.count(xmlChildNode)
try:
......
......@@ -61,7 +61,7 @@ def detectNetworkDevices(ttl=4, timeout=10):
y['hn'] = bits[6].replace('.local', '')
details = bits[9].split('" "')
for item in details:
key, value = item.split('=')
key, value = item.split('=', 1)
if key == 'ty':
y['mdns'] = value
y['device1'] = "MFG:Hewlett-Packard;MDL:%s;CLS:PRINTER;" % value
......
......@@ -71,6 +71,19 @@ ERROR_FAX_FILE_NOT_FOUND = 57
ERROR_INVALID_ARGUMENT = 58
# --> add new codes here <--
ERROR_INTERNAL = 99
ERROR_FILE_NOT_FOUND = 101
ERROR_DIRECTORY_NOT_FOUND = 102
ERROR_NO_NETWORK = 103
ERROR_CHECKSUM_ERROR = 104
ERROR_GPG_CMD_NOT_FOUND = 105
ERROR_UNABLE_TO_RECV_KEYS = 106
ERROR_DIGITAL_SIGN_NOT_FOUND = 107
ERROR_FAILED_TO_DOWNLOAD_FILE = 107
ERROR_DIGITAL_SIGN_BAD = 108
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
......@@ -276,7 +289,6 @@ EVENT_ERROR_DEVICEOPEN_FAILED_DEV_NODE_MOVED = 5038
# end
# diagnosis tool codes
EVENT_ADD_PRINTQUEUE = 5501
EVENT_DIAGNOSE_PRINTQUEUE = 5502
#end
......@@ -306,7 +318,7 @@ EVENT_FAX_MAX = 8999
# UI
EVENT_MIN_UI_EVENT = 9000
EVENT_CUPS_QUEUES_CHANGED = 9000 # sent by hp-setup if queues added (or removed)
EVENT_CUPS_QUEUES_ADDED = 9000 # sent by hp-setup if queues added
EVENT_RAISE_DEVICE_MANAGER = 9001
#EVENT_JOB_STORAGE_UI_REQUEST = 9002 # sent by hplipjs CUPS filter for job storage UI
EVENT_HISTORY_UPDATE = 9003 # sent by hp-systray to hp-toolbox when a device's history changes
......@@ -321,6 +333,7 @@ EVENT_DEVICE_UPDATE_ACTIVE = 9030
EVENT_DEVICE_UPDATE_INACTIVE = 9031
EVENT_DEVICE_UPDATE_BLIP = 9032
EVENT_SYSTEMTRAY_EXIT = 9040
EVENT_CUPS_QUEUES_REMOVED = 9041 # sent by hp-setup if queues removed
EVENT_MAX_UI_EVENT = 9999
EVENT_MAX_EVENT = 9999
......@@ -592,10 +605,13 @@ AGENT_TYPE_K_Y = 14 # black and yellow (for LJ Pro)
AGENT_TYPE_C_M = 15 # cyan and magenta (for LJ Pro)
AGENT_TYPE_LG_PK = 16 # light grey and photo black
AGENT_TYPE_LG = 17 # light grey
AGENT_TYPE_G = 18 # medium grey
AGENT_TYPE_G = 18 # grey
AGENT_TYPE_PG = 19 # photo grey
AGENT_TYPE_PHOTO_BLACK = 20 # photo black
AGENT_TYPE_MATTE_BLACK = 21 # matte black
AGENT_TYPE_LC = 22 #light cyan
AGENT_TYPE_LM = 23 #light magenta
AGENT_TYPE_DG = 24 #dark gray
AGENT_TYPE_BLACK_B8800 = 39 # For PS B8800
AGENT_TYPE_WHITE = 0x20 # For ISO 10180 compatibility
AGENT_TYPE_RED = 0x21 # For ISO 10180 compatibility
......
......@@ -45,7 +45,7 @@ import pml
import status
from prnt import pcl, ldl, cups
from base import models, mdns, slp, avahi
from strings import StringTable
from strings import *
http_result_pat = re.compile("""HTTP/\d.\d\s(\d+)""", re.I)
......@@ -375,7 +375,7 @@ def makeURI(param, port=1):
result_code, uri = hpmudext.make_net_uri(param, port)
if result_code == hpmudext.HPMUD_R_OK and uri:
uri = uri.replace("ip","hostname")
uri = uri.replace("ip=","hostname=")
log.debug("Found: %s" % uri)
found = True
cups_uri = uri
......@@ -909,75 +909,6 @@ def validateFilterList(filter):
return True
#
# UI String Queries (why is this here?)
#
inter_pat = re.compile(r"""%(.*)%""", re.IGNORECASE)
st = StringTable()
strings_init = False
def initStrings():
global strings_init, st
strings_init = True
cycles = 0
while True:
found = False
for s in st.string_table:
short_string, long_string = st.string_table[s]
short_replace, long_replace = short_string, long_string
try:
short_match = inter_pat.match(short_string).group(1)
except (AttributeError, TypeError):
short_match = None
if short_match is not None:
found = True
try:
short_replace, dummy = st.string_table[short_match]
except KeyError:
log.error("String interpolation error: %s" % short_match)
try:
long_match = inter_pat.match(long_string).group(1)
except (AttributeError, TypeError):
long_match = None
if long_match is not None:
found = True
try:
dummy, long_replace = st.string_table[long_match]
except KeyError:
log.error("String interpolation error: %s" % long_match)
if found:
st.string_table[s] = (short_replace, long_replace)
if not found:
break
else:
cycles +=1
if cycles > 1000:
break
def queryString(string_id, typ=0):
if not strings_init:
initStrings()
#log.debug("queryString(%s)" % string_id)
s = st.string_table.get(str(string_id), ('', ''))[typ]
if type(s) == type(''):
return s
return s()
AGENT_types = { AGENT_TYPE_NONE : 'invalid',
......@@ -999,12 +930,16 @@ AGENT_types = { AGENT_TYPE_NONE : 'invalid',
#AGENT_TYPE_C_K : 'cyan_and_black',
AGENT_TYPE_LG_PK : 'light_gray_and_photo_black',
AGENT_TYPE_LG : 'light_gray',
AGENT_TYPE_G : 'medium_gray',
AGENT_TYPE_G : 'gray',
AGENT_TYPE_DG : 'dark_gray',
AGENT_TYPE_PG : 'photo_gray',
AGENT_TYPE_C_M : 'cyan_and_magenta',
AGENT_TYPE_K_Y : 'black_and_yellow',
AGENT_TYPE_PHOTO_BLACK : 'photo_black',
AGENT_TYPE_LC : 'light_cyan',
AGENT_TYPE_LM : 'light_magenta',
AGENT_TYPE_MATTE_BLACK : 'matte_black',
AGENT_TYPE_RED : 'red',
AGENT_TYPE_UNSPECIFIED : 'unspecified', # Kind=5,6
}
......
......@@ -160,13 +160,8 @@ class State(ConfigBase):
class UserConfig(ConfigBase):
def __init__(self):
prop.user_dir = os.path.expanduser('~/.hplip')
try:
if not os.path.exists(prop.user_dir):
os.makedirs(prop.user_dir)
except OSError:
log.error("Failed to create %s directory. User preferences and collection of debug logs can't be supported."%(prop.user_dir))
sts, prop.user_dir = os_utils.getHPLIPDir()
if not os.geteuid() == 0:
prop.user_config_file = os.path.join(prop.user_dir, 'hplip.conf')
......
......@@ -22,6 +22,7 @@
# Global import
import os
import os.path
import stat
#Local
from base import logger
......@@ -45,3 +46,39 @@ def getFileSize(filename):
return os.path.getsize(filename)
def getHPLIPDir():
homedir = os.path.expanduser('~')
hplipdir = os.path.join(homedir, ".hplip")
status = 0
if<