Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
8
Merge Requests
8
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
slapos.buildout
Commits
defdcec1
Commit
defdcec1
authored
Jun 17, 2006
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added logging support.
parent
eb311a70
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
242 additions
and
54 deletions
+242
-54
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+93
-27
src/zc/buildout/buildout.txt
src/zc/buildout/buildout.txt
+149
-25
todo.txt
todo.txt
+0
-2
No files found.
src/zc/buildout/buildout.py
View file @
defdcec1
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
$Id$
$Id$
"""
"""
import
logging
import
md5
import
md5
import
os
import
os
import
pprint
import
pprint
...
@@ -64,15 +65,17 @@ class Buildout(dict):
...
@@ -64,15 +65,17 @@ class Buildout(dict):
super
(
Buildout
,
self
).
__init__
()
super
(
Buildout
,
self
).
__init__
()
# default options
# default options
data
=
dict
(
buildout
=
{
'directory'
:
os
.
path
.
dirname
(
config_file
),
data
=
dict
(
buildout
=
{
'directory'
:
os
.
path
.
dirname
(
config_file
),
'eggs-directory'
:
'eggs'
,
'eggs-directory'
:
'eggs'
,
'bin-directory'
:
'bin'
,
'bin-directory'
:
'bin'
,
'parts-directory'
:
'parts'
,
'parts-directory'
:
'parts'
,
'installed'
:
'.installed.cfg'
,
'installed'
:
'.installed.cfg'
,
'python'
:
'buildout'
,
'python'
:
'buildout'
,
'executable'
:
sys
.
executable
,
'executable'
:
sys
.
executable
,
},
'log-level'
:
'WARNING'
,
)
'log-format'
:
'%(name)s: %(message)s'
,
})
# load user defaults, which override defaults
# load user defaults, which override defaults
if
'HOME'
in
os
.
environ
:
if
'HOME'
in
os
.
environ
:
...
@@ -116,8 +119,6 @@ class Buildout(dict):
...
@@ -116,8 +119,6 @@ class Buildout(dict):
for
name
in
(
'bin'
,
'parts'
,
'eggs'
):
for
name
in
(
'bin'
,
'parts'
,
'eggs'
):
d
=
self
.
_buildout_path
(
options
[
name
+
'-directory'
])
d
=
self
.
_buildout_path
(
options
[
name
+
'-directory'
])
options
[
name
+
'-directory'
]
=
d
options
[
name
+
'-directory'
]
=
d
if
not
os
.
path
.
exists
(
d
):
os
.
mkdir
(
d
)
options
[
'installed'
]
=
os
.
path
.
join
(
options
[
'directory'
],
options
[
'installed'
]
=
os
.
path
.
join
(
options
[
'directory'
],
options
[
'installed'
])
options
[
'installed'
])
...
@@ -163,6 +164,15 @@ class Buildout(dict):
...
@@ -163,6 +164,15 @@ class Buildout(dict):
return
os
.
path
.
join
(
self
.
_buildout_dir
,
*
names
)
return
os
.
path
.
join
(
self
.
_buildout_dir
,
*
names
)
def
install
(
self
,
install_parts
):
def
install
(
self
,
install_parts
):
# Create buildout directories
for
name
in
(
'bin'
,
'parts'
,
'eggs'
):
d
=
self
[
'buildout'
][
name
+
'-directory'
]
if
not
os
.
path
.
exists
(
d
):
self
.
_logger
.
info
(
'Creating directory %s'
,
d
)
os
.
mkdir
(
d
)
# Build develop eggs
self
.
_develop
()
self
.
_develop
()
# load installed data
# load installed data
...
@@ -181,7 +191,7 @@ class Buildout(dict):
...
@@ -181,7 +191,7 @@ class Buildout(dict):
if
install_parts
:
if
install_parts
:
extra
=
[
p
for
p
in
install_parts
if
p
not
in
conf_parts
]
extra
=
[
p
for
p
in
install_parts
if
p
not
in
conf_parts
]
if
extra
:
if
extra
:
error
(
'Invalid install parts:'
,
*
extra
)
self
.
_
error
(
'Invalid install parts:'
,
*
extra
)
uninstall_missing
=
False
uninstall_missing
=
False
else
:
else
:
install_parts
=
conf_parts
install_parts
=
conf_parts
...
@@ -206,12 +216,14 @@ class Buildout(dict):
...
@@ -206,12 +216,14 @@ class Buildout(dict):
continue
continue
# ununstall part
# ununstall part
self
.
_logger
.
info
(
'Uninstalling %s'
,
part
)
self
.
_uninstall
(
self
.
_uninstall
(
installed_part_options
[
part
][
'__buildout_installed__'
])
installed_part_options
[
part
][
'__buildout_installed__'
])
installed_parts
=
[
p
for
p
in
installed_parts
if
p
!=
part
]
installed_parts
=
[
p
for
p
in
installed_parts
if
p
!=
part
]
# install new parts
# install new parts
for
part
in
install_parts
:
for
part
in
install_parts
:
self
.
_logger
.
info
(
'Installing %s'
,
part
)
installed_part_options
[
part
]
=
self
[
part
].
copy
()
installed_part_options
[
part
]
=
self
[
part
].
copy
()
del
self
[
part
][
'__buildout_signature__'
]
del
self
[
part
][
'__buildout_signature__'
]
installed_files
=
recipes
[
part
].
install
()
or
()
installed_files
=
recipes
[
part
].
install
()
or
()
...
@@ -241,7 +253,7 @@ class Buildout(dict):
...
@@ -241,7 +253,7 @@ class Buildout(dict):
setup
=
self
.
_buildout_path
(
setup
)
setup
=
self
.
_buildout_path
(
setup
)
if
os
.
path
.
isdir
(
setup
):
if
os
.
path
.
isdir
(
setup
):
setup
=
os
.
path
.
join
(
setup
,
'setup.py'
)
setup
=
os
.
path
.
join
(
setup
,
'setup.py'
)
self
.
_logger
.
info
(
"Running %s -q develop ..."
,
setup
)
os
.
chdir
(
os
.
path
.
dirname
(
setup
))
os
.
chdir
(
os
.
path
.
dirname
(
setup
))
os
.
spawnle
(
os
.
spawnle
(
os
.
P_WAIT
,
sys
.
executable
,
sys
.
executable
,
os
.
P_WAIT
,
sys
.
executable
,
sys
.
executable
,
...
@@ -349,6 +361,33 @@ class Buildout(dict):
...
@@ -349,6 +361,33 @@ class Buildout(dict):
_save_options
(
part
,
installed_options
[
part
],
f
)
_save_options
(
part
,
installed_options
[
part
],
f
)
f
.
close
()
f
.
close
()
def
_error
(
self
,
message
,
*
args
,
**
kw
):
self
.
_logger
.
error
(
message
,
*
args
,
**
kw
)
sys
.
exit
(
1
)
def
_setup_logging
(
self
):
root_logger
=
logging
.
getLogger
()
handler
=
logging
.
StreamHandler
(
sys
.
stdout
)
handler
.
setFormatter
(
logging
.
Formatter
(
self
[
'buildout'
][
'log-format'
]))
root_logger
.
addHandler
(
handler
)
self
.
_logger
=
logging
.
getLogger
(
'buildout'
)
level
=
self
[
'buildout'
][
'log-level'
]
if
level
in
(
'DEBUG'
,
'INFO'
,
'WARNING'
,
'ERROR'
,
'CRITICAL'
):
level
=
getattr
(
logging
,
level
)
else
:
try
:
level
=
int
(
level
)
except
ValueError
:
self
.
_error
(
"Invalid logging level %s"
,
level
)
verbosity
=
self
[
'buildout'
].
get
(
'verbosity'
,
0
)
try
:
verbosity
=
int
(
verbosity
)
except
ValueError
:
self
.
_error
(
"Invalid verbosity %s"
,
verbosity
)
root_logger
.
setLevel
(
level
-
verbosity
)
def
_save_options
(
section
,
options
,
f
):
def
_save_options
(
section
,
options
,
f
):
print
>>
f
,
'[%s]'
%
section
print
>>
f
,
'[%s]'
%
section
items
=
options
.
items
()
items
=
options
.
items
()
...
@@ -435,23 +474,47 @@ def _error(*message):
...
@@ -435,23 +474,47 @@ def _error(*message):
def
main
(
args
=
None
):
def
main
(
args
=
None
):
if
args
is
None
:
if
args
is
None
:
args
=
sys
.
argv
[
1
:]
args
=
sys
.
argv
[
1
:]
if
args
and
args
[
0
]
==
'-c'
:
args
.
pop
(
0
)
if
not
args
:
_error
(
"No configuration file specified,"
)
config_file
=
args
.
pop
(
0
)
else
:
config_file
=
'buildout.cfg'
config_file
=
'buildout.cfg'
verbosity
=
0
options
=
[]
options
=
[]
while
args
and
'='
in
args
[
0
]:
while
args
:
if
args
[
0
][
0
]
==
'-'
:
op
=
orig_op
=
args
.
pop
(
0
)
op
=
op
[
1
:]
while
op
and
op
[
0
]
in
'vq'
:
if
op
[
0
]
==
'v'
:
verbosity
+=
10
else
:
verbosity
-=
10
op
=
op
[
1
:]
if
op
[:
1
]
==
'c'
:
op
=
op
[
1
:]
if
op
:
config_file
=
op
else
:
if
args
:
config_file
=
args
.
pop
(
0
)
else
:
_error
(
"No file name specified for option"
,
orig_op
)
elif
op
:
_error
(
"Invalid option"
,
'-'
+
op
[
0
])
elif
'='
in
args
[
0
]:
option
,
value
=
args
.
pop
(
0
).
split
(
'='
,
1
)
option
,
value
=
args
.
pop
(
0
).
split
(
'='
,
1
)
if
len
(
option
.
split
(
':'
))
!=
2
:
if
len
(
option
.
split
(
':'
))
!=
2
:
_error
(
'Invalid option:'
,
option
)
_error
(
'Invalid option:'
,
option
)
section
,
option
=
option
.
split
(
':'
)
section
,
option
=
option
.
split
(
':'
)
options
.
append
((
section
.
strip
(),
option
.
strip
(),
value
.
strip
()))
options
.
append
((
section
.
strip
(),
option
.
strip
(),
value
.
strip
()))
else
:
# We've run out of command-line options and option assignnemnts
# The rest should be commands, so we'll stop here
break
if
verbosity
:
options
.
append
((
'buildout'
,
'verbosity'
,
str
(
verbosity
)))
buildout
=
Buildout
(
config_file
,
options
)
buildout
=
Buildout
(
config_file
,
options
)
buildout
.
_setup_logging
()
if
args
:
if
args
:
command
=
args
.
pop
(
0
)
command
=
args
.
pop
(
0
)
...
@@ -460,7 +523,10 @@ def main(args=None):
...
@@ -460,7 +523,10 @@ def main(args=None):
else
:
else
:
command
=
'install'
command
=
'install'
try
:
getattr
(
buildout
,
command
)(
args
)
getattr
(
buildout
,
command
)(
args
)
finally
:
logging
.
shutdown
()
if
sys
.
version_info
[:
2
]
<
(
2
,
4
):
if
sys
.
version_info
[:
2
]
<
(
2
,
4
):
def
reversed
(
iterable
):
def
reversed
(
iterable
):
...
...
src/zc/buildout/buildout.txt
View file @
defdcec1
This diff is collapsed.
Click to expand it.
todo.txt
View file @
defdcec1
...
@@ -24,8 +24,6 @@
...
@@ -24,8 +24,6 @@
- Local download cache
- Local download cache
- Logging
- Some way to freeze versions so we can have reproducable buildouts.
- Some way to freeze versions so we can have reproducable buildouts.
- Part dependencies
- Part dependencies
...
...
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