If in windows, I do: type logfile | cantools plot inputfile.dbc What would the syntax look like if I'm trying to do using Popen? The following did not work as it did not pipe the logfile contents to cantools args = ["plot 1.dbc"] p = Popen(['cantools'] + args, stdout=PIPE)
Good video. However, I have read multiple posts regarding the use of this module and almost all of them recommend against using shell=True. What are your thoughts?
Could I used this to monitor the breads I make, giving me a live counting list of each loaf I made throughout the day, so I can tell when one of the loaves is ready to cut and serve? Each bread needs to cool for up to 2 hours. So I'd like to be able to keep adding breads to an ever expanding list. That way I can just look at it and tell how long each batch of bread has been cooling. I'm a baker. Thanks
Great video; is there any way we can order glob module to select file in sequence ex. Have File name with (1-30) . Want to process file 1-30 in sequence of 1,2,3....30
Thank you for the explanation!. I have one doubt. Suppose if I want to execute a command with multiple arguments to be passed in the CLI using the Popen subprocess. For Eg. jira --action createIssue --project "$1" --type "$2" --description $3 I get an error stating that the bufsize must be an integer. But when I provide a valid value for the bufsize argument in Popen. I still get an error stating too many values passed for bufsize argument
May be when you are passing the argument it is taking as char. You may need to cast your value as integer and try. eg: suppose your are passing $1 then first_num = int(sys.argv[1])
you mean to say subprocess failed then you want to execute once again ? You can write via n-number ways. I am giving you one example using function. if success then returncode will return 0 else other than 0. You can loop through. You can add stdout and stderr. If you want capture value of stdout and stderr. ================================ import subprocess def run_os_cmd(cmd): p1 = subprocess.Popen(cmd, s p1.wait() return p1.returncode cmd = "du -sh /tmp" cmd_status = run_os_cmd(cmd) if cmd_status != 0: cmd_status = run_os_cmd(cmd)
Hi! if I run a bioinformatics pipeline, will this method show the live feed of the pipeline and also capture stderr if something goes wrong in the pipeline? today I have tried using subprocess.run, but if I use the capture_output=True, I wont get any live feed. and if I skip that I will get live feed but I wont get any stderr so I can see what went wrong in case it does:/ pls help!:)
in some cases, your error will captured in stdout also. Believe, you are capturing stdout and stderr also. Please check value of both. You will get required info. To know if your subprocess completed or not, You can check with returncode. If returncode == 0 then success else fail.
Usually application should handle and authenticate if running by adminstrator or not. If you are considering python code as application and your running on window then you can check via ctypes.windll.shell32.IsUserAnAdmin() ==> 0 ## running via normal user 1 means running by adminstrator. For unix, you can use os module or getpass.getuser(). You may combine also.