Fix errors in syncing logic and update to use subprocess.check_call instead os.system#334
Fix errors in syncing logic and update to use subprocess.check_call instead os.system#334
Conversation
probe_scraper/runner.py
Outdated
| f"--delete " | ||
| f"--exclude index.html" | ||
| f"--exclude index.html " | ||
| f"--content-type 'application/json' " + sync_params |
There was a problem hiding this comment.
This is probably also a problem that needs to be fixed. See https://github.com/mozilla/probe-scraper/pull/327/files#r701131309
There was a problem hiding this comment.
Hmm, am pretty sure this is fine:
wlach@antwerp glean-dictionary % python3
Python 3.8.2 (default, Jun 8 2021, 11:59:35)
[Clang 12.0.5 (clang-1205.0.22.11)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.system("echo " + ("foo"))
foo
0
There was a problem hiding this comment.
Mayb to just circumvent the whole "manually adding spaces" problem, stuff all arguments into an array, then " ".join() that together?
(Doesn't os.system alternatively take an array to do this for you?)
There was a problem hiding this comment.
The subprocess module provides more comprehensive facilities, including taking in a list of args instead of a full string. I think we should transition this code to do that.
There was a problem hiding this comment.
Hmm, am pretty sure this is fine
That example hits a python gotcha. ("foo") with a single entry and no trailing comma is not interpreted as a tuple. The example fails if you use ("foo",):
>>> os.system("echo " + ("foo",))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: can only concatenate str (not "tuple") to str
There was a problem hiding this comment.
The
subprocessmodule provides more comprehensive facilities, including taking in a list of args instead of a full string. I think we should transition this code to do that.
Yeah, I was just thinking that. I'll update this PR to use check_call
No description provided.