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
befa5a90
Commit
befa5a90
authored
Oct 01, 2013
by
Paweł Szostek
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fetcher: go back to a directory after chdir
parent
af468dec
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
28 deletions
+59
-28
backend_factory.py
hdlmake/fetch/backend_factory.py
+2
-1
fetcher.py
hdlmake/fetch/fetcher.py
+25
-0
git.py
hdlmake/fetch/git.py
+30
-26
svn.py
hdlmake/fetch/svn.py
+2
-1
No files found.
hdlmake/fetch/backend_factory.py
View file @
befa5a90
...
...
@@ -23,9 +23,10 @@ from git import (Git, GitSubmodule)
from
svn
import
Svn
import
logging
import
fetch
from
fetcher
import
Fetcher
class
Local
(
object
):
class
Local
(
Fetcher
):
def
__init__
(
self
):
pass
...
...
hdlmake/fetch/fetcher.py
0 → 100644
View file @
befa5a90
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# Copyright (c) 2013 CERN
# Author: Pawel Szostek (pawel.szostek@cern.ch)
#
# This file is part of Hdlmake.
#
# Hdlmake is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Hdlmake is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Hdlmake. If not, see <http://www.gnu.org/licenses/>.
class
Fetcher
(
object
):
def
fetch
(
self
,
module
):
pass
\ No newline at end of file
hdlmake/fetch/git.py
View file @
befa5a90
...
...
@@ -25,9 +25,10 @@ import logging
from
tempfile
import
TemporaryFile
from
subprocess
import
Popen
,
PIPE
import
fetch
from
fetcher
import
Fetcher
class
GitSubmodule
(
object
):
class
GitSubmodule
(
Fetcher
):
def
fetch
(
self
,
module
):
if
module
.
source
!=
fetch
.
GITSUBMODULE
:
raise
ValueError
(
"This backend should get git modules only."
)
...
...
@@ -38,7 +39,7 @@ class GitSubmodule(object):
os
.
chdir
(
cur_dir
)
class
Git
(
object
):
class
Git
(
Fetcher
):
def
__init__
(
self
):
pass
...
...
@@ -46,31 +47,34 @@ class Git(object):
def
get_git_submodules
(
module
):
submodule_dir
=
path
.
rel2abs
(
module
.
path
)
logging
.
debug
(
"Checking git submodules in
%
s"
%
submodule_dir
)
curdir
=
os
.
getcwd
()
os
.
chdir
(
submodule_dir
)
#"git config --list" | grep submodule | sed 's/.*=//')" % submodule_dir
config_content
=
Popen
(
"git config --list"
,
stdout
=
PIPE
,
stdin
=
PIPE
,
shell
=
True
)
config_lines
=
[
line
.
strip
()
for
line
in
config_content
.
stdout
.
readlines
()]
config_submodule_lines
=
[
line
for
line
in
config_lines
if
"submodule"
in
line
]
config_submodules
=
[
line
.
split
(
"="
)[
-
1
]
for
line
in
config_submodule_lines
]
#"(cd %s && cat ./.gitmodules 2>/dev/null | grep url | sed 's/url = //')" % submodule_dir
cur_dir
=
os
.
getcwd
()
try
:
dotgitmodules_file
=
open
(
".gitmodules"
,
'r'
)
dotgitmodules_lines
=
dotgitmodules_file
.
readlines
()
url_lines
=
[
line
for
line
in
dotgitmodules_lines
if
'url'
in
line
]
dotgitmodules_submodules
=
[
line
.
split
(
" = "
)[
-
1
]
.
strip
()
for
line
in
url_lines
]
set
(
config_submodules
)
.
update
(
set
(
dotgitmodules_submodules
))
except
IOError
:
pass
# no .gitmodules file
submodules
=
list
(
config_submodules
)
if
len
(
submodules
)
>
0
:
logging
.
info
(
"Found git submodules in
%
s"
%
module
.
path
)
os
.
chdir
(
submodule_dir
)
#"git config --list" | grep submodule | sed 's/.*=//')" % submodule_dir
config_content
=
Popen
(
"git config --list"
,
stdout
=
PIPE
,
stdin
=
PIPE
,
shell
=
True
)
config_lines
=
[
line
.
strip
()
for
line
in
config_content
.
stdout
.
readlines
()]
config_submodule_lines
=
[
line
for
line
in
config_lines
if
"submodule"
in
line
]
config_submodules
=
[
line
.
split
(
"="
)[
-
1
]
for
line
in
config_submodule_lines
]
#"(cd %s && cat ./.gitmodules 2>/dev/null | grep url | sed 's/url = //')" % submodule_dir
try
:
dotgitmodules_file
=
open
(
".gitmodules"
,
'r'
)
dotgitmodules_lines
=
dotgitmodules_file
.
readlines
()
url_lines
=
[
line
for
line
in
dotgitmodules_lines
if
'url'
in
line
]
dotgitmodules_submodules
=
[
line
.
split
(
" = "
)[
-
1
]
.
strip
()
for
line
in
url_lines
]
set
(
config_submodules
)
.
update
(
set
(
dotgitmodules_submodules
))
except
IOError
:
pass
# no .gitmodules file
submodules
=
list
(
config_submodules
)
if
len
(
submodules
)
>
0
:
logging
.
info
(
"Found git submodules in
%
s"
%
module
.
path
)
finally
:
os
.
chdir
(
cur_dir
)
return
submodules
def
fetch
(
self
,
module
):
...
...
hdlmake/fetch/svn.py
View file @
befa5a90
...
...
@@ -24,9 +24,10 @@ import logging
from
tempfile
import
TemporaryFile
from
util
import
path
from
subprocess
import
Popen
,
PIPE
from
fetcher
import
Fetcher
class
Svn
(
object
):
class
Svn
(
Fetcher
):
def
__init__
(
self
):
pass
...
...
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