Changeset 3437 for pkipplib/trunk/notifiers/samplenotifier
- Timestamp:
- 10/06/08 00:24:42 (16 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
pkipplib/trunk/notifiers/samplenotifier
r45 r3437 1 1 #! /usr/bin/env python 2 # -*- coding: UTF-8 -*-2 # -*- coding: utf-8 -*- 3 3 # 4 4 # pkipplib : IPP and CUPS support for Python … … 9 9 # the Free Software Foundation, either version 3 of the License, or 10 10 # (at your option) any later version. 11 # 11 # 12 12 # This program is distributed in the hope that it will be useful, 13 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 15 # GNU General Public License for more details. 16 # 16 # 17 17 # You should have received a copy of the GNU General Public License 18 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. … … 38 38 # First thing we do is put stdin in non-blocking mode. 39 39 fd = sys.stdin.fileno() 40 fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, 40 fcntl.fcntl(sys.stdin.fileno(), fcntl.F_SETFL, 41 41 fcntl.fcntl(fd, fcntl.F_GETFL) | os.O_NONBLOCK) 42 42 43 43 # then we read the notification CUPS sent us to our stdin 44 44 notification = pkipplib.IPPRequest(sys.stdin.read()) 45 45 46 46 # now we parse it 47 47 notification.parse() 48 48 49 49 # then we act one way or another, depending on the event received. 50 50 event = notification.event_notification["notify-subscribed-event"][0][1] … … 53 53 if event.endswith("-added") : 54 54 action = "add" 55 else : 55 else : 56 56 action = "delete" 57 57 os.system('/usr/bin/pkprinters --%s "%s"' % (action, printername))