Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #91598

Re: Using Python instead of Bash

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:Python': 0.05; 'preference': 0.05; 'sufficient': 0.05; 'think,': 0.05; 'filenames': 0.07; 'libraries.': 0.09; 'pil': 0.09; 'python': 0.11; 'files.': 0.13; 'ignore': 0.14; 'argument': 0.15; '(heck,': 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message-id:@cskk.homeip.net': 0.16; 'simpson': 0.16; 'subprocess': 0.16; 'thread.': 0.16; 'wrote:': 0.16; 'memory': 0.17; 'string': 0.17; 'library': 0.20; 'explicit': 0.22; 'simpler': 0.22; 'passing': 0.23; 'cheers,': 0.24; 'seems': 0.24; 'header:In-Reply-To:1': 0.24; 'example': 0.25; 'header:User-Agent:1': 0.26; 'command': 0.28; "doesn't": 0.28; 'issues.': 0.29; 'queue': 0.29; 'print': 0.31; "i'd": 0.31; 'creating': 0.32; 'probably': 0.32; 'rule': 0.33; 'know.': 0.34; "i'll": 0.34; 'that,': 0.34; 'could': 0.35; 'to:addr:python-list': 0.35; 'skip:> 10': 0.35; "isn't": 0.35; 'submitting': 0.35; 'but': 0.36; '(and': 0.36; 'should': 0.37; 'subject:: ': 0.37; 'charset :us-ascii': 0.37; 'skip:i 20': 0.37; 'or,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'content-disposition:inline': 0.60; 'avoid': 0.61; 'more': 0.62; 'needing': 0.63; 'waiting': 0.63; 'making': 0.64; 'within': 0.64; 'between': 0.65; 'therefore': 0.65; 'cameron': 0.66; 'jobs': 0.67; 'direct': 0.70; 'received:61': 0.72; 'directly.': 0.76; 'etc,': 0.84; 'subject:Using': 0.84; 'dennis': 0.91
X-Authentication-Info Submitted using ID cskk@bigpond.com
X-Authority-Analysis v=2.0 cv=F6HVh9dN c=1 sm=1 a=CHt9LjXFlqDSH5K6u1KraQ==:17 a=yEdEr6MRgwAA:10 a=kj9zAlcOel0A:10 a=vrnE16BAAAAA:8 a=ZtCCktOnAAAA:8 a=XAFQembCKUMA:10 a=QrVWhbZvAAAA:8 a=AImdrFvdY1HD8FtoRQUA:9 a=CjuIK1q_8ugA:10 a=CHt9LjXFlqDSH5K6u1KraQ==:117
Date Mon, 1 Jun 2015 08:57:13 +1000
From Cameron Simpson <cs@zip.com.au>
To python-list@python.org
Subject Re: Using Python instead of Bash
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii; format=flowed
Content-Disposition inline
In-Reply-To <bn7mmadupkolhvttkok4dbsa71b9j81gmj@4ax.com>
User-Agent Mutt/1.5.23 (2014-03-12)
References <bn7mmadupkolhvttkok4dbsa71b9j81gmj@4ax.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.20+
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.251.1433113049.5151.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1433113049 news.xs4all.nl 2854 [2001:888:2000:d::a6]:57237
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:91598

Show key headers only | View raw


On 31May2015 11:05, Dennis Lee Bieber <wlfraed@ix.netcom.com> wrote:
>	I'll concede submitting jobs to a print queue probably does work easier
>this way, but I'd have to ask if the "convert" could be performed using
>actual Python -- the old Python Imaging Library -- PIL -- for example
>(superseded, I think, by pillow)?

(Yes, PIL is stale, Pillow is live.)

Or, more direct if Pillow doesn't have what he wants, is to use the ImageMagick 
or GraphicsMagick Python libraries. Anything ImageMagick can do via the command 
line they should be able to do directly.

The advantage of using PIL/Pillow or ImageMagick/GraphicsMagick within Python 
is that, memory permitting, one can avoid making (and therefore needing to 
clean up) temporary files.

>	Given that you do nothing between creating a subprocess and waiting for
>it to exit, subprocess.Popen() could be overkill -- the simpler
>subprocess.call() could be sufficient (heck, the old os.system() is
>sufficient, but preference seems to be to ignore it for subprocess.call()
>instead).

os.system passed a string to the shell. That has quoting/security issues.  
(Exactly like shell=True with subprocess.)

With his specific example this isn't a big deal because all the filenames are 
benign etc, but as a general rule using subprocess and passing explicit command 
line argument strings is safer.

All of which you know, I know. But good to get it said in the thread.

Cheers,
Cameron Simpson <cs@zip.com.au>

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Using Python instead of Bash Cameron Simpson <cs@zip.com.au> - 2015-06-01 08:57 +1000

csiph-web