Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: eryk sun Newsgroups: comp.lang.python Subject: Re: Running lpr on windows from python Date: Fri, 22 Apr 2016 12:04:24 -0500 Lines: 38 Message-ID: References: <7ec37d41-61eb-4c93-ae21-28d108c261f1@googlegroups.com> <982a6a8e-f987-4e9b-ae2e-90f3d9aad4c9@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: news.uni-berlin.de 0zuO1WFtwTsgHo77JXqUhA9AQDV+NJuJAeC9sd5volhw== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'received:209.85.223': 0.03; 'binary': 0.05; 'file)': 0.07; 'filename': 0.07; '22,': 0.09; 'indicates': 0.09; 'sunos': 0.09; 'python': 0.10; 'subject:python': 0.14; '2016': 0.16; 'dlls': 0.16; 'executable.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'subject:windows': 0.16; 'wrote:': 0.16; 'copied': 0.18; 'directory.': 0.18; '>>>': 0.20; 'windows': 0.20; 'cc:2**0': 0.20; '(by': 0.22; 'assumes': 0.22; 'sends': 0.22; 'am,': 0.23; 'cc:addr:gmail.com': 0.24; 'header:In-Reply-To:1': 0.24; '(e.g.': 0.27; 'fri,': 0.27; 'message-id:@mail.gmail.com': 0.27; 'host': 0.28; '32-bit': 0.29; 'queue': 0.29; 'print': 0.30; 'folder': 0.30; 'option': 0.31; 'class': 0.33; 'file': 0.34; 'running': 0.34; 'server': 0.34; 'received:google.com': 0.35; 'text': 0.35; 'done': 0.35; 'options:': 0.35; 'should': 0.36; 'received:209.85': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'virtual': 0.38; 'received:209': 0.38; 'skip:p 20': 0.38; 'files': 0.38; 'data': 0.39; 'subject:from': 0.39; 'to:addr:python.org': 0.40; 'default': 0.61; 'providing': 0.62; 'url:co': 0.65; 'here': 0.66; 'finally': 0.70; 'burst': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=zjcyvZ6vOnPYCe0hg2kYyEyVLBOIfC+ZGfkphU0qQpk=; b=TvuZPajIvOcTT1Ee4bZQHyBPlyGynCBPC6vDsQPriqPcFsQwE6hYYzV1SnfXE7YY1c fV+IGFHbHDGse81SjP+wH4ZDxkf/zROoXh/76jpdx9SuK6hBK9W8Yi1aiTaiuEFyLXxA 8vz/TPD0vYVrJ02/dWmcbfPrercXYuE3lU40Lr+ClLNftAKwnHqSJJW2j+DaDlrO4xuy A49Y/sw1cgo9v+vfYBrc5HkxWGPjd4NnmYv67WSmnBzrs519nPwtNZmYlZkDM5uY2iBg nhEDjnL6dza2GB7VAyiBCh6G0SbZ9X4w9smSkW6N3AutRtq/ld+KBJ8tQWG7LV6pyeK4 rAwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=zjcyvZ6vOnPYCe0hg2kYyEyVLBOIfC+ZGfkphU0qQpk=; b=ZiUuDf0fNP/05fI/E1vL3q6X48AfnsRoVed2oivVXnxeJ6QHBZQ9A1o1T89h1iMlMn QaMrewHOCycn32qXfovVcxcoP242A6ooJ3oGSjE7vlZmgeDND0V+2mM/RM1EIHRo58tx C/lLs9ouALkMdls2rJdb47jUswHnI5dnbgNSm8EeQwNjYXZCDy3WFi2Vo388qWHh9+Fo inFAqswzadh6cxEE4pz2a05P7agyyeQJvwvFnLz6fUxaTWCbRFymJgkZ10st/sFvOCyM QIMGxVgzZGzt7ErfUjQcJAx7MN+Emjs5SvCqe7CKqp4u0u7c2his0x/Cz1uOCk3naf/S cK0w== X-Gm-Message-State: AOPr4FXzY6gS6lHVXyZXRPaR91cl33m6/JVY21Z4DQbqu0AnU4UAliBCuXBmzcJ6R0MCPwSlm0Vzhl0QvPnyGA== X-Received: by 10.107.14.209 with SMTP id 200mr24220936ioo.73.1461344703903; Fri, 22 Apr 2016 10:05:03 -0700 (PDT) In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: X-Mailman-Original-References: <7ec37d41-61eb-4c93-ae21-28d108c261f1@googlegroups.com> <982a6a8e-f987-4e9b-ae2e-90f3d9aad4c9@googlegroups.com> Xref: csiph.com comp.lang.python:107500 On Fri, Apr 22, 2016 at 10:07 AM, loial wrote: > I finally found the solution here : > > http://www.tomshardware.co.uk/forum/240019-44-error-windows > > Copied lpr.exe, lprhelp.dll, and lprmonui.dll from the System32 folder to the sysWOW64 folder Using the virtual "SysNative" directory should work on Windows 7+ (Server 2008 R2). All you need is for CreateProcess to find the executable. Finding the DLLs is done during process initialization, so there's no need to copy them from the native System32 directory. It works for me in 32-bit Python running in Windows 10: >>> if '32bit' in platform.architecture(): ... lpr = os.path.join(os.environ['SystemRoot'], 'SysNative', 'lpr.exe') ... else: ... lpr = os.path.join(os.environ['SystemRoot'], 'System32', 'lpr.exe') ... >>> print(lpr) C:\Windows\SysNative\lpr.exe >>> subprocess.call(lpr) Sends a print job to a network printer Usage: lpr -S server -P printer [-C class] [-J job] [-o option] [-x] [-d] filename Options: -S server Name or ipaddress of the host providing lpd service -P printer Name of the print queue -C class Job classification for use on the burst page -J job Job name to print on the burst page -o option Indicates type of the file (by default assumes a text file) Use "-o l" for binary (e.g. postscript) files -x Compatibility with SunOS 4.1.x and prior -d Send data file first1