Re: [Tutor] subprocess.call not formatting date

2014-07-08 Thread Bob Williams
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 08/07/14 18:12, Peter Otten wrote: > I suggest that you calculate the folder name in Python instead: > > # untested name = > datetime.datetime.now().strftime("%y-%m-%d_%H-%M") destpath = > os.path.join("/home/bob/A3/docsnaps", name) subprocess.call

Re: [Tutor] subprocess.call not formatting date

2014-07-08 Thread Emile van Sebille
On 7/8/2014 9:44 AM, Bob Williams wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I'm using Python 2.7.6 on an openSUSE linux system. I'm trying to convert a shell (bash) script to a python script, and everything's worked OK except this. The following line in the shell script btrfs subvo

Re: [Tutor] subprocess.call not formatting date

2014-07-08 Thread Peter Otten
Bob Williams wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > I'm using Python 2.7.6 on an openSUSE linux system. > > I'm trying to convert a shell (bash) script to a python script, and > everything's worked OK except this. The following line in the shell script > > btrfs subvolume

[Tutor] subprocess.call not formatting date

2014-07-08 Thread Bob Williams
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I'm using Python 2.7.6 on an openSUSE linux system. I'm trying to convert a shell (bash) script to a python script, and everything's worked OK except this. The following line in the shell script btrfs subvolume snapshot /home/bob/A3/documents /home/

Re: [Tutor] subprocess.call list vs. str argument

2014-02-28 Thread Albert-Jan Roskam
> > From: Oscar Benjamin >To: Albert-Jan Roskam >Cc: Dave Angel ; eryksun ; >"Tutor@python.org" >Sent: Wednesday, February 26, 2014 3:38 PM >Subject: Re: [Tutor] subprocess.call list vs. str argument > > >On 26 Febru

Re: [Tutor] subprocess.call list vs. str argument

2014-02-26 Thread Oscar Benjamin
On 26 February 2014 08:50, Albert-Jan Roskam wrote: > > Yesterday evening (it was *late* so forgive me if I wrong) I realized that > part of my confusion was also caused by the fact that I ran my code in Idle. > If I called subprocess.call with a list argument, it returned code 0 > (success) bu

Re: [Tutor] subprocess.call list vs. str argument

2014-02-26 Thread eryksun
On Wed, Feb 26, 2014 at 3:50 AM, Albert-Jan Roskam wrote: > On Tue, Feb 25, 2014 at 4:54 PM, Dave Angel wrote: >> CreateProcess has its own design bobbles as well. For >> example, if you forget to put quotes around the program >> name, it will happily try to add ".exe" to *multiple* >> places in

Re: [Tutor] subprocess.call list vs. str argument

2014-02-26 Thread Albert-Jan Roskam
? ~~ On Tue, 2/25/14, eryksun wrote: Subject: Re: [Tutor] subprocess.call list vs. str argument To: "Dave Angel" Cc: tutor@python.org Date: Tuesday, February 25, 2014, 11:30 PM O

Re: [Tutor] subprocess.call list vs. str argument

2014-02-25 Thread eryksun
On Tue, Feb 25, 2014 at 4:54 PM, Dave Angel wrote: > CreateProcess has its own design bobbles as well. For example, if > you forget to put quotes around the program name, it will > happily try to add ".exe" to *multiple* places in the hopes that > one of them will work. > > Adding a file c:\prog

Re: [Tutor] subprocess.call list vs. str argument

2014-02-25 Thread Dave Angel
eryksun Wrote in message: > > > FYI, in Windows the situation is different. CreateProcess takes a > string argument, so the setup code changes to the following: > > > It's fine to use a string for args in Windows, and you may need to if > the program parses the command line differently than l

Re: [Tutor] subprocess.call list vs. str argument

2014-02-25 Thread Danny Yoo
See the comment about 'args' in: http://docs.python.org/2/library/subprocess.html#frequently-used-arguments which says: """args is required for all calls and should be a string, or a sequence of program arguments. Providing a sequence of arguments is generally preferred, as it allows the mod

Re: [Tutor] subprocess.call list vs. str argument

2014-02-25 Thread eryksun
On Tue, Feb 25, 2014 at 2:52 PM, Albert-Jan Roskam wrote: > Here is why I used "shell=True" before. Is it related to the > file paths? > > cmd = (r'sphinx-apidoc ' >r'-f -F ' >r'-H "%(title)s" ' >r'-A "%(author)s" ' >r'-V "%(version)s" ' >

Re: [Tutor] subprocess.call list vs. str argument

2014-02-25 Thread Dave Angel
Albert-Jan Roskam Wrote in message: > > > - Original Message - > >> From: Danny Yoo >> To: Peter Otten <__pete...@web.de> >> Cc: Python Tutor Mailing List >> Sent: Monday, February 24, 2014 11:01 PM >> Subject: Re: [Tutor] subproces

Re: [Tutor] subprocess.call list vs. str argument

2014-02-25 Thread Albert-Jan Roskam
- Original Message - > From: Danny Yoo > To: Peter Otten <__pete...@web.de> > Cc: Python Tutor Mailing List > Sent: Monday, February 24, 2014 11:01 PM > Subject: Re: [Tutor] subprocess.call list vs. str argument > > Last comment (apologies for being so frag

Re: [Tutor] subprocess.call list vs. str argument

2014-02-24 Thread Danny Yoo
Last comment (apologies for being so fragmented!). I don't know why the literal strings there are raw there. Altogether, I'd expect: # cmd1 = ['sphinx-apidoc', '-f', '-F', '-H', title, '-A', author, '-V', version,

Re: [Tutor] subprocess.call list vs. str argument

2014-02-24 Thread Danny Yoo
There are a few issues there. I'd also recommend not trying to shell-quote these manually, # in the argument list of os.subprocess: r'-H', '"%s"' % title, r'-A', '"%s"' % author, r'-V', '"%s"' % version, Rather, just do the simpler thing: r'-H', title, r'-A', author,

Re: [Tutor] subprocess.call list vs. str argument

2014-02-24 Thread Peter Otten
Peter Otten wrote: >> r'-f -F', >> r'-H', '"%s"' % title, > > "title" becomes \"title\", i. e. Python puts in an extra effort to have > the quotes survive the subsequent parsing process of the shell: > print subprocess.list2cmdline(['"title"']) > \"title\" Forget that :( Danny spotted th

Re: [Tutor] subprocess.call list vs. str argument

2014-02-24 Thread Peter Otten
Albert-Jan Roskam wrote: > Hi, > > In the code below, cmd1 and cmd2 are equivalent, as in: " ".join(cmd1) == > cmd2. But the first example returns a code 2, whereas the second runs > successfully. What is the difference? I prefer using a list as it looks a > little cleaner. Btw, shell=True is nee

Re: [Tutor] subprocess.call list vs. str argument

2014-02-24 Thread Danny Yoo
> cmd1 = [r'sphinx-apidoc', >r'-f -F', This part looks suspicious. Are you sure you don't mean: '-f', '-F' here? They need to be separate arguments. Also, you mention: > Btw, shell=True is needed here. Why do you need shell expansion on the arguments? This can be dangerous u

[Tutor] subprocess.call list vs. str argument

2014-02-24 Thread Albert-Jan Roskam
Hi, In the code below, cmd1 and cmd2 are equivalent, as in: " ".join(cmd1) == cmd2. But the first example returns a code 2, whereas the second runs successfully. What is the difference? I prefer using a list as it looks a little cleaner. Btw, shell=True is needed here. # Python 2.7.3 (default, J

Re: [Tutor] subprocess.call warning

2010-10-04 Thread Steven D'Aprano
On Mon, 4 Oct 2010 05:42:16 pm Norman Khine wrote: > >> the first calls the 'sox' library which joins all the .wav files > >> into one file and then i use the 'wav2swf' library to create a SWF > >> output of the file. > >> > >> can the code be improved? > > > > Code can always be improved :-) What

Re: [Tutor] subprocess.call warning

2010-10-04 Thread Norman Khine
thank you for the reply On Mon, Oct 4, 2010 at 12:47 AM, Steven D'Aprano wrote: > On Mon, 4 Oct 2010 06:44:54 am Norman Khine wrote: >> hello, from the docs http://docs.python.org/library/subprocess.html i >> see there is a WARNING about deadlock when using the subprocess.call. >> in my code i ha

Re: [Tutor] subprocess.call warning

2010-10-03 Thread Steven D'Aprano
On Mon, 4 Oct 2010 06:44:54 am Norman Khine wrote: > hello, from the docs http://docs.python.org/library/subprocess.html i > see there is a WARNING about deadlock when using the subprocess.call. > in my code i have this > > http://pastie.org/1197024 The warning says: Like Popen.wait(), this

[Tutor] subprocess.call warning

2010-10-03 Thread Norman Khine
hello, from the docs http://docs.python.org/library/subprocess.html i see there is a WARNING about deadlock when using the subprocess.call. in my code i have this http://pastie.org/1197024 the first calls the 'sox' library which joins all the .wav files into one file and then i use the 'wav2swf'

Re: [Tutor] subprocess.call

2009-07-27 Thread Sander Sweers
On Mon, 2009-07-27 at 14:40 -0400, davidwil...@safe-mail.net wrote: > OK I think I found my error, here is what I did: > > flags = set([file for file in glob.glob('flag-*.svg')]) > > def call(cmd): > subprocess.call([cmd], shell=True) You hardly ever need shell=True. And using [cmd] is close

[Tutor] subprocess.call

2009-07-27 Thread davidwilson
OK I think I found my error, here is what I did: flags = set([file for file in glob.glob('flag-*.svg')]) def call(cmd): subprocess.call([cmd], shell=True) for flag in flags: name = flag[:-4] out = name+'.png' call('svg2png --width=17 --height=12 %s %s' \ % (flag, o

[Tutor] subprocess.call

2009-07-27 Thread davidwilson
Hello again, >From my previous post I would now like to transform the SVG images using the >svg2png library, but am having difficulties in making it work. Here is the >code: import glob import csv from os import rename import subprocess countries = {} reader = csv.reader(open("countries.csv"))