Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
browser: browser
});
return job
.stop()
// Try to delete the timed out job in order to prevent the SauceLabs badge to
// indicate failure. The del() function can also fail, in that case swallow the
// exception.
.then(function () { return job.del().fail(_.noop); })
.then(getResult);
}
return result;
});
}
return Q
.fcall(function () {
me.startedJobs += 1;
me.reportProgress({
type: 'jobStarted',
numberOfJobs: me.numberOfJobs,
startedJobs: me.startedJobs
});
})
.then(getResult)
.then(function (result) {
if (me.onTestComplete) {
var clone = _.clone(result, true);
return Q
.nfcall(me.onTestComplete, clone)
.then(
function (passed) {
PREFIX rdfs: \n\
SELECT DISTINCT ?property WHERE {\n\
GRAPH <' + dsUri + '> {\n\
' + union + '\n\
}\n\
} LIMIT 50';
return client.query(q).then(function(results) {
console.log('properties by class result:');
console.dir(results);
return results.map(function(result) {
return result.property.value;
});
});
} else {
return Q.fcall(function() {
return [];
});
}
}
}
},
details: {},
call: {
args: message.args,
kwargs: message.kwargs
}
});
})
.catch(function (err) {
logger.error('cannot call remote procedure', message.registered.registration.id, err.stack);
self.error('CALL', message.request.id, err);
});
break;
case 'YIELD':
q.fcall(function () {
var defer = q.defer();
self.emit('yield', message.invocation.request.id, defer);
return defer.promise;
})
.then(function (invocation) {
invocation.session.send('RESULT', {
call: {
request: {
id: invocation.requestId
}
},
options: {},
yield: {
args: message.args,
kwargs: message.kwargs
}
SimpleWS.prototype._acceptKeepalive = function(msg) {
var self = this;
if (self._state !== STATE_READY && self._state !== STATE_HANDSHAKE) {
dbg.error('WS KEEPALIVE ON BAD STATE', self._name, self._state);
self._onWsError(msg._ws, new Error('WS MESSAGE ON BAD STATE'));
return;
}
dbg.log0('WS KEEPALIVE ACCEPT', self._name);
var acceptFunc = self._options.keepalive && self._options.keepalive.accept || noop;
Q.fcall(acceptFunc, self, msg.data)
.then(null, function(err) {
dbg.error('WS HANDSHAKE ACCEPT ERROR', self._name);
self._onWsError(msg._ws, err);
});
};
router.post('/batchcreateprob', function(req, res){
var cnt = parseInt(req.body.cnt, 10);
var manager = Comm.clearSpace(req.body.manager);
var source = Comm.clearSpace(req.body.source);
var resp = {ret: ERR.OK};
var ret = ERR.SYS;
Q.fcall(function(){
var name = req.session.user ? req.session.user.name : '';
if (name !== 'admin') {
ret = ERR.ACCESS_DENIED;
throw new Error('access denied.');
}
if (!manager || !source || !cnt || cnt > 50) {
ret = ERR.ARGS;
throw new Error('invalid args.');
}
return User.watch(manager);
})
.then(function(user){
if (!user) {
ret = ERR.NOT_EXIST;
throw new Error('user('+manager+') NOT exist.');
}
return function (key, arg) {
if (!has(cache, key)) {
cache[key] = Q.fcall(callback, key, arg);
}
return cache[key];
};
}
Thermostat.prototype.mode = function (mode, next) {
if(typeof mode === 'function') {
next = mode;
mode = null;
}
if(mode) {
var modeCmd = MODE_CMDS[mode.toLowerCase()];
if(!modeCmd) {
return Q.fcall(function() {
throw new Error('Invalid mode. Must be one of the following: ' + MODES.join(', '));
}).nodeify(next);
}
var cmd = {
cmd1: '6B',
cmd2: modeCmd,
extended: true,
exitOnAck: true
};
return this.insteon.directCommand(this.id, cmd)
.then(function(status) {
if(!!status && status.success) {
return mode;
} else {
return null;
return action().then(Q.resolve, function (err) {
if(retries >= currentTry++) {
return Q.delay(Q.fcall(retryAction), delayBeforeRetry);
} else {
return Q.reject(err);
}
});
};
var get_promise = function(value) {
return Q.fcall(function() { return value; }) };
router.get('/list', function(req, res){
var page = parseInt(req.query.page, 10);
if (!page) {
page = 1;
}
var search = req.query.search;
var resp = {
title: 'TopicList',
key: KEY.TOPIC_LIST,
page: page,
search: search,
getDate: getTime
};
var ret = ERR.SYS;
Q.fcall(function(){
if (page < 0) {
ret = ERR.REDIRECT;
throw new Error('redirect.');
}
var cond1 = {cid: -1}, cond2 = {cid: -1};
if (search) {
cond1.title = cond2.user = new RegExp("^.*"+Comm.toEscape(search)+".*$", 'i');
}
return Topic.get({$or: [cond1, cond2]}, page);
})
.then(function(o){
resp.topics = o.topics;
resp.totalPage = o.totalPage;
var names = new Array(), has = {};
o.topics.forEach(function(p){
if (!has[p.user]) {