[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 # -*- coding: utf-8 -*- 2 import sys, os, posix 3 from se3Utils import * 4 5 class se3Printers: 6 7 def __init__ (self, path2BatFiles, user, computer, master): 8 """ 9 Open vbs registry rules, some initializations 10 """ 11 try: 12 self.__vbs = open ("%s/machine/%s/printers.vbs" % (path2BatFiles, computer), 'w') 13 self.__user = user 14 self.__computer = computer 15 self.__master = master 16 self.__vbsContent = [] 17 18 # Add some helpers 19 if os.access ("/etc/se3/python/logonPrinters.vbs", os.F_OK): 20 file = open ("/etc/se3/python/logonPrinters.vbs") 21 for line in file.xreadlines (): 22 self.__vbsContent.append (line) 23 24 except OSError: 25 print "Can't write printer %s.vbs" % self.__computer 26 sys.exit (1) 27 28 29 def __del__ (self): 30 """ 31 close vbs 32 """ 33 try: 34 for line in self.__vbsContent: 35 self.__vbs.write (line) 36 37 self.__vbs.close () 38 39 except OSError: 40 print "Can't write printer %s.vbs" % self.__computer 41 42 43 def add (self, printers): 44 """ 45 Add printers rules 46 """ 47 try: 48 if len(printers) > 0: 49 for printer in printers: 50 self.__vbsContent.append ("AddUserPrinterDevice \"%s\", \"%s\"\r\n" % (self.__master, printer)) 51 # Il semble préférable de définir l'imprimante par défaut après 52 # les avoir ajoutées toutes. 53 self.__vbsContent.append ("SetUserDefaultPrinterDevice \"%s\", \"%s\"\r\n" % (self.__master, printers[0])) 54 55 except OSError: 56 print "Can't write printer %s.vbs" % self.__computer 57 58 59 def clean (self): 60 """ 61 Remove old printers 62 """ 63 try: 64 self.__vbsContent.append ("DeleteUserPrintersDevice \"%s\"\r\n" % self.__master) 65 66 except OSError: 67 print "Can't write printer %s.vbs" % self.__computer
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Tue Mar 17 22:47:18 2015 | Cross-referenced by PHPXref 0.7.1 |