Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var async = require('neo-async')
var AWS = require('aws-sdk')
var AU = require('ansi_up')
var buildTemplate = require('../html/build.html.js')
// We buffer all logs in-memory, including cmd output
var LOG_BUFFER = []
var SVGS = {
pending: fs.readFileSync(`${__dirname}/../html/pending.svg`, 'utf8'),
passing: fs.readFileSync(`${__dirname}/../html/passing.svg`, 'utf8'),
failing: fs.readFileSync(`${__dirname}/../html/failing.svg`, 'utf8'),
}
var s3 = new AWS.S3()
var ansiUp = new AU.default()
exports.logIfErr = function(err) {
if (err) exports.error(err.stack || err)
}
// We rely on a singleton logger (for the buffer), so this is kinda hacky
// (ie, cannot execute concurrent invocations from the same process)
// We could return a new logger instance, but... meh.
// Lambda doesn't execute concurrently in the same process anyway.
exports.init = function() {
LOG_BUFFER = []
exports.info.apply(exports, arguments)
}
exports.info = function() {
LOG_BUFFER.push(util.format.apply(util, arguments))
export function renderText(options: renderText.IRenderOptions): Promise {
// Unpack the options.
let { host, source } = options;
const ansiUp = new AnsiUp();
ansiUp.escape_for_html = true;
ansiUp.use_classes = true;
// Create the HTML content.
let content = ansiUp.ansi_to_html(source);
// Set the inner HTML for the host node.
host.innerHTML = `<pre>${content}</pre>`;
// Return the rendered promise.
return Promise.resolve(undefined);
}
import moment from 'moment';
import DatasetFactory from '../../../tabledata/datasetfactory';
import TableVisualization from '../../../visualization/builtins/visualization-table';
import BarchartVisualization from '../../../visualization/builtins/visualization-barchart';
import PiechartVisualization from '../../../visualization/builtins/visualization-piechart';
import AreachartVisualization from '../../../visualization/builtins/visualization-areachart';
import LinechartVisualization from '../../../visualization/builtins/visualization-linechart';
import ScatterchartVisualization from '../../../visualization/builtins/visualization-scatterchart';
import NetworkVisualization from '../../../visualization/builtins/visualization-d3network';
import {DefaultDisplayType, SpellResult} from '../../../spell';
import {ParagraphStatus} from '../paragraph.status';
import Result from './result';
const AnsiUp = require('ansi_up');
const AnsiUpConverter = new AnsiUp.default; // eslint-disable-line new-parens,new-cap
const TableGridFilterTemplate = require('../../../visualization/builtins/visualization-table-grid-filter.html');
angular.module('zeppelinWebApp').controller('ResultCtrl', ResultCtrl);
function ResultCtrl($scope, $rootScope, $route, $window, $routeParams, $location,
$timeout, $compile, $http, $q, $templateCache, $templateRequest, $sce, websocketMsgSrv,
baseUrlSrv, ngToast, saveAsService, noteVarShareService, heliumService,
uiGridConstants) {
'ngInject';
/**
* Built-in visualizations
*/
$scope.builtInTableDataVisualizationList = [
{
id: 'table', // paragraph.config.graph.mode
// tslint:disable:object-literal-sort-keys
import * as Toolkit from 'chipmunk.client.toolkit';
import { default as AnsiUp } from 'ansi_up';
const ansiup = new AnsiUp();
ansiup.escape_for_html = false;
const REGS = {
COLORS: /\x1b\[[\d;]{1,}[mG]/,
COLORS_GLOBAL: /\x1b\[[\d;]{1,}[mG]/g,
};
const ignoreList: { [key: string]: boolean } = {};
export class ASCIIColorsParser extends Toolkit.ARowCommonParser {
public parse(str: string, themeTypeRef: Toolkit.EThemeType, row: Toolkit.IRowInfo): string {
if (typeof row.sourceName === "string") {
if (ignoreList[row.sourceName] === undefined) {
ignoreList[row.sourceName] = row.sourceName.search(/\.dlt$/gi) !== -1;
}
/* @flow */
const React = require("react");
const { TriangleRightIcon } = require("react-octicons");
const ansiUp = require("ansi_up").default;
const Job = require("../../job");
const Padding = require("./Padding");
const LabelWithIcon = require("./LabelWithIcon");
const ansiUpInstance = new ansiUp();
type Props = {
job: Job,
isSelected: boolean,
};
module.exports = class JobRunOutput extends React.Component {
render() {
const { job, isSelected } = this.props;
const hasContent = Boolean(
isSelected || job.runResult.output.trim().length > 0 || job.error
);
if (!hasContent) {
return null;
}
ngOnInit() {
this.au = new AnsiUp.default();
this.au.use_classes = true;
this.fetch();
this.socketService.outputEvents
.pipe(
filter(msg => !!msg.message && !!msg.type)
)
.subscribe(msg => {
msg.created_at = new Date().getTime();
msg.message = this.au.ansi_to_html(msg.message);
if (this.show === 'all' || this.show === msg.type) {
this.logs.unshift(msg);
}
});
import React from 'react';
var AU = require('ansi_up');
var ansi_up = new AU.default();
class BashOutput extends React.Component {
updateHTML(text) {
return { __html: ansi_up.ansi_to_html(text.replace(/<br>/g, '\n')) };
}
render() {
if (this.props.text) {
return (
<pre> <div>
</div></pre>
);
} else {
return (<div>);
}</div>
socket.on('logs:fetch', function() {
var path = require('path');
var AnsiUp = require('ansi_up');
var ansi_up = new AnsiUp.default;
var fileTailer = require('file-tail');
var fs = require('fs');
var logFile = path.join(__dirname, '../logs/output.log');
if (!fs.existsSync(logFile))
utils.sendToSelf(socket, 'logs:data', 'Invalid Log File...');
else {
var ft = fileTailer.startTailing(logFile);
ft.on('line', function(line) {
utils.sendToSelf(socket, 'logs:data', ansi_up.ansi_to_html(line));
});
}
});
settingsController.logs = function(req, res) {
if (!checkPerms(req, 'settings:logs')) return res.redirect('/settings');
var content = initViewContant('logs', req);
var fs = require('fs'),
path = require('path'),
AnsiUp = require('ansi_up'),
ansiUp = new AnsiUp.default,
file = path.join(__dirname, '../../logs/output.log');
fs.readFile(file, 'utf-8', function(err, data) {
if (err) {
content.data.logFileContent = err;
return res.render('logs', content);
}
content.data.logFileContent = data.toString().trim();
content.data.logFileContent = ansiUp.ansi_to_html(content.data.logFileContent);
return res.render('logs', content);
});
};