bee_python 0.0.6 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/egg/mysql/mysql.py +2 -0
- data/egg/project/test.py +1 -1
- data/lib/bee_task_python.rb +40 -0
- data/python.yml +41 -1
- metadata +4 -4
data/README
CHANGED
data/egg/mysql/mysql.py
CHANGED
@@ -24,11 +24,13 @@ def run_query(query):
|
|
24
24
|
db = DATABASE)
|
25
25
|
cursor = connection.cursor(MySQLdb.cursors.DictCursor)
|
26
26
|
cursor.execute(query)
|
27
|
+
connection.commit()
|
27
28
|
return cursor.fetchall()
|
28
29
|
finally:
|
29
30
|
if cursor:
|
30
31
|
cursor.close()
|
31
32
|
if connection:
|
33
|
+
connection.rollback()
|
32
34
|
connection.close()
|
33
35
|
|
34
36
|
def main():
|
data/egg/project/test.py
CHANGED
@@ -7,7 +7,7 @@ import os
|
|
7
7
|
import sys
|
8
8
|
import inspect
|
9
9
|
test_dir = os.path.dirname(inspect.currentframe().f_code.co_filename)
|
10
|
-
src_dir = os.path.join(test_dir, '
|
10
|
+
src_dir = os.path.join(test_dir, '..', 'src')
|
11
11
|
sys.path.insert(0, src_dir)
|
12
12
|
import <%= name %>
|
13
13
|
import unittest
|
data/lib/bee_task_python.rb
CHANGED
@@ -354,6 +354,46 @@ module Bee
|
|
354
354
|
end
|
355
355
|
end
|
356
356
|
|
357
|
+
# Check Python dependencies using PIP (see http://pypi.python.org/pypi/pip).
|
358
|
+
# Takes a single parameter that is the map of dependencies that gives version
|
359
|
+
# for a given dependency. A vesion set to ~ (or nil) indicates that this
|
360
|
+
# dependency is needed in any version (useful for developement libraries used
|
361
|
+
# for development).
|
362
|
+
#
|
363
|
+
# Example:
|
364
|
+
#
|
365
|
+
# - python.dependencies: { Django: "1.2.3", PyYAML: ~ }
|
366
|
+
def dependencies(dependencies)
|
367
|
+
error "python.deps_check parameter is a Map" unless
|
368
|
+
dependencies.kind_of?(Hash)
|
369
|
+
puts "Checking Python dependencies..."
|
370
|
+
lines = `pip freeze`.strip.split("\n")
|
371
|
+
installed = {}
|
372
|
+
for line in lines
|
373
|
+
if line =~ /^[^#].*/
|
374
|
+
index = line.index('==')
|
375
|
+
name = line[0..index-1]
|
376
|
+
version = line[index+2..-1]
|
377
|
+
installed[name] = version
|
378
|
+
end
|
379
|
+
end
|
380
|
+
for name in dependencies.keys.sort
|
381
|
+
if installed.has_key?(name)
|
382
|
+
if not dependencies[name] or dependencies[name] == '*'
|
383
|
+
puts "#{name}: OK" if @verbose
|
384
|
+
else
|
385
|
+
if dependencies[name] != installed[name]
|
386
|
+
throw "Dependency '#{name}' in bad version ('#{installed[_name]}' installed instead of '#{dependencies[name]}' required)"
|
387
|
+
else
|
388
|
+
puts "#{name} (#{dependencies[name]}): OK" if @verbose
|
389
|
+
end
|
390
|
+
end
|
391
|
+
else
|
392
|
+
throw "Missing dependency '#{name}'"
|
393
|
+
end
|
394
|
+
end
|
395
|
+
end
|
396
|
+
|
357
397
|
private
|
358
398
|
|
359
399
|
# Add directories to the Python path environment variable.
|
data/python.yml
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
abstract: true
|
5
5
|
default: [clean, test]
|
6
6
|
alias:
|
7
|
-
test: [py_check, py_test]
|
7
|
+
test: [py_deps, py_check, py_test]
|
8
8
|
doc: py_doc
|
9
9
|
run: py_run
|
10
10
|
clean: py_clean
|
@@ -46,6 +46,15 @@
|
|
46
46
|
py_cov_inc: ["*.py"]
|
47
47
|
# main scrip to run
|
48
48
|
py_main: "#{py_src_dir}/#{name}.py"
|
49
|
+
# dependencies as a map, for instance:
|
50
|
+
#
|
51
|
+
# py_deps:
|
52
|
+
# Django: "1.2.3"
|
53
|
+
# PyYAML: ~
|
54
|
+
#
|
55
|
+
# Set a version to ~ (or null) to indicate that no specific version is needed.
|
56
|
+
# Set dependencies to ~ if you don't want any check (default).
|
57
|
+
py_deps: ~
|
49
58
|
# directories to clean
|
50
59
|
py_clean_dirs: [:py_build_dir]
|
51
60
|
# files to clean
|
@@ -122,3 +131,34 @@
|
|
122
131
|
script:
|
123
132
|
- rmdir: :py_clean_dirs
|
124
133
|
- rm: :py_clean_files
|
134
|
+
|
135
|
+
- target: py_deps
|
136
|
+
description: Check Python dependencies using PIP
|
137
|
+
script:
|
138
|
+
- if: defined?(py_deps) and py_deps
|
139
|
+
then:
|
140
|
+
- python.dependencies: :py_deps
|
141
|
+
|
142
|
+
- target: py_inst_deps
|
143
|
+
description: Install Python dependencies using PIP
|
144
|
+
script:
|
145
|
+
- if: defined?(py_deps) and py_deps
|
146
|
+
then:
|
147
|
+
- for: _name
|
148
|
+
in: py_deps.keys.sort
|
149
|
+
do:
|
150
|
+
- if: not py_deps[_name] or py_deps[_name] == '*'
|
151
|
+
then:
|
152
|
+
- print: "Installing '#{_name}'..."
|
153
|
+
- try:
|
154
|
+
- "sudo pip install #{_name}"
|
155
|
+
- print: "OK"
|
156
|
+
catch:
|
157
|
+
- print: "ERROR: could not install '#{_name}'"
|
158
|
+
else:
|
159
|
+
- print: "Installing '#{_name}' in version '#{py_deps[_name]}'..."
|
160
|
+
- try:
|
161
|
+
- "sudo pip install #{_name}==#{py_deps[_name]}"
|
162
|
+
- print: "OK"
|
163
|
+
catch:
|
164
|
+
- print: "ERROR: could not install '#{_name}' in version '#{py_deps[_name]}'"
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bee_python
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.6
|
10
|
+
version: 0.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michel Casabianca
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-12-04 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: bee
|