empty stdout (subprocess.run)

2022-01-19 Thread James Smith
I'm trying to run a shell command but the stdout is empty: import subprocess torrentno=8 cmd="/usr/bin/transmission-remote --torrent %s --info", str(torrentno) res=subprocess.run(cmd, shell=True, check=True, universal_newlines=True, capture_output=True) print(res) CompletedProcess(args=('/usr/b

Re: empty stdout (subprocess.run)

2022-01-20 Thread James Smith
On Wednesday, January 19, 2022 at 11:08:58 PM UTC-5, Dennis Lee Bieber wrote: > Don't you need to provide for that %s? Perhaps > > cmd="/usr/bin/transmission-remote --torrent %s --info" % torrentno That works, thanks. -- https://mail.python.org/mailman/listinfo/python-list

Re: empty stdout (subprocess.run)

2022-01-20 Thread James Smith
On Wednesday, January 19, 2022 at 11:14:28 PM UTC-5, cameron...@gmail.com wrote: > But I recommend you use shell=False and make: > > cmd = ["/usr/bin/transmission-remote", "--torrent", str(torrentno), "--info"] I like that. :-) -- https://mail.python.org/mailman/listinfo/python-list

=+ for strings

2020-05-03 Thread James Smith
I tried: dt=+"{:02d}".format(day) but I got: dt=+"{:02d}".format(day) TypeError: bad operand type for unary +: 'str' This works: dt=dt+"{:02d}".format(day) Why can't I do the shortcut on strings? -- https://mail.python.org/mailman/listinfo/python-list

pickle and then object changes

2015-01-20 Thread James Smith
Say an object like this exists: class test: a = "" b = "" You pickle it. You change the object definition to have a new field: class test a = "" b = "" c = "" You read the pickled object. Will it load but ignore the new field? That is what I want. -- https://mail.python.org/

regex line by line over file

2014-03-26 Thread James Smith
I can't get this to work. It runs but there is no output when I try it on a file. #!/usr/bin/python import os import sys import re from datetime import datetime #logDir = '/nfs/projects/equinox/platformTools/RTLG/RTLG_logs'; #os.chdir( logDir ); programName = sys.argv[0] fileName = sys.argv[1]

Re: regex line by line over file

2014-03-26 Thread James Smith
On Wednesday, March 26, 2014 11:23:29 PM UTC-4, James Smith wrote: > I can't get this to work. > > It runs but there is no output when I try it on a file. > > > > > > #!/usr/bin/python > > > > import os > > import sys > > import

Re: regex line by line over file

2014-03-27 Thread James Smith
On Thursday, March 27, 2014 1:32:03 AM UTC-4, Steven D'Aprano wrote: > - are you mistaken about the content of the file? > > I can't help you with the first. But the second: try running this: > > # line2 and pat as defined above > filename = sys.argv[1] > with open(filename) as f: > for line

Re: regex line by line over file

2014-03-27 Thread James Smith
On Thursday, March 27, 2014 9:41:55 AM UTC-4, James Smith wrote: > (134, False, '\' > "SHELF-17:LOG_COLN_IP,SC,03-25,01-18-58,NEND,NA,,,:"Log Collection In > Progress",NONE:170035-6364-1048,:YEAR=2014,MODE=NONE"\\r\\n\'') > &g

help with regex

2014-10-07 Thread James Smith
I want the last "1" I can't this to work: >>> pattern=re.compile( "(\d+)$" ) >>> match=pattern.match( "LINE: 235 : Primary Shelf Number (attempt 1): 1") >>> print match.group() -- https://mail.python.org/mailman/listinfo/python-list