Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.devtools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.devtools
Commits
6c6db1e5
Commit
6c6db1e5
authored
6 years ago
by
André Anjos
Browse files
Options
Downloads
Patches
Plain Diff
[bootstrap] Revert previous commits
parent
71cd821d
No related branches found
No related tags found
No related merge requests found
Pipeline
#26198
passed
6 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bob/devtools/bootstrap.py
+9
-42
9 additions, 42 deletions
bob/devtools/bootstrap.py
with
9 additions
and
42 deletions
bob/devtools/bootstrap.py
+
9
−
42
View file @
6c6db1e5
...
@@ -36,12 +36,9 @@ _INTERVALS = (
...
@@ -36,12 +36,9 @@ _INTERVALS = (
import
os
import
os
import
sys
import
sys
import
pty
import
glob
import
glob
import
time
import
time
import
errno
import
shutil
import
shutil
import
select
import
platform
import
platform
import
subprocess
import
subprocess
...
@@ -96,9 +93,6 @@ def human_time(seconds, granularity=2):
...
@@ -96,9 +93,6 @@ def human_time(seconds, granularity=2):
def
run_cmdline
(
cmd
,
env
=
None
):
def
run_cmdline
(
cmd
,
env
=
None
):
'''
Runs a command on a environment, logs output and reports status
'''
Runs a command on a environment, logs output and reports status
Copied from: https://github.com/terminal-labs/cli-passthrough, which is in
turn based on https://stackoverflow.com/a/31953436.
Parameters:
Parameters:
...
@@ -115,42 +109,14 @@ def run_cmdline(cmd, env=None):
...
@@ -115,42 +109,14 @@ def run_cmdline(cmd, env=None):
start
=
time
.
time
()
start
=
time
.
time
()
masters
,
slaves
=
zip
(
pty
.
openpty
(),
pty
.
openpty
())
p
=
subprocess
.
Popen
(
cmd
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
,
env
=
env
,
bufsize
=
1
,
universal_newlines
=
True
)
with
subprocess
.
Popen
(
cmd
,
stdin
=
slaves
[
0
],
stdout
=
slaves
[
0
],
stderr
=
slaves
[
1
],
env
=
env
)
as
p
:
for
line
in
iter
(
p
.
stdout
.
readline
,
''
):
sys
.
stdout
.
write
(
line
)
for
fd
in
slaves
:
sys
.
stdout
.
flush
()
os
.
close
(
fd
)
# no input
readable
=
{
if
p
.
wait
()
!=
0
:
masters
[
0
]:
sys
.
stdout
.
buffer
,
# store buffers seperately
masters
[
1
]:
sys
.
stderr
.
buffer
,
}
while
readable
:
for
fd
in
select
.
select
(
readable
,
[],
[])[
0
]:
try
:
data
=
os
.
read
(
fd
,
1024
)
# read available
except
OSError
as
e
:
if
e
.
errno
!=
errno
.
EIO
:
raise
#XXX cleanup
del
readable
[
fd
]
# EIO means EOF on some systems
else
:
if
not
data
:
# EOF
del
readable
[
fd
]
else
:
if
fd
==
masters
[
0
]:
# We caught stdout
print
(
data
.
rstrip
().
decode
(
sys
.
stdout
.
encoding
))
else
:
# We caught stderr
print
(
data
.
rstrip
().
decode
(
sys
.
stderr
.
encoding
))
readable
[
fd
].
flush
()
for
fd
in
masters
:
os
.
close
(
fd
)
if
p
.
returncode
!=
0
:
raise
RuntimeError
(
"
command `%s
'
exited with error state (%d)
"
%
\
raise
RuntimeError
(
"
command `%s
'
exited with error state (%d)
"
%
\
(
'
'
.
join
(
cmd
),
p
.
returncode
))
(
'
'
.
join
(
cmd
),
p
.
returncode
))
...
@@ -159,6 +125,7 @@ def run_cmdline(cmd, env=None):
...
@@ -159,6 +125,7 @@ def run_cmdline(cmd, env=None):
logger
.
info
(
'
command took %s
'
%
human_time
(
total
))
logger
.
info
(
'
command took %s
'
%
human_time
(
total
))
def
touch
(
path
):
def
touch
(
path
):
'''
Python-implementation of the
"
touch
"
command-line application
'''
'''
Python-implementation of the
"
touch
"
command-line application
'''
...
...
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