Détails du package smp-install-printer_9_all_MUST-BE-EDITED_all.wapt
retour Revenir à la liste des packages

smp-install-printer

ATTENTION CE DÉPÔT n'est plus compatible 1.3 vous devez migrer en 1.5.1.21 !

Fichier control :

package           : smp-install-printer
version           : 9
architecture      : all
section           : base
priority          : standard
maintainer        : Simon Fonteneau
description       : Sample Package for printer installation with wapt
depends           : 
conflicts         : 
maturity          : MUST-BE-EDITED
locale            : all
target_os         : windows
min_os_version    : 
max_os_version    : 
min_wapt_version  : 
sources           : 
installed_size    : 
impacted_process  : 
signer            : wapt.lesfourmisduweb.org
signer_fingerprint: 8da83ebdac1a25e820b186510d049f47407b11835b0664fdc5bacd3595b1671d
signature         : JmuzpklWL1JZmme+SJO4vKKpm2ycVc6/vFFKzb3IPuOY6uueQdT874AWh/aczM6o7sKkqFY8i/Q4OtoZv0pf0xc81eAnMRsB/9gxHjo/ZazE2FqXuASJQdiS6HQzgRU3TFuIyvoFqLS1xv2inXNPcfPRB3Lu9gLls3Q5zpGrPW7tDuX1ibl2BtoeNfkUmg0kwdg5Z50n03TIORk8WxSXbgFzyOCj9xTtVbwQ6foxPM7WjPPFZyfWsCl5rQR3R8riF2Gbo5HGxzdYR9tRWyrKyUBb5gkS3bt3/mzuQZPwU6VAjYqPF40c5k+YXCQAoNGkBUvzXpt/uJkn+1nC7RgJgw==
signature_date    : 20180310-172214
signed_attributes : package,version,architecture,section,priority,maintainer,description,depends,conflicts,maturity,locale,target_os,min_os_version,max_os_version,min_wapt_version,sources,installed_size,impacted_process,signer,signer_fingerprint,signature_date,signed_attributes






Fichier setup.py :

# -*- coding: utf-8 -*-
from setuphelpers import *
import win32com.client


uninstallkey = []

portprint = "192.168.123.4"
nameprinter = "Copieur Compta"

def install():

    if iswin64():
        path_driver = r"disk1\oemsetup.inf"
        name_drivers = "PCL6 Driver for Universal Print"
    else:
        path_driver = r"disk1\oemsetup.inf"
        name_drivers = "PCL6 Driver for Universal Print"



    # Delete old printer
    run_notfatal('rundll32 printui.dll,PrintUIEntry /n "%s" /dl /q ' % nameprinter)

    # Create port lpr or raw
    createprinterport_raw(portprint)

    # use create lpr if needed
    #createprinterport_lpr(portprint,'qu')

    # Install printer and drivers
    run(ur'rundll32 printui.dll,PrintUIEntry /if /b "%s" /f %s /r  "IP_%s" /m "%s" ' % (nameprinter,path_driver,portprint,name_drivers))




def uninstall():
    run_notfatal('rundll32 printui.dll,PrintUIEntry /n "%s" /dl /q ' % nameprinter)








def createprinterport_raw(IPAddress):
    WBEM = win32com.client.GetObject(r"winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
    WBEM.Security_.Privileges.AddAsString("SeLoadDriverPrivilege")
    printerport = WBEM.Get("Win32_TCPIPPrinterPort").SpawnInstance_()
    printerport.Properties_('Name').Value = 'IP_'+IPAddress
    printerport.Properties_('Protocol').Value = 1
    printerport.Properties_('HostAddress').Value = IPAddress
    printerport.Properties_('PortNumber').Value = '9100'
    printerport.Properties_('SNMPEnabled').Value = 'False'
    printerport.Put_()

def createprinterport_lpr(IPAddress,namequeu):
    WBEM = win32com.client.GetObject(r"winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
    WBEM.Security_.Privileges.AddAsString("SeLoadDriverPrivilege")
    printerport = WBEM.Get("Win32_TCPIPPrinterPort").SpawnInstance_()
    printerport.Properties_('Name').Value = 'IP_'+IPAddress
    printerport.Properties_('Protocol').Value = 2
    printerport.Properties_('HostAddress').Value = IPAddress
    printerport.Properties_('SNMPEnabled').Value = 'False'
    printerport.Properties_('Queue').Value = namequeu
    printerport.Put_()