Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Carlos Ramos Carreño
erp5
Commits
829c040a
Commit
829c040a
authored
Oct 27, 2011
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update lamp recipe and remove MySQLdb dependance
parent
f009116a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
53 additions
and
125 deletions
+53
-125
slapos/recipe/lamp/__init__.py
slapos/recipe/lamp/__init__.py
+30
-23
slapos/recipe/lamp/runner.py
slapos/recipe/lamp/runner.py
+20
-75
software/prestashop/template/prestashop.inc.php.in
software/prestashop/template/prestashop.inc.php.in
+0
-25
stack/lamp.cfg
stack/lamp.cfg
+3
-2
No files found.
slapos/recipe/lamp/__init__.py
View file @
829c040a
...
...
@@ -157,16 +157,29 @@ class BaseRecipe(BaseSlapRecipe):
"""Start process which can launch python scripts, move or remove files or
directories when installing software.
"""
if
not
self
.
options
.
has_key
(
'delete'
)
and
not
\
self
.
options
.
has_key
(
'
rename
'
)
and
not
self
.
options
.
has_key
(
'script'
):
if
not
self
.
options
.
has_key
(
'delete'
)
and
not
self
.
options
.
has_key
(
'rename'
)
and
not
\
self
.
options
.
has_key
(
'
chmod
'
)
and
not
self
.
options
.
has_key
(
'script'
):
return
delete
=
[]
chmod
=
[]
data
=
[]
rename
=
[]
rename_list
=
""
data
=
{}
if
self
.
options
.
has_key
(
'delete'
):
argument
=
[
self
.
options
[
'lampconfigure_directory'
].
strip
()]
if
not
self
.
options
.
has_key
(
'file_token'
):
argument
=
argument
+
[
"-d"
,
mysql_conf
[
'mysql_database'
],
"-H"
,
mysql_conf
[
'mysql_host'
],
"-P"
,
mysql_conf
[
'mysql_port'
],
"-p"
,
mysql_conf
[
'mysql_password'
],
"-u"
,
mysql_conf
[
'mysql_user'
],
"--table"
,
self
.
options
[
'table_name'
].
strip
(),
"--cond"
,
self
.
options
[
'constraint'
].
strip
()]
else
:
argument
=
argument
+
[
"-f"
,
self
.
options
[
'file_token'
].
strip
()]
argument
+=
[
"-t"
,
document_root
]
if
self
.
options
.
has_key
(
'delete'
):
delete
=
[
"delete"
]
for
fname
in
self
.
options
[
'delete'
].
split
(
','
):
delete
.
append
(
os
.
path
.
join
(
document_root
,
fname
.
strip
()
))
delete
.
append
(
fname
.
strip
(
))
if
self
.
options
.
has_key
(
'rename'
):
for
fname
in
self
.
options
[
'rename'
].
split
(
','
):
if
fname
.
find
(
"=>"
)
<
0
:
...
...
@@ -176,28 +189,22 @@ class BaseRecipe(BaseSlapRecipe):
fname
.
append
(
old_name
+
'-'
+
mysql_conf
[
'mysql_user'
])
else
:
fname
=
fname
.
split
(
"=>"
)
rename
.
append
(
dict
(
old
=
os
.
path
.
join
(
document_root
,
fname
[
0
].
strip
()),
new
=
os
.
path
.
join
(
document_root
,
fname
[
1
].
strip
())
))
rename_list
+=
fname
[
0
]
+
"=> "
+
fname
[
1
]
+
", "
if
not
self
.
options
.
has_key
(
'file_token'
):
token
=
dict
(
table
=
self
.
options
[
'table_name'
].
strip
(),
constraint
=
self
.
options
[
'constraint'
].
strip
()
)
else
:
token
=
os
.
path
.
join
(
document_root
,
self
.
options
[
'file_token'
].
strip
())
cmd
=
[
"rename"
]
if
self
.
options
.
has_key
(
'rename_chmod'
):
cmd
+=
[
"--chmod"
,
self
.
options
[
'rename_chmod'
].
strip
()]
rename
.
append
(
cmd
+
[
fname
[
0
].
strip
(),
fname
[
1
].
strip
()])
rename_list
+=
fname
[
0
]
+
"=>"
+
fname
[
1
]
+
" "
if
self
.
options
.
has_key
(
'chmod'
):
chmod
=
[
"chmod "
,
self
.
options
[
'mode'
].
strip
()]
for
fname
in
self
.
options
[
'chmod'
].
split
(
','
):
chmod
.
append
(
fname
.
strip
())
if
self
.
options
.
has_key
(
'script'
)
and
\
self
.
options
[
'script'
].
strip
().
endswith
(
".py"
):
data
=
dict
(
htdocs
=
document_root
,
base_url
=
url
,
script
=
self
.
options
[
'script'
].
strip
(),
renamed
=
rename_list
)
data
=
[
"run"
,
self
.
options
[
'script'
].
strip
(),
"-v"
,
base_url
]
self
.
path_list
.
extend
(
zc
.
buildout
.
easy_install
.
scripts
(
[(
'configureInstall'
,
__name__
+
'.runner'
,
'executeRunner'
)],
self
.
ws
,
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
[
delete
,
rename
,
token
,
mysql_conf
,
data
]))
sys
.
executable
,
self
.
wrapper_directory
,
arguments
=
[
argument
,
delete
,
rename
,
chmod
,
data
]))
return
rename_list
class
Static
(
BaseRecipe
):
...
...
slapos/recipe/lamp/runner.py
View file @
829c040a
import
os
import
time
import
sys
import
shutil
import
MySQLdb
import
subprocess
def
executeRunner
(
args
):
"""Start the instance
runner
. this may run a python script, move or/and rename
"""Start the instance
configure
. this may run a python script, move or/and rename
file or directory when dondition is filled. the condition may be when file exist or when an entry
exist into database.
"""
delete
,
rename
,
token
,
mysql_config
,
script_data
=
args
timeout
=
5
;
while
True
:
if
not
checkAction
(
token
,
mysql_config
):
print
"Waiting for 3s and retrying"
time
.
sleep
(
3
)
continue
time
.
sleep
(
timeout
)
for
path
in
delete
:
if
not
os
.
path
.
exists
(
path
):
print
"Error when deleting: '%s': no such file or directory"
%
path
continue
if
os
.
path
.
isdir
(
path
):
shutil
.
rmtree
(
path
)
else
:
os
.
remove
(
path
)
for
data
in
rename
:
if
not
os
.
path
.
exists
(
data
[
'old'
]):
print
"Error when moving: '%s': no such file or directory"
%
data
[
'old'
]
continue
os
.
rename
(
data
[
'old'
],
data
[
'new'
])
if
script_data
!=
{}:
script
=
script_data
[
'script'
]
if
os
.
path
.
exists
(
script
):
import
subprocess
#run python script with predefined data
return_code
=
subprocess
.
call
([
sys
.
executable
,
script
,
script_data
[
'base_url'
],
script_data
[
'htdocs'
],
script_data
[
'renamed'
],
mysql_config
[
'mysql_user'
],
mysql_config
[
'mysql_password'
],
mysql_config
[
'mysql_database'
],
mysql_config
[
'mysql_host'
]])
if
return_code
!=
0
:
print
"Error: execution of script %r failed with code: %s"
%
(
script
,
return_code
)
else
:
print
"Error: can not read file '%s'"
%
script
arguments
,
delete
,
rename
,
chmod
,
data
=
args
if
delete
!=
[]:
print
"Calling lampconfigure with 'delete' arguments"
result
=
subprocess
.
Popen
(
arguments
+
delete
)
result
.
wait
()
if
rename
!=
[]:
for
parameters
in
rename
:
print
"Calling lampconfigure with 'rename' arguments"
result
=
subprocess
.
Popen
(
arguments
+
parameters
)
result
.
wait
()
if
chmod
!=
[]:
print
"Calling lampconfigure with 'chmod' arguments"
result
=
subprocess
.
Popen
(
arguments
+
chmod
)
result
.
wait
()
if
data
!=
[]:
print
"Calling lampconfigure with 'run' arguments"
result
=
subprocess
.
Popen
(
arguments
+
data
)
result
.
wait
()
return
def
checkAction
(
token
,
mysql_config
):
"""Check if condition is filled. If token is string(that represent a path), the function check if file exist
otherwise token is a dictionary and mysql_config is used to check condition into database
"""
if
type
(
token
)
is
dict
:
try
:
conn
=
MySQLdb
.
connect
(
host
=
mysql_config
[
'mysql_host'
],
port
=
int
(
mysql_config
[
'mysql_port'
]),
user
=
mysql_config
[
'mysql_user'
],
passwd
=
mysql_config
[
'mysql_password'
],
db
=
mysql_config
[
'mysql_database'
])
except
:
#Mysql is not ready yet?...
return
False
if
token
[
'table'
]
==
"**"
:
#only detect if mysql has been started
conn
.
close
()
return
True
cursor
=
conn
.
cursor
()
cursor
.
execute
(
"SHOW TABLES LIKE '%"
+
token
[
'table'
]
+
"'"
)
#Check if table has been created
row
=
cursor
.
fetchone
()
if
row
==
None
:
conn
.
close
()
return
False
else
:
token
[
'table'
]
=
row
[
0
]
cursor
.
execute
(
"SELECT * FROM "
+
token
[
'table'
]
+
" WHERE "
+
token
[
'constraint'
])
row
=
cursor
.
fetchone
()
conn
.
close
()
if
row
==
None
:
return
False
else
:
return
True
else
:
return
os
.
path
.
exists
(
token
)
\ No newline at end of file
software/prestashop/template/prestashop.inc.php.in
deleted
100644 → 0
View file @
f009116a
<?php
$cfg
[
'blowfish_secret'
]
=
''
;
/* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
$i
=
0
;
$i
++
;
/* Server parameters */
$cfg
[
'Servers'
][
$i
][
'host'
]
=
'%(mysql_host)s'
;
$cfg
[
'Servers'
][
$i
][
'port'
]
=
'%(mysql_port)s'
;
/* Authentication type */
$cfg
[
'Servers'
][
$i
][
'auth_type'
]
=
'cookie'
;
$cfg
[
'Servers'
][
$i
][
'user'
]
=
''
;
$cfg
[
'Servers'
][
$i
][
'connect_type'
]
=
'tcp'
;
$cfg
[
'Servers'
][
$i
][
'compress'
]
=
false
;
/* Select mysqli if your server has it */
$cfg
[
'Servers'
][
$i
][
'extension'
]
=
'mysql'
;
$cfg
[
'Servers'
][
$i
][
'AllowNoPassword'
]
=
false
;
/* rajk - for blobstreaming */
$cfg
[
'Servers'
][
$i
][
'bs_garbage_threshold'
]
=
50
;
$cfg
[
'Servers'
][
$i
][
'bs_repository_threshold'
]
=
'32M'
;
$cfg
[
'Servers'
][
$i
][
'bs_temp_blob_timeout'
]
=
600
;
$cfg
[
'Servers'
][
$i
][
'bs_temp_log_threshold'
]
=
'32M'
;
$cfg
[
'UploadDir'
]
=
''
;
$cfg
[
'SaveDir'
]
=
''
;
?>
stack/lamp.cfg
View file @
829c040a
...
...
@@ -33,14 +33,15 @@ extends =
../component/python-2.7/buildout.cfg
../component/lxml-python/buildout.cfg
../component/zlib/buildout.cfg
../component/stunnel/buildout.cfg
../component/stunnel/buildout.cfg
../component/pycrypto-python/buildout.cfg
../component/mysql-python/buildout.cfg
[eggs]
recipe = zc.recipe.egg
eggs =
${lxml-python:egg}
${
mysql-python:egg}
${
pycrypto-python:egg}
[application]
#XXX-Cedric : ugly hack to work around h.r.cmmi unrespectful behavior, so that
...
...
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