How to nicely format my console/terminal text as HTML - html

I have a java program which sends a results (as seen in a console) via HTTP to a browser. The real results are nicely formatted by tabs and newlines, as seen below:
./src/yse4 : The YSE emulator in use
[-w] - [w]rap around at tracefile end and begin anew at time zero.
[-f filename] - [-f tracefile to use from]
/home/Downloads/yse.wzt/tracefiles/capacity.3Mbps_400RTT_PER_0.0001.txt
File name: tracefiles/capacity.3Mbps_400RTT_PER_0.0001.txt
200 Forwarding Delay (ms)
200 Reversed Delay (ms)
3000000 Download Capacity (Mbps)
3000000 Upload Capacity (Mbps)
0.0001 Packet Error Rate (PER)
at=eth1
an=eth0
But when I send it as HTML, of course it does not recognize tabs and newlines. I manually add <br> at the end of each line, but still tabs are missing, and the browser shows it as below:
./src/yse4 : The YSE emulator in use
[-w] - [w]rap around at tracefile end and begin anew at time zero.
[-f filename] - [-f tracefile to use from]
/home/Downloads/yse.wzt/tracefiles/capacity.3Mbps_400RTT_PER_0.0001.txt
File name: tracefiles/capacity.3Mbps_400RTT_PER_0.0001.txt
200 Forwarding Delay (ms)
200 Reversed Delay (ms)
3000000 Download Capacity (Mbps)
3000000 Upload Capacity (Mbps)
0.0001 Packet Error Rate (PER)
at=eth1
an=eth0
How can I format it as HTML to be seen nicely? Maybe any library exists for that?

You can return an HTML Table containing two rows and format the table as you want
HTML Table

Related

Q/KDB+ / CSV upload and WSFULL

Pardon me but I'm a Q novice and couldn't find a solution. The code below appends a four-column CSV file to a KDB+ database. This code worked well but, now that my database is large, it throws a WSFULL error. Perhaps there is a more memory efficient way to write it. Please help:
// FILE_LOADER.q
\c 520 500
if [(count .z.x) < 1;
show `$"usage: q loadcsv.q inputfile destfile
where inputfile and destfile are absolute or relative paths to
the files. Inputfile has the following fields:
DATE, TICKER, FIELD, VALUE. DATE is of type date,
TICKER and FIELD are strings, and VALUE is converted to a float.
Any string VALUEs will show up as nulls.";
exit 1
]
f1: hsym `$.z.x[0]
f2: hsym `$.z.x[1]
columns: `DATE`TICKER`FIELD`VALUE
if [() ~ key f1; show ("Input file '",.z.x[0],"' not found");exit 1]
x: .Q.fsn[{f2 upsert flip columns!("DSSF";",")0:x};f1;4194000000]
show ("loaded ",(string x)," characters into the kdb database")
exit 0
First just from trying this out I assume your input csv file never has a header? If it does you'll need a slight code change so kdb is aware.
You are correct that it's a memory issue so what you can do is just decrease the chunk size. You are reading in 4194000000 bytes at a time right now. Try lowering this in accordance with available memory.
If you are still seeing issues it may be your garbage collection setting. You could force a gc after each read/upsert.
.Q.fsn[{f2 upsert flip columns!("DSSF";",")0:x;**.Q.gc[]**};f1;4194000000]

Octave Psychtoolbox crashing when the screen is called to be displayed

I am still new in Octave with some experience in Python and I was requested to do a test in a stimulus application in order to find if there are errors in the code (not developed by me) and try to fix them and run the application. The issue in the code is at the time to open the screen as follows the implementation (these ones where I commented (%) are what already did before, and these ones below the comments are my correction) the code is large with 825 lines:
%% Get subject name from the user
prompt = {'Enter Subject Number:','Enter Subject Name:','Enter Todays Date:','Left or Right:'};
dlgtitle = 'Information Input';
%dims = [1 50];
dims = [1 50;1 50;1 50;1 50];
opts = 'on';
answer = inputdlg(prompt,dlgtitle,dims);
%waitfor(answer);
waitfor(dims);
%% TO Excel
% Get the name of the file that the user wants to save.
%startingFolder = userpath;
startingFolder = 'C:\Users\Vtr\Downloads\Final-task-981203\Final-task-981203\Task-981203';
defaultFileName = fullfile(startingFolder, '*.xlsx');
[baseFileName, folder] = uiputfile(defaultFileName, 'Specify a filename ');
if baseFileName == 0
% User clicked the Cancel button.
return;
end
% Combine the folder and base file name into the full file name.
fullFileName = fullfile(folder, baseFileName);
%% LOAD text initial setting
%% Create 1st screen : (Loading and Wait)text screen
% Open an on screen window - purple screen
[window, windowRect] = PsychImaging('OpenWindow', screenNumber, [0.5 0.5 1]);
% Set up alpha-blending for smooth (anti-aliased) lines
Screen('BlendFunction', window, 'GL_SRC_ALPHA', 'GL_ONE_MINUS_SRC_ALPHA');
After that, in the first part is created a form to insert subject nº, subject name, today's date and left or right, and after that to specify a filename. Made these two parts it appears a purple screen with the mouse's cursor rotating non-stop and if I try to click with the mouse an error alert box "octave-gui.exe has stopped working" appears on. I already tried to run this code on my Virtualbox-VM (Ubuntu 16.04 LTS), firstly, it notifies that my screen is being tested and calibrated and after, it appears another error screen on the terminal:
PTB-INFO: OS support status: Linux 4.15.0-55-generic Supported.
PTB-INFO: Type 'PsychtoolboxVersion' for more detailed version information.
PTB-INFO: Most parts of the Psychtoolbox distribution are licensed to you under terms of the MIT License, with
PTB-INFO: some restrictions. See file 'License.txt' in the Psychtoolbox root folder for the exact licensing conditions.
PTB-WARNING: FAILED to enable synchronization to vertical retrace!
PTB-WARNING: FAILED to enable synchronization to vertical retrace (System ignored setting [Req 1 != Actual 0])!
PTB-INFO: Failed to enable realtime-scheduling [Operation not permitted]!
PTB-INFO: You need to run Matlab or Octave with root-privileges, or run the script PsychLinuxConfiguration once for this to work.
PTB-INFO: See /usr/share/doc/psychtoolbox-3-common/README.Debian to make this work.
PTB-WARNING: Couldn't even collect one single valid flip interval sample! Sanity range checks failed!
PTB-WARNING: Could be a system bug or a temporary timing problem. Retrying the procedure might help if
PTB-WARNING: the latter is the culprit.
WARNING: VBL Calibration run No. 1 failed. Retrying...
PTB-INFO: Failed to enable realtime-scheduling [Operation not permitted]!
PTB-INFO: You need to run Matlab or Octave with root-privileges, or run the script PsychLinuxConfiguration once for this to work.
PTB-INFO: See /usr/share/doc/psychtoolbox-3-common/README.Debian to make this work.
PTB-WARNING: Couldn't even collect one single valid flip interval sample! Sanity range checks failed!
PTB-WARNING: Could be a system bug or a temporary timing problem. Retrying the procedure might help if
PTB-WARNING: the latter is the culprit.
WARNING: VBL Calibration run No. 2 failed. Retrying...
WARNING: Will enable VBL busy wait-workaround before trying final VBL Calibration run No. 3.
WARNING: This will hopefully work-around graphics driver bugs of the GPU sync-to-retrace mechanism. Cross your fingers!
PTB-INFO: Failed to enable realtime-scheduling [Operation not permitted]!
PTB-INFO: You need to run Matlab or Octave with root-privileges, or run the script PsychLinuxConfiguration once for this to work.
PTB-INFO: See /usr/share/doc/psychtoolbox-3-common/README.Debian to make this work.
PTB-WARNING: Couldn't even collect one single valid flip interval sample! Sanity range checks failed!
PTB-WARNING: Could be a system bug or a temporary timing problem. Retrying the procedure might help if
PTB-WARNING: the latter is the culprit.
PTB-INFO: OpenGL-Renderer is VMware, Inc. :: SVGA3D; build: RELEASE; LLVM; :: 2.1 Mesa 18.0.5
PTB-INFO: VBL startline = 664 , VBL Endline = -1
PTB-INFO: Beamposition queries unsupported or defective on this system. Using basic timestamping as fallback.
PTB-INFO: Timestamps returned by Screen('Flip') will be therefore less robust and accurate.
PTB-INFO: Measured monitor refresh interval from VBLsync = 0.000000 ms [inf Hz]. (0 valid samples taken, stddev=10000000.000000 ms.)
PTB-INFO: Reported monitor refresh interval from operating system = 16.667222 ms [59.998001 Hz].
PTB-INFO: Small deviations between reported values are normal and no reason to worry.
WARNING: Couldn't compute a reliable estimate of monitor refresh interval! The trouble with VBL syncing?!?
WARNING: Mismatch between measured monitor refresh interval and interval reported by the operating system.
This indicates massive problems with VBL sync.
----- ! PTB - ERROR: SYNCHRONIZATION FAILURE ! -----
One or more internal checks (see Warnings above) indicate that synchronization
of Psychtoolbox to the vertical retrace (VBL) is not working on your setup.
This will seriously impair proper stimulus presentation and stimulus presentation timing!
Please read 'help SyncTrouble' for information about how to solve or work-around the problem.
You can force Psychtoolbox to continue, despite the severe problems, by adding the command
Screen('Preference', 'SkipSyncTests', 1); at the top of your script, if you really know what you are doing.
error: Screen: See error message printed above.
error: Called from
PsychImaging at line 2240 column 26
Naderi_test_task_v_main_1203_v_2 at line 110 column 20
I would like to know if the issue is in my computer configurations that don't support Psychtoolbox resources or any configuration that I need to change.

Sikuli IDE command wait("image") not waiting for image to appear before script continues

I am new to Sikuli and am trying it out with a very simple script that looks like this...
wait and click cmds are used and they are working, The issue i am facing is wait("1513068228396.png",3600) is not waiting until image appears,, it waits for some 10 to 15 secs and executes next cmd. I tried including some Logs, and also tried with other images to same wait cmd, still same result.
wait("1513067960826.png",60)
click(Pattern("1513066493827.png").targetOffset(-106,2))
sleep(2)
click("1513066637741.png")
sleep(1)
click("1513599247108.png")
sleep(5)
print "wait for my image"
wait("1513068228396.png",3600) # Facing issue in this line
print "found my image"
outputLog :
wait for my image
[debug] Region: find: waiting 3600.0 secs for 1513068228396.png to appear in R[0,0 1920x1080]#S(0)
[debug] Image: reused: 1513068228396.png (file:/D:/softwares/sikuli/SENINFO_V100R002C00SPC700.sikuli/1513068228396.png)
[debug] Region: checkLastSeen: not there
[debug] Region: find: 1513068228396.png has appeared at M[832,379 30x16]#S(S(0)[0,0 1920x1080]) S:0.70 C:847,387 [753 msec]
found my image
Any suggestion how to solve this issue.
Maybe that image have a similarity with some region in the screen. You could try to set the similarity to the highest value:
wait(Pattern("some_image.png").similar(0.8),) # if you want the 80% of similarity
wait(Pattern("some_image.png").exact()) # if you want the 100% of similarity
Also, I encourage you to use if exists instead of wait. Wait will end the program if the image doesn't exist:
if exists(Pattern("some_image.png").exact(),3600):
click("some_image.png")
You can find Pattern documentation here
The wait(pattern, 3600) is equivalent to wait(pattern, FOREVER) which is described here and will wait for the pattern indefinitely. In case like yours, the only thing that can explain this behavior is if the pattern was actually found on the screen and the below line confirms that:
Region: find: 1513068228396.png has appeared at M[832,379
30x16]#S(S(0)[0,0 1920x1080]) S:0.70 C:847,387 [753 msec]
Perhaps this pattern appears elsewhere and you missed it? Or maybe the similarity parameter is too low and another pattern gets recognized. To check that try to use the highlight(1) method.
ptrn = find("pattern.png")
ptrn.highlight(1)
This might shed some light.

How to format output from a program spawned from a expect script

I am writing a load testing script for radius server using tcl and expect.
I am invoking radclient, that comes inbuild with the radius server, from my script on remote server.
scripts does following:
take remote server IP
- spawn ssh to remote server
- invoke radclient
- perform load test using radclient commands
- need to collect the result from the output (as shown in the sample output) into a variable
- Extract authentication/sec as Transaction per second (TPS) from output or variable from previous step
Need help on last two steps:
Sample output from radclient:
*--> timetest 20 10 2 1 1
Cycles: 10, Repetitions: 2, Requests per Cycle: 10
Starting User Number: 1, Increment: 1
Current Repetition Number=1
Skipping Accounting On Request
Total Requests=100, Total Responses=100, Total Accepts=0 Total Not Accepts=100
1: Sending 100 requests and getting 100 responses took 449ms, or 0.00 authentications/sec
Current Repetition Number=2
Skipping Accounting On Request
Total Requests=100, Total Responses=100, Total Accepts=0 Total Not Accepts=100
2: Sending 100 requests and getting 100 responses took 471ms, or 0.00 authentications/sec
Expected Output:
TPS achieved = 0
You might use something like this:
expect -re {([\d.]+) authentications/sec}
set authPerSec $expect_out(1,string)
puts "TPS achieved = $authPerSec"
However, that's not to say that the information extracted is the right information. For example, when run against your test data it is likely to come unstuck as there are two places where you have authentications/sec due to all the repetitions; we don't account for that at all! More complex patterns might extract more information and so on.
expect {
-re {([\d.]+) authentications/sec} {
set authPerSec $expect_out(1,string)
puts "TPS achieved #[incr count] = $authPerSec"
exp_continue
}
"bash$" {
# System prompt means stop expecting; tune for what you've got...
}
}
Doing the right thing can be complex sometimes…

How to trigger an OpenNMS event with thresholds

it seems that it is not possible for me to trigger an event in OpenNMS using a threshold...
first the fact (as much detail as i can)
i want to monitor a html file, better, the content.
if a value is not what i expected OpenNMS should call be.
my html file:
Document Count: 5
in /var/lib/opennms/rrd/snmp/NODE are two files named: "documentCount" (.jbr & .meta)
--> because of the http-datacollection-config.xml
in my logfiles is written:
INFO [LegacyScheduler-Thread-2-of-50] RrdUtils: updateRRD: updating RRD file /var/lib/opennms/rrd/snmp/21/documentCount.jrb with values '1385031023:5'"
so the "5" is collected correctly.
now i created a threshold for this case:
<threshold type="high" ds-type="node"
value="4.0" rearm="2.0" trigger="1" triggeredUEI="uei.opennms.org/threshold/highThresholdExceeded"
filterOperator="or" ds-name="documentCount"
/>
in my collectd-configuration.xml is the threshold also enabled:
in my opinion the threshold of 4 is exceeded, because the value is 5. so the highTresholdEvent should be fired. BUT IT DOESNT.
so i'm here to ask if someone had an idea.
regards dawn
Check collectd.log with the following
tail -f collectd.log | grep -i thresholding
Threshold checking was moved to evaluate while the data is being retrieved a while back as opposed to a post process of rrd files.
Even with the log setting at info you should find some clues as to why the threshold rule is not matching any data.