Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (fs.existsSync(_cookies.path)) {
_cookies.load();
request.get('https://plug.dj/_/users/me', {
headers: {
'User-Agent': 'plugAPI_' + PlugAPIInfo.version,
Cookie: _cookies.toString()
}
}, function(err, res) {
if (res.statusCode === 200) {
loggedIn = true;
}
loggingIn = false;
});
// Wait until the session is set
while (loggingIn) {
deasync.sleep(100);
}
}
if (!loggedIn) {
loggingIn = true;
request.get('https://plug.dj/', {
headers: {
'User-Agent': 'plugAPI_' + PlugAPIInfo.version,
Cookie: _cookies.toString()
}
}, function(err, res, body) {
var csrfToken;
_cookies.fromHeaders(res.headers);
csrfToken = body.split('_csrf')[1].split('"')[1];
base: _base
}
console.log('Loading dataset ' + options.store + ' ...');
_base.loadCSV(options, function (err) {
if (err) return callback(err);
var Iris = _base.store(options.store);
console.log(options.store + ' dataset loaded')
finished = true;
})
// Used deasync module to turn this function into sync.
while (finished == false) {
require('deasync').runLoopOnce();
}
return _base.store(options.store);
}
base: _base
}
console.log('Loading dataset ' + options.store + ' ...');
_base.loadCSV(options, function (err) {
if (err) return callback(err);
var Iris = _base.store(options.store);
console.log(options.store + ' dataset loaded')
finished = true;
})
// Used deasync module to turn this function into sync.
while (finished == false) {
require('deasync').runLoopOnce();
}
return _base.store(options.store);
}
base: _base
}
console.log('Loading dataset ' + options.store + ' ...');
_base.loadCSV(options, function (err) {
if (err) return callback(err);
var Iris = _base.store(options.store);
console.log(options.store + ' dataset loaded')
finished = true;
})
// Used deasync module to turn this function into sync.
while (finished == false) {
require('deasync').runLoopOnce();
}
return _base.store(options.store);
}
.on('error', function () {
logging.error('Failed to create server.cache.js.gz');
compressionFinished = true;
})
.pipe(output)
.on('finish', function () {
logging.info('Created server.cache.js.gz');
compressionFinished = true;
})
.on('error', function () {
logging.error('Failed to create server.cache.js.gz');
compressionFinished = true;
});
// wait for compression to complete
deasync.loopWhile(function(){return !compressionFinished;});
}
step.stats = module._getStats(methodName);
} else {
step.stats = {};
}
if (err) {
step.failure = errorHelper.getFailureFromError(err);
// let the module decide whether a screenshot should be taken on error or not
if (typeof module._takeScreenshot === 'function') {
try {
step.screenshot = module._takeScreenshot(methodName);
}
catch (e) {
// If we are here, we were unable to get a screenshot
// Try to wait for a moment (in Perfecto Cloud, the screenshot might not be immidiately available)
deasync.sleep(1000);
try {
step.screenshot = module._takeScreenshot(methodName);
}
catch (e) {
// FIXME: indicate to user that an attempt to take a screenshot has failed
}
}
}
}
return step;
}
var lineColumn = getLineAndColumnFromStacktrace(err, scriptPath);
if (lineColumn) {
err.line = lineColumn.line;
err.column = lineColumn.column;
}
}
step.failure._line = err.line;
// let the module decide whether a screenshot should be taken on error or not
if (typeof module._takeScreenshot === 'function') {
try {
step.screenshot = module._takeScreenshot(methodName);
}
catch (e) {
// If we are here, we were unable to get a screenshot
// Try to wait for a moment (in Perfecto Cloud, the screenshot might not be immidiately available)
deasync.sleep(1000);
try {
step.screenshot = module._takeScreenshot(methodName);
}
catch (e) {
// FIXME: indicate to user that an attempt to take a screenshot has failed
}
}
}
}
rs.steps.push(step);
}
downloadSync2 = wget2 = (url) => {
ret = undefined// global hack
fetch(urlify(url)).then(response => response.text().then(data => ret = data))
while (ret === undefined) {
require('deasync').runLoopOnce();
}
return ret
}
dispatchSync(action) {
let done = false;
let result;
action(this.mockDispatch, this.getState).then((r) => {
result = r;
done = true;
});
require('deasync').loopWhile(() => !done);
//require('deasync').sleep(100);
return result;
}
beforeEach: function (cb) {
mongoose.connect(config.mongoDbURI)
require('deasync').loopWhile(function () {
return mongoose.connection.readyState !== 1
})
cb()
},
afterEach: function (cb) {