Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Vincent Bechu
slapos
Commits
ac96ce51
Commit
ac96ce51
authored
Nov 02, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
track multiple callbacks
parent
bcd98f53
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
5 deletions
+23
-5
slapos/recipe/librecipe/generic.py
slapos/recipe/librecipe/generic.py
+18
-1
slapos/recipe/notifier.py
slapos/recipe/notifier.py
+5
-4
No files found.
slapos/recipe/librecipe/generic.py
View file @
ac96ce51
# -*- coding: utf-8 -*-
# vim: set et sts=2:
##############################################################################
##############################################################################
#
#
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
# Copyright (c) 2010 Vifib SARL and Contributors. All Rights Reserved.
...
@@ -24,6 +26,7 @@
...
@@ -24,6 +26,7 @@
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#
##############################################################################
##############################################################################
import
io
import
logging
import
logging
import
os
import
os
import
sys
import
sys
...
@@ -90,6 +93,21 @@ class GenericBaseRecipe(object):
...
@@ -90,6 +93,21 @@ class GenericBaseRecipe(object):
def
createExecutable
(
self
,
name
,
content
,
mode
=
0700
):
def
createExecutable
(
self
,
name
,
content
,
mode
=
0700
):
return
self
.
createFile
(
name
,
content
,
mode
)
return
self
.
createFile
(
name
,
content
,
mode
)
def
addLineToFile
(
self
,
filepath
,
line
,
encoding
=
'utf8'
):
"""Append a single line to a text file, if the line does not exist yet.
line must be unicode."""
try
:
lines
=
io
.
open
(
filepath
,
'r'
,
encoding
=
encoding
).
readlines
()
except
IOError
:
lines
=
[]
if
not
line
in
lines
:
lines
.
append
(
line
)
with
io
.
open
(
filepath
,
'w+'
,
encoding
=
encoding
)
as
f
:
f
.
write
(
u'
\
n
'
.
join
(
lines
))
def
createPythonScript
(
self
,
name
,
absolute_function
,
arguments
=
''
):
def
createPythonScript
(
self
,
name
,
absolute_function
,
arguments
=
''
):
"""Create a python script using zc.buildout.easy_install.scripts
"""Create a python script using zc.buildout.easy_install.scripts
...
@@ -115,7 +133,6 @@ class GenericBaseRecipe(object):
...
@@ -115,7 +133,6 @@ class GenericBaseRecipe(object):
Takes care of quoting.
Takes care of quoting.
"""
"""
q
=
shlex
.
quote
lines
=
[
lines
=
[
'#!/bin/sh'
,
'#!/bin/sh'
,
'exec %s'
%
shlex
.
quote
(
command
)
'exec %s'
%
shlex
.
quote
(
command
)
...
...
slapos/recipe/notifier.py
View file @
ac96ce51
...
@@ -47,12 +47,13 @@ class Callback(GenericBaseRecipe):
...
@@ -47,12 +47,13 @@ class Callback(GenericBaseRecipe):
def
createCallback
(
self
,
notification_id
,
callback
):
def
createCallback
(
self
,
notification_id
,
callback
):
callback_id
=
sha512
(
notification_id
).
hexdigest
()
callback_id
=
sha512
(
notification_id
).
hexdigest
()
callback
=
self
.
createFile
(
os
.
path
.
join
(
self
.
options
[
'callbacks'
],
callback_id
),
filepath
=
os
.
path
.
join
(
self
.
options
[
'callbacks'
],
callback_id
)
callback
)
self
.
addLineToFile
(
filepath
,
callback
)
return
callback
return
filepath
def
install
(
self
):
def
install
(
self
):
# XXX this path is returned multiple times, one for each callback that has been added.
return
[
self
.
createCallback
(
self
.
options
[
'on-notification-id'
],
return
[
self
.
createCallback
(
self
.
options
[
'on-notification-id'
],
self
.
options
[
'callback'
])]
self
.
options
[
'callback'
])]
...
...
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