Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
H
Hdlmake
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
15
Issues
15
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Hdlmake
Commits
caa17392
Commit
caa17392
authored
May 23, 2017
by
Javier D. Garcia-Lasheras
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Create a function to execute processes in the O.S. specific shell
parent
e773bd4b
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
90 deletions
+36
-90
action.py
hdlmake/action/action.py
+3
-16
fetcher.py
hdlmake/fetch/fetcher.py
+3
-27
git.py
hdlmake/fetch/git.py
+7
-34
module.py
hdlmake/module/module.py
+2
-13
shell.py
hdlmake/util/shell.py
+21
-0
No files found.
hdlmake/action/action.py
View file @
caa17392
...
...
@@ -26,7 +26,6 @@ from __future__ import print_function
from
__future__
import
absolute_import
import
os
import
logging
from
subprocess
import
PIPE
,
Popen
import
sys
from
hdlmake.util
import
shell
...
...
@@ -192,23 +191,11 @@ class Action(list):
"""Guess origin (git, svn, local) of a module at given path"""
cwd
=
self
.
top_module
.
path
try
:
is_windows
=
shell
.
check_windows
()
os
.
chdir
(
path
)
git_out
=
Popen
(
"git config --get remote.origin.url"
,
stdout
=
PIPE
,
shell
=
True
,
close_fds
=
not
is_windows
)
lines
=
git_out
.
stdout
.
readlines
()
if
len
(
lines
)
==
0
:
return
None
url
=
lines
[
0
]
.
strip
()
url
=
shell
.
run
(
"git config --get remote.origin.url"
)
if
not
url
:
# try svn
svn_out
=
Popen
(
"svn info | grep 'Repository Root' | awk '{print $NF}'"
,
stdout
=
PIPE
,
shell
=
True
,
close_fds
=
not
is_windows
)
url
=
svn_out
.
stdout
.
readlines
()[
0
]
.
strip
()
if
url
:
return
url
else
:
return
None
return
shell
.
run
(
"svn info | grep 'Repository Root' | "
+
"awk '{print $NF}'"
)
else
:
return
url
finally
:
...
...
hdlmake/fetch/fetcher.py
View file @
caa17392
...
...
@@ -24,9 +24,6 @@
from
__future__
import
absolute_import
import
os
from
hdlmake.util
import
shell
import
logging
from
tempfile
import
TemporaryFile
from
subprocess
import
Popen
,
PIPE
class
Fetcher
(
object
):
...
...
@@ -42,28 +39,7 @@ class Fetcher(object):
"""Use the provided command to get the specific ID from
the repository at path"""
cur_dir
=
os
.
getcwd
()
identifier
=
None
stderr
=
TemporaryFile
()
try
:
is_windows
=
shell
.
check_windows
()
os
.
chdir
(
path
)
command_out
=
Popen
(
command
,
shell
=
True
,
stdin
=
PIPE
,
stdout
=
PIPE
,
stderr
=
stderr
,
close_fds
=
not
is_windows
)
errmsg
=
stderr
.
readlines
()
if
errmsg
:
logging
.
debug
(
"ID error message (in
%
s):
%
s"
,
path
,
'
\n
'
.
join
(
errmsg
))
try
:
identifier
=
command_out
.
stdout
.
readlines
()[
0
]
.
strip
()
except
IndexError
:
pass
finally
:
os
.
chdir
(
cur_dir
)
stderr
.
close
()
os
.
chdir
(
path
)
identifier
=
shell
.
run
(
command
)
os
.
chdir
(
cur_dir
)
return
identifier
hdlmake/fetch/git.py
View file @
caa17392
...
...
@@ -26,7 +26,6 @@ import os
from
hdlmake.util
import
path
as
path_utils
from
hdlmake.util
import
shell
import
logging
from
subprocess
import
Popen
,
PIPE
,
CalledProcessError
from
.constants
import
GIT
from
.fetcher
import
Fetcher
...
...
@@ -42,43 +41,17 @@ class Git(Fetcher):
@
staticmethod
def
get_git_toplevel
():
"""Get the top level for the Git repository"""
try
:
tree_root_cmd
=
Popen
(
"git rev-parse --show-toplevel"
,
stdout
=
PIPE
,
stdin
=
PIPE
,
close_fds
=
not
shell
.
check_windows
(),
shell
=
True
)
tree_root_line
=
tree_root_cmd
.
stdout
.
readlines
()[
0
]
.
strip
()
return
tree_root_line
except
CalledProcessError
as
process_error
:
logging
.
error
(
"Cannot get the top level!:
%
s"
,
process_error
.
output
)
quit
()
return
shell
.
run
(
"git rev-parse --show-toplevel"
)
@
staticmethod
def
get_submodule_commit
(
submodule_dir
):
"""Get the commit for a repository if defined in Git submodules"""
try
:
command_tmp
=
"git submodule status
%
s"
%
submodule_dir
status_cmd
=
Popen
(
command_tmp
,
stdout
=
PIPE
,
stdin
=
PIPE
,
stderr
=
PIPE
,
close_fds
=
not
shell
.
check_windows
(),
shell
=
True
)
status_output
=
status_cmd
.
stdout
.
readlines
()
if
len
(
status_output
)
==
1
:
status_line
=
status_output
[
0
]
.
split
()
if
len
(
status_line
)
==
2
:
return
status_line
[
0
][
1
:]
else
:
return
None
else
:
return
None
except
CalledProcessError
as
process_error
:
logging
.
error
(
"Cannot get the submodule status!:
%
s"
,
process_error
.
output
)
quit
()
status_line
=
shell
.
run
(
"git submodule status
%
s"
%
submodule_dir
)
status_line
=
status_line
.
split
()
if
len
(
status_line
)
==
2
:
return
status_line
[
0
][
1
:]
else
:
return
None
def
fetch
(
self
,
module
):
"""Get the code from the remote Git repository"""
...
...
hdlmake/module/module.py
View file @
caa17392
...
...
@@ -31,7 +31,6 @@ from __future__ import print_function
from
__future__
import
absolute_import
import
os
import
logging
from
subprocess
import
Popen
,
PIPE
,
CalledProcessError
from
hdlmake.util
import
path
as
path_mod
from
hdlmake.util
import
shell
...
...
@@ -103,18 +102,8 @@ class Module(ModuleContent):
if
not
self
.
isfetched
:
return
logging
.
debug
(
"Removing "
+
self
.
path
)
try
:
command_tmp
=
shell
.
rmdir_command
()
+
" "
+
self
.
path
Popen
(
command_tmp
,
stdout
=
PIPE
,
stdin
=
PIPE
,
stderr
=
PIPE
,
close_fds
=
not
shell
.
check_windows
(),
shell
=
True
)
except
CalledProcessError
as
process_error
:
logging
.
error
(
"Cannot clean the module:
%
s"
,
process_error
.
output
)
quit
()
command_tmp
=
shell
.
rmdir_command
()
+
" "
+
self
.
path
shell
.
run
(
command_tmp
)
def
process_manifest
(
self
):
"""
...
...
hdlmake/util/shell.py
View file @
caa17392
...
...
@@ -27,6 +27,27 @@ from __future__ import absolute_import
import
os
import
sys
import
platform
import
logging
from
subprocess
import
PIPE
,
Popen
,
CalledProcessError
def
run
(
command
):
"""Execute a command in the shell and print the output lines as a list"""
try
:
command_out
=
Popen
(
command
,
stdout
=
PIPE
,
stdin
=
PIPE
,
stderr
=
PIPE
,
close_fds
=
not
check_windows
(),
shell
=
True
)
lines
=
command_out
.
stdout
.
readlines
()
if
len
(
lines
)
==
0
:
return
None
return
lines
[
0
]
.
strip
()
except
CalledProcessError
as
process_error
:
logging
.
error
(
"Cannot clean the module:
%
s"
,
process_error
.
output
)
quit
()
def
tclpath
(
path
):
...
...
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