Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
slider
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tuhe
slider
Commits
25103555
Commit
25103555
authored
Sep 9, 2021
by
tuhe
Browse files
Options
Downloads
Patches
Plain Diff
Updates
parent
6fef9d75
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/jinjafy/__init__.py
+32
-9
32 additions, 9 deletions
src/jinjafy/__init__.py
with
32 additions
and
9 deletions
src/jinjafy/__init__.py
+
32
−
9
View file @
25103555
...
@@ -10,15 +10,38 @@ import platform
...
@@ -10,15 +10,38 @@ import platform
def
execute_command
(
command
,
shell
=
True
):
def
execute_command
(
command
,
shell
=
True
):
if
not
isinstance
(
command
,
list
):
"""
command
=
[
command
]
This is a super dodgy command from way back in the early 3.x days. I *think* all uses are better served by regular
if
not
platform
.
uname
()[
0
]
==
"
Linux
"
:
subprocess.check_output(..., shell=True), but I am not completely sure, and various people have updated the function
result
=
subprocess
.
run
(
command
,
stdout
=
subprocess
.
PIPE
,
shell
=
shell
)
to make it work on linux/mac; I know that giving inputs as lists was required at some point (perhaps for args with spaces?).
out
=
result
.
stdout
else
:
Current behavior will be subprocess.check_output, and if that works it can just be removed. Until and unless this turns out to be
cmd
=
"
"
.
join
(
command
)
useful again, I think the function is best avoided.
print
(
cmd
)
"""
out
=
subprocess
.
check_output
(
cmd
,
shell
=
shell
)
# if not isinstance(command, list):
# command = [command]
#
# if not platform.uname()[0] == "Linux":
# result = subprocess.run(command, stdout=subprocess.PIPE, shell=shell)
# out = result.stdout
# else:
# cmd = " ".join(command)
# out = subprocess.check_output(cmd, shell=shell)
# s = out.decode("utf-8")
# OK = True
# return s, OK
if
isinstance
(
command
,
list
):
command
=
"
"
.
join
(
command
)
# if not isinstance(command, list):
# command = [command]
# if not platform.uname()[0] == "Linux":
# result = subprocess.run(command, stdout=subprocess.PIPE, shell=shell)
# out = result.stdout
# else:
# cmd = " ".join(command)
out
=
subprocess
.
check_output
(
command
,
shell
=
shell
)
s
=
out
.
decode
(
"
utf-8
"
)
s
=
out
.
decode
(
"
utf-8
"
)
OK
=
True
OK
=
True
return
s
,
OK
return
s
,
OK
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment