2 # -*- coding: utf-8 -*-
4 # (c) Copyright 2003-2009 Hewlett-Packard Development Company, L.P.
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
24 __mod__ = 'hp-timedate'
25 __title__ = 'Time/Date Utility'
26 __doc__ = "Set the time and date on an HP Officejet all-in-one device using the PC time and date."
38 from base.codes import *
39 from base import device, status, utils, pml, tui, module
43 from fax import faxdevice
45 log.error("Unable to load fax services for HPLIP (required for hp-timedate). Exiting.")
50 pml.ERROR_OK_END_OF_SUPPORTED_OBJECTS: "OK: End of supported objects",
51 pml.ERROR_OK_NEAREST_LEGAL_VALUE_SUBSITUTED: "OK: Nearest legal value substituted",
52 pml.ERROR_UNKNOWN_REQUEST: "Unknown request",
53 pml.ERROR_BUFFER_OVERFLOW: "Buffer overflow",
54 pml.ERROR_COMMAND_EXECUTION: "Command execution",
55 pml.ERROR_UNKNOWN_OID: "Unknown OID",
56 pml.ERROR_OBJ_DOES_NOT_SUPPORT_SPECIFIED_ACTION: "Object does not support action",
57 pml.ERROR_INVALID_OR_UNSUPPORTED_VALUE: "Invalid or unsupported value",
58 pml.ERROR_PAST_END_OF_SUPPORTED_OBJS: "Past end of supported objects",
59 pml.ERROR_ACTION_CANNOT_BE_PERFORMED_NOW: "Action cannot be performed now",
60 pml.ERROR_SYNTAX: "Syntax",
64 mod = module.Module(__mod__, __title__, __version__, __doc__, None,
67 mod.setUsage(module.USAGE_FLAG_DEVICE_ARGS)
69 opts, device_uri, printer_name, mode, ui_toolkit, lang = \
72 device_uri = mod.getDeviceUri(device_uri, printer_name,
73 filter={'fax-type': (operator.gt, 0)},
74 back_end_filter=['hpfax'])
77 d = faxdevice.FaxDevice(device_uri, printer_name, disable_dbus=True)
79 if e.opt == ERROR_DEVICE_DOES_NOT_SUPPORT_OPERATION:
80 log.error("Device does not support setting time/date.")
90 log.error("Unable to open device. Exiting. ")
94 log.info("Setting time and date on %s" % device_uri)
97 log.error("An error occured!")
101 except KeyboardInterrupt:
102 log.error("User exit")