Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Chromium_Depot_tools
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
Chromium_Depot_tools
Commits
9a0de0b9
Commit
9a0de0b9
authored
Jul 14, 2016
by
hinoka
Committed by
Commit bot
Jul 14, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add cipd binary support to cit.py
BUG= Review-Url:
https://codereview.chromium.org/2117943002
parent
a543853d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
11 deletions
+45
-11
cit.py
cit.py
+45
-11
No files found.
cit.py
View file @
9a0de0b9
...
...
@@ -9,6 +9,7 @@
This tool does a two things:
* Maintains a infra.git checkout pinned at "deployed" in the home dir
* Acts as an alias to infra.tools.*
* Acts as an alias to infra.git/cipd/<executable>
"""
# TODO(hinoka): Use cipd/glyco instead of git/gclient.
...
...
@@ -75,34 +76,67 @@ def ensure_infra(branch):
sys
.
stderr
.
flush
()
def
is_exe
(
filename
):
"""Given a full filepath, return true if the file is an executable."""
if
sys
.
platform
.
startswith
(
'win'
):
return
filename
.
endswith
(
'.exe'
)
else
:
return
os
.
path
.
isfile
(
filename
)
and
os
.
access
(
filename
,
os
.
X_OK
)
def
get_available_tools
():
tools
=
[]
"""Returns a tuple of (list of infra tools, list of cipd tools)"""
infra_tools
=
[]
cipd_tools
=
[]
starting
=
os
.
path
.
join
(
TARGET_DIR
,
'infra'
,
'infra'
,
'tools'
)
for
root
,
_
,
files
in
os
.
walk
(
starting
):
if
'__main__.py'
in
files
:
tools
.
append
(
root
[
len
(
starting
)
+
1
:]
.
replace
(
os
.
path
.
sep
,
'.'
))
return
sorted
(
tools
)
infra_tools
.
append
(
root
[
len
(
starting
)
+
1
:]
.
replace
(
os
.
path
.
sep
,
'.'
))
cipd
=
os
.
path
.
join
(
TARGET_DIR
,
'infra'
,
'cipd'
)
for
fn
in
os
.
listdir
(
cipd
):
if
is_exe
(
os
.
path
.
join
(
cipd
,
fn
)):
cipd_tools
.
append
(
fn
)
return
(
sorted
(
infra_tools
),
sorted
(
cipd_tools
))
def
run
(
args
):
if
args
:
tool_name
=
args
[
0
]
cmd
=
[
sys
.
executable
,
os
.
path
.
join
(
TARGET_DIR
,
'infra'
,
'run.py'
),
'infra.tools.
%
s'
%
tool_name
]
# Check to see if it is a infra tool first.
infra_dir
=
os
.
path
.
join
(
TARGET_DIR
,
'infra'
,
'infra'
,
'tools'
,
*
tool_name
.
split
(
'.'
))
cipd_file
=
os
.
path
.
join
(
TARGET_DIR
,
'infra'
,
'cipd'
,
tool_name
)
if
sys
.
platform
.
startswith
(
'win'
):
cipd_file
+=
'.exe'
if
(
os
.
path
.
isdir
(
infra_dir
)
and
os
.
path
.
isfile
(
os
.
path
.
join
(
infra_dir
,
'__main__.py'
))):
cmd
=
[
sys
.
executable
,
os
.
path
.
join
(
TARGET_DIR
,
'infra'
,
'run.py'
),
'infra.tools.
%
s'
%
tool_name
]
elif
os
.
path
.
isfile
(
cipd_file
)
and
is_exe
(
cipd_file
):
cmd
=
[
cipd_file
]
# Add the remaining arguments.
cmd
.
extend
(
args
[
1
:])
return
subprocess
.
call
(
cmd
)
tools
=
get_available_tools
()
infra_tools
,
cipd_
tools
=
get_available_tools
()
print
"""usage: cit.py <name of tool> [args for tool]
Wrapper for maintaining and calling tools in "infra.git/run.py infra.tools.*"
Wrapper for maintaining and calling tools in:
"infra.git/run.py infra.tools.*"
"infra.git/cipd/*"
Available tools are:
"""
for
tool
in
tools
:
Available infra tools are:"""
for
tool
in
infra_tools
:
print
' *
%
s'
%
tool
print
"""
Available cipd tools are:"""
for
tool
in
cipd_tools
:
print
' *
%
s'
%
tool
def
main
():
parser
=
argparse
.
ArgumentParser
(
"Chrome Infrastructure CLI."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment