-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPKG-INFO
144 lines (107 loc) · 4.66 KB
/
PKG-INFO
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
Metadata-Version: 1.0
Name: cp.recipe.cmd
Version: 0.2
Summary: ZC Buildout recipe to execute a commande line in it's own shell
Home-page: cp.recipe.cmd
Author: YUHSD #70
Author-email: [email protected]
License: GPL
Description: =====================
cp.recipe.cmd package
=====================
.. contents::
What is cp.recipe.cmd ?
=======================
This recipe is used to run one or more command lines.
I stole this from iw.recipe.cmd (http://pypi.python.org/pypi/iw.recipe.cmd/0.1)
It works differently tho, when it comes to executing shell commands. iw.recipe.cmd would push each command out separately in it's own shell. Here I push them out to a shell script, and then run the shell script. This way things like CD and other things that require state within the shell work great.
Also, I changed the way it works in the config file.
we have 2 options in the command.
[commandexample]
recipe = cp.recipe.cmd
install_cmds =
echo "install commands go here"
cd /tmp
echo `pwd`
echo 'see, I exist in one shell instance.'
update_cmds =
echo "update commands go here"
On install, install_cmds will be turned into a shell script, and then ran.
on update, update_cmds will be turned into a shell script and then ran. If you want update_cmds to be the same you can do something like this:
update_cmds = ${commandexample:install_cmd}
(where commandexample is the name of your part)
python code execution is unchanged in this version, and below are the original docs.
We need a config file::
>>> cfg = """
... [buildout]
... parts = cmds
...
... [cmds]
... recipe = iw.recipe.cmd
... on_install=true
... cmds= %s
... """
>>> test_file = join(sample_buildout, 'test.txt')
>>> cmds = 'touch %s' % test_file
>>> write(sample_buildout, 'buildout.cfg', cfg % cmds)
Ok, so now we can touch a file for testing::
>>> print system(buildout)
Installing cmds.
>>> 'test.txt' in os.listdir(sample_buildout)
True
And remove it::
>>> test_file = join(sample_buildout, 'test.txt')
>>> cmds = 'rm -f %s' % test_file
>>> write(sample_buildout, 'buildout.cfg', cfg % cmds)
>>> print system(buildout)
Uninstalling cmds.
Installing cmds.
>>> 'test.txt' in os.listdir(sample_buildout)
False
We can run more than one commands::
>>> cmds = '''
... touch %s
... rm -f %s
... ''' % (test_file, test_file)
>>> test_file = join(sample_buildout, 'test.txt')
>>> cmds = 'rm -f %s' % test_file
>>> write(sample_buildout, 'buildout.cfg', cfg % cmds)
>>> print system(buildout)
Updating cmds.
>>> 'test.txt' in os.listdir(sample_buildout)
False
We can also run some python code::
>>> cfg = """
... [buildout]
... parts = py py2
...
... [py]
... recipe = iw.recipe.cmd:py
... on_install=true
... cmds=
... >>> sample_buildout = buildout.get('directory', '.')
... >>> print os.listdir(sample_buildout)
... >>> shutil.rmtree(os.path.join(sample_buildout, "bin"))
... >>> print os.listdir(sample_buildout)
... [py2]
... recipe = iw.recipe.cmd:py
... on_install=true
... cmds=
... >>> def myfunc(value):
... ... return value and True or False
... >>> v = 20
... >>> print myfunc(v)
... """
>>> write(sample_buildout, 'buildout.cfg', cfg)
Ok, so now we run it::
>>> print system(buildout)
Uninstalling cmds.
Installing py.
['.installed.cfg', 'bin', 'buildout.cfg', 'develop-eggs', 'eggs', 'parts']
['.installed.cfg', 'buildout.cfg', 'develop-eggs', 'eggs', 'parts']
Installing py2.
True
Keywords: buildout,zc.buildout,recipe
Platform: UNKNOWN
Classifier: Programming Language :: Python
Classifier: Topic :: Software Development :: Libraries :: Python Modules