Switching subprocess commands to recommended ones

Switched out all `subprocess.Popen` statements for `subprocess.run`
since they are the more recommended and less low-level versions.
This commit is contained in:
Marty Oehme 2021-12-14 17:55:48 +01:00
parent 978da38001
commit 417536f1b5
Signed by: Marty
GPG Key ID: B7538B8F50A1C800
1 changed files with 5 additions and 4 deletions

View File

@ -95,7 +95,7 @@ def log_completed_to_taskwarrior(task_string, date, options):
if options.dryrun:
print(cmd)
return
subprocess.Popen(cmd)
subprocess.run(cmd)
def handle_open_tasks(line, date, options):
@ -123,7 +123,7 @@ def add_incomplete_to_taskwarrior(task_string, date, options):
if options.dryrun:
print(cmd)
return
subprocess.Popen(cmd)
subprocess.run(cmd)
def handle_idea(line, options):
@ -150,7 +150,7 @@ def add_idea_to_taskwarrior(idea_string, options):
if options.dryrun:
print(cmd)
return
subprocess.Popen(cmd)
subprocess.run(cmd)
def get_prio_string(task_string):
@ -192,7 +192,7 @@ def is_today(cur_date):
def add_today(fname, options):
cmd = ["task", *options.taskwarrior_overrides, "+TODAY or +OVERDUE", "export"]
due_json = json.loads(subprocess.run(cmd,capture_output=True).stdout)
due_json = json.loads(subprocess.run(cmd, capture_output=True).stdout)
tasks = f"[{TODAY} 09:00] {options.todo_block_title}\n"
for task in due_json:
@ -209,6 +209,7 @@ def add_today(fname, options):
write_file.write(read_file.read())
os.rename(repl_fname, fname)
if __name__ == "__main__":
process_file(opts.init())
sys.exit(0)