Détails du package

smp-install-printer

retour Revenir à la liste des packages

smp-install-printer

Fichier control :

package           : smp-install-printer
version           : 10
architecture      : all
section           : base
priority          : standard
name              : 
categories        : 
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  : 
description_fr    : 
description_pl    : 
description_de    : 
description_es    : 
description_pt    : 
description_it    : 
description_nl    : 
description_ru    : 
audit_schedule    : 
editor            : 
keywords          : 
licence           : 
homepage          : 
package_uuid      : 44dea40a-dbb2-43a0-831c-74990f7e218a
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
signer            : wapt.lesfourmisduweb.org
signer_fingerprint: 1e54425be03a2a3ea1a264b40d984c31f17a6a489a3b722acb993cbf6561e903
signature         : BLU0kBqe/fcwpmS7+k52Q9OAVdp83wLz2DsLwEwc5Se2v4p3SUSZ6I3+NEBYIGVNAHNTDPyibZwrYd1HX+dcE8aM0FHzfp0cpI6N+OV3Juh/Dn0znQiuPZEvkzztHcV7/e1hts9pjiTcl8uvHMZkW9Tm6jTOwLpDCEeNJy0961pg46lNa/BZRBu3Q7CvgqtpMa6ig7cYtsFkQxSqVAE0VXU9PyPhzmoiB0UQ4z4ZBq0yy97oCwK1xgxqt01GGNzvjtFFCmq8IgR43ntGac/1D91dVDy7plwgsfOJc7AFYTT2FAsotFJgOcfLettUD03yRa30XvW0ndlx9Ln5Falacw==
signature_date    : 2020-07-04T11:05:18.447000
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_os_version,max_os_version,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,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(r'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_()