Skip to content

Commit

Permalink
Make update_virtualenv create virtualenvs as sudo user, not just when…
Browse files Browse the repository at this point in the history
… deleting them
  • Loading branch information
dan-blanchard committed Jan 10, 2019
1 parent 7e4828f commit 0250cfa
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions streamparse/cli/update_virtualenv.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@
)


def _run_cmd(cmd, user, warn_only=False):
if user == env.user:
run(cmd, warn_only=warn_only)
else:
sudo(cmd, warn_only=warn_only, user=user)


@parallel
def _create_or_update_virtualenv(
virtualenv_root,
Expand All @@ -49,15 +56,13 @@ def _create_or_update_virtualenv(
if overwrite_virtualenv:
puts("Removing virtualenv if it exists in {}".format(virtualenv_root))
cmd = "rm -rf {}".format(virtualenv_path)
if user == env.user:
run(cmd, warn_only=True)
else:
sudo(cmd, warn_only=True, user=user)
_run_cmd(cmd, user, warn_only=True)
if not exists(virtualenv_path):
if virtualenv_flags is None:
virtualenv_flags = ""
puts("virtualenv not found in {}, creating one.".format(virtualenv_root))
run("virtualenv {} {}".format(virtualenv_path, virtualenv_flags))
cmd = "virtualenv {} {}".format(virtualenv_path, virtualenv_flags)
_run_cmd(cmd, user)

if isinstance(requirements_paths, string_types):
requirements_paths = [requirements_paths]
Expand Down

0 comments on commit 0250cfa

Please sign in to comment.