Skip to content

Commit e3e39c7

Browse files
author
Niall O'Higgins
committed
Merge remote-tracking branch 'jared/master'
Conflicts: worker.js
2 parents 44d8bef + f5ff337 commit e3e39c7

File tree

8 files changed

+4634
-45
lines changed

8 files changed

+4634
-45
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ logs
1212
results
1313

1414
node_modules
15-
npm-debug.log
15+
npm-debug.log
16+
*.pyc

config/config.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<select ng-model="config.test">
2+
<option value="py.test">py.test</option>
3+
<option value="make test">make test</option>
4+
<option value="./setup.py test">./setup.py test</option>
5+
<option value="none">No test command</option>
6+
</select>
7+
<p class="help-text">
8+
Select which command should be used to test your
9+
project. Alternatively, select "none" if you are going to test using
10+
some other plugin.
11+
</p>
12+
<button class="btn btn-primary" ng-click="save()">Save</button>

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@
1313
"strider",
1414
"python"
1515
],
16+
"strider": {
17+
"type": "job",
18+
"id": "python",
19+
"title": "Python",
20+
"webapp": "webapp.js",
21+
"worker":"worker.js",
22+
"icon": "icon.png",
23+
"config": true
24+
},
1625
"author": "Niall O'Higgins",
1726
"license": "BSD",
1827
"dependencies": {

static/icon.png

1.7 KB
Loading

static/python-powered-w.svg

Lines changed: 4571 additions & 0 deletions
Loading

thirdparty/virtualenv.py

100644100755
File mode changed.

webapp.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
module.exports = {
3+
config: {
4+
/* we don't support this yet
5+
runtime: {
6+
type: String,
7+
enum: ['2.6', '2.7', '3.3', 'whatever']
8+
},
9+
*/
10+
test: {
11+
type: String,
12+
enum: ['none', 'py.test', './setup.py test', 'make test'],
13+
default: 'py.test'
14+
}
15+
}
16+
}

worker.js

Lines changed: 24 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,29 @@
11
var detect = require('strider-detection-rules')
2+
var fs = require('fs')
23
var path = require('path')
34

4-
// We include a copy of the virtualenv script
5-
var VIRTUAL_ENV_PY = path.join(__dirname, "thirdparty", "virtualenv.py")
6-
// Virtual environment will be under this directory name in the project dir
7-
var VIRTUAL_ENV_DIR = "venv"
8-
// Command to create the virtual env
9-
var VIRTUAL_ENV_CMD = "python " + VIRTUAL_ENV_PY + " " + VIRTUAL_ENV_DIR
10-
var VIRTUAL_PYTHON = path.join(VIRTUAL_ENV_DIR, "bin", "python")
11-
var VIRTUAL_PIP = path.join(VIRTUAL_ENV_DIR, "bin", "pip")
12-
var CREATE_VIRTUAL_ENV = VIRTUAL_ENV_CMD + " && " + VIRTUAL_PIP + " install -r requirements.txt"
13-
14-
var RULES = [{
15-
filename:"manage.py",
16-
grep:/django/i,
17-
language:"python",
18-
framework:"django",
19-
prepare:CREATE_VIRTUAL_ENV,
20-
test:VIRTUAL_PYTHON + " manage.py test",
21-
}, {
22-
filename:"setup.py",
23-
exists:true,
24-
language:"python",
25-
framework:null,
26-
prepare:CREATE_VIRTUAL_ENV,
27-
test:VIRTUAL_PYTHON + " setup.py test",
28-
}]
29-
30-
31-
module.exports = function(ctx, cb) {
32-
33-
function doTest(ctx , cb){
34-
detect(RULES, "test", ctx, cb)
5+
module.exports = {
6+
init: function (config, job, context, done) {
7+
var venvDir = path.join(context.baseDir, '.venv')
8+
done(null, {
9+
path: [path.join(__dirname, 'thirdparty'),
10+
path.join(venvDir, 'bin')],
11+
environment: 'virtualenv.py ' + venvDir,
12+
prepare: function (context, done) {
13+
if (fs.existsSync(path.join(context.dataDir, 'requirements.txt'))) {
14+
return context.cmd('pip install -r requirements.txt', function (err) {
15+
done(err, true)
16+
})
17+
}
18+
done(null, false)
19+
},
20+
test: (config && config.test !== 'none') ? config.test : undefined
21+
})
22+
},
23+
autodetect: {
24+
filename: 'requirements.txt',
25+
exists: true,
26+
language: 'python',
27+
framework: null
3528
}
36-
37-
function doPrepare(ctx, cb) {
38-
detect(RULES, "prepare", ctx, cb)
39-
}
40-
41-
ctx.addBuildHook({
42-
test: doTest,
43-
prepare: doPrepare,
44-
})
45-
46-
console.log("strider-python extension loaded")
47-
cb(null, null)
48-
4929
}

0 commit comments

Comments
 (0)