Skip to content

Commit 443914e

Browse files
committed
finally fixed terminal output bug
1 parent 328418e commit 443914e

File tree

6 files changed

+221
-75
lines changed

6 files changed

+221
-75
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "aminosee",
3-
"version": "1.31.4",
3+
"version": "1.31.5",
44
"owner": "Thomas Bieder Atkinson",
55
"author": "Tom Atkinson <tom@funk.co.nz>",
66
"website": "http://aminosee.funk.nz",

run-test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ aminosee --serve &
2828
echo aminosee $* --no-image
2929
aminosee $* --no-image
3030
test_do "KEYBOARD MODE" $FAST $* --no-image --peptide=Methionine --keyboard
31+
test_do "regmarks" $FAST $* --reg
3132
test_do "Networked cluster render test $NETWORK" -fv --peptide=Phenylalanine $FAST $NETWORK $MEDIUM $*
3233
test_do "Test use of --maxpix=5000000" --maxpix=5000000 -v $SLOW $MEDIUM $FAST $NETWORK $*
3334
test_do "Forced re-render verbose no image" -fv $MEDIUM $FAST $* --no-image

src/aminosee-cli.js

Lines changed: 40 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ function startGUI() {
128128
// output("Starting carlo GUI - press Control-C to quit")
129129
// const carlo = require("./aminosee-carlo").run( generateTheArgs() )
130130
output("start gui.")
131-
// server.start( generateTheArgs() )
132131
// destroyKeyboardUI()
133132
// return carlo
134133
}
@@ -138,6 +137,7 @@ function generateTheArgs() {
138137
log(`webroot: ${webroot} ${url}`)
139138
let theArgs = {
140139
verbose: verbose,
140+
path: webroot,
141141
webroot: webroot,
142142
outputPath: path.join( webroot, netFoldername ),
143143
openHtml: false,
@@ -161,7 +161,7 @@ function generateTheArgs() {
161161
logip: true,
162162
webroot: webroot,
163163
openHtml: cliInstance.openHtml,
164-
https: true,
164+
https: false,
165165
background: cliInstance.background,
166166
currentURL: cliInstance.currentURL
167167
}
@@ -174,7 +174,7 @@ function populateArgs(procArgv) { // returns args
174174
const options = {
175175
boolean: [ "artistic", "brute", "clear", "chrome", "devmode", "debug", "demo", "dnabg", "explorer", "file", "force", "fullscreen", "firefox", "gui", "html", "image", "keyboard", "list", "progress", "quiet", "reg", "recycle", "redraw", "slow", "serve", "safari", "test", "updates", "verbose", "view" ],
176176
string: [ "url", "output", "triplet", "peptide", "ratio" ],
177-
alias: { a: "artistic", b: "dnabg", c: "codons", d: "devmode", f: "force", finder: "explorer", h: "help", k: "keyboard", m: "magnitude", o: "output", p: "peptide", i: "image", t: "triplet", u: "updates", q: "quiet", r: "reg", w: "width", v: "verbose", x: "explorer", v: "verbose", view: "html" },
177+
alias: { a: "artistic", b: "dnabg", c: "codons", d: "devmode", f: "force", finder: "explorer", h: "help", k: "keyboard", m: "magnitude", o: "output", p: "peptide", i: "image", t: "triplet", u: "updates", q: "quiet", r: "ratio", w: "width", v: "verbose", x: "explorer", v: "verbose", view: "html" },
178178
default: { brute: false, debug: false, keyboard: false, progress: true, redraw: true, updates: true, stop: false, serve: false, fullscreen: false , html: true, image: false, index: false, clear: false, explorer: false, quiet: false, gui: false },
179179
stopEarly: false
180180
} // NUMERIC INPUTS: codons, magnitude, width, maxpix
@@ -298,7 +298,6 @@ function pushCli(cs) {
298298
// do stuff aside from creating any changes. eg if you just run "aminosee" by itself.
299299
// for each render batch sent through newJob, here is where "this" be instantiated once per newJob
300300
// for each DNA file, run setupRender
301-
// server.setArgs( args )
302301
isShuttingDown = false
303302
streamLineNr = 0
304303
loopCounter = 0
@@ -324,7 +323,6 @@ function pushCli(cs) {
324323
this.done = 0
325324
this.devmode = false // kills the auto opening of reports etc
326325
this.quiet = false
327-
verbose = false // not recommended. will slow down due to console.
328326
this.force = false // this.force overwrite existing PNG and HTML reports
329327
this.artistic = false // for Charlie
330328
this.dnabg = false // firehose your screen with DNA!
@@ -464,6 +462,7 @@ function pushCli(cs) {
464462
output("💩 debug mode ENABLED 💩")
465463
} else {
466464
debug = false
465+
log("💩 debug mode DISABLED 💩")
467466
}
468467

469468
if ( args.url ) {
@@ -660,8 +659,8 @@ function pushCli(cs) {
660659
}
661660

662661
if ( args.verbose || args.v) {
663-
output("verbose enabled. AminoSee version: " + version)
664-
bugtxt(`os.platform(): ${os.platform()} ${process.cwd()}`)
662+
output("verbose output enabled. AminoSee version: " + version)
663+
log(`os.platform(): ${os.platform()} ${process.cwd()}`)
665664
verbose = true
666665
termDisplayHeight -= 2
667666
} else {
@@ -898,36 +897,32 @@ function pushCli(cs) {
898897

899898
// output(`webserverEnabled: ${webserverEnabled}`)
900899
if ( webserverEnabled === true ) {
901-
output(`Starting webserver`)
902900
let theargs = generateTheArgs()
903-
bugtxt(theargs)
904901
server.stop() // kludge? maybe remove later
905902
url = projectprefs.aminosee.url
906903
output()
907904
this.setupKeyboardUI()
908905
autoStartGui = false
909906
// output(`Server running at: ${ chalk.underline( url ) } to stop use: aminosee --stop `)
910-
server.setArgs(theargs)
907+
// server.setArgs(theargs)
908+
909+
server.setArgs( theargs )
910+
911911
// server()
912912
// this.currentURL = server.foregroundserver()
913913
// this.currentURL = this.generateURL()
914-
// this.currentURL = server.start( theargs )
915914

916-
// server.start(theargs)
917915
// output( theargs )
918916
// output(`starting server in a tick`)
919917
// runcb( () => {
920-
log(`starting server now`)
918+
output(theargs)
919+
output(args)
920+
output(`Starting webserver...`)
921921
try {
922-
// server( theargs )
923-
server.start( this.currentURL )
924-
922+
server.start()
925923
} catch (err) {
926-
output(`error starting server: ${fixedWidth(tx/2, err)}`)
924+
output(`error starting server: ${err}`)
927925
}
928-
// webserverEnabled = false
929-
// })
930-
931926

932927
} else {
933928
log("Not starting server")
@@ -1205,8 +1200,7 @@ function pushCli(cs) {
12051200
}
12061201
if ( debug === true && this.quiet == false) {
12071202
// console.log( histogramJson )
1208-
// output( beautify( histogramJson, null, 2, 100) )
1209-
1203+
output( beautify( histogramJson, null, 2, 100) )
12101204
}
12111205
aminosee_json = histogramJson
12121206
return histogramJson
@@ -1457,7 +1451,6 @@ function pushCli(cs) {
14571451

14581452
// pushCli('--serve');
14591453
// output( server.foregroundserver() )
1460-
// server.start( generateTheArgs() )
14611454
autoStartGui = false
14621455

14631456
} else {
@@ -1917,6 +1910,7 @@ function pushCli(cs) {
19171910

19181911

19191912
this.setIsDiskBusy( false )
1913+
output(`debug: was inside preRenderReset ${status}`)
19201914
killAllTimers()
19211915
try {
19221916
remain = this.args._.length
@@ -2046,7 +2040,6 @@ function pushCli(cs) {
20462040
diskStorm(cb) {
20472041
log("WE BE STORMIN")
20482042
if ( brute === false) { runcb(cb); return false }
2049-
// killAllTimers()
20502043
output("LIKE NORMAN")
20512044

20522045
for ( let p = 1; p < this.pepTable.length; p++ ) { // standard peptide loop
@@ -2675,7 +2668,8 @@ function pushCli(cs) {
26752668
}
26762669

26772670
saveHTML( cb ) {
2678-
status = ""
2671+
mode("Saving HTML")
2672+
// status = ""
26792673
if ( this.isHilbertPossible === false ) { status += "Hilbert not possible. "; this.report = false }
26802674
if ( this.report === false ) { status += "Report is disabled. "; this.report = false }
26812675
if ( this.test ) { status += "Test. "; this.report = false }
@@ -2689,13 +2683,12 @@ function pushCli(cs) {
26892683
// cb()
26902684
// return false
26912685
// }
2692-
mode("Saving HTML")
2686+
26932687

26942688
// this.pepTable.sort( this.compareHistocount )
26952689
let histogramJson = this.getRenderObject()
26962690
let histogramFile = this.generateFilenameHistogram()
2697-
bugtxt(`globalVariablesDoSuck: ${ this.usersPeptide}`)
2698-
// output( beautify( histogramJson , null, 2, 100) )
2691+
bugtxt( beautify( histogramJson , null, 2, 100) )
26992692

27002693
let hypertext
27012694
if ( this.test === true ) {
@@ -2716,14 +2709,22 @@ function pushCli(cs) {
27162709
}
27172710

27182711
if ( this.dimension > defaultPreviewDimension ) {
2719-
this.fileWrite(path.resolve( this.outputPath, this.shortnameGenome, "highres.html"), hypertext)
2712+
if ( this.reg ) {
2713+
this.fileWrite(path.resolve( this.outputPath, this.shortnameGenome, "highres-regmarks.html"), hypertext)
2714+
} else {
2715+
this.fileWrite(path.resolve( this.outputPath, this.shortnameGenome, "highres.html"), hypertext)
2716+
}
27202717
log( blueWhite(`Writing high resolution report for the directory ${this.shortnameGenome}`))
27212718
} else if ( this.dimension = defaultPreviewDimension ) {
27222719
this.index = true
27232720
}
27242721

27252722
if ( this.index || !ishighres ) { // if it wont make the users computer explode... set it as index page!
2726-
this.fileWrite(path.resolve( this.outputPath, this.shortnameGenome, "index.html"), hypertext)
2723+
if ( this.reg ) {
2724+
this.fileWrite(path.resolve( this.outputPath, this.shortnameGenome, "regmarks.html"), hypertext)
2725+
} else {
2726+
this.fileWrite(path.resolve( this.outputPath, this.shortnameGenome, "index.html"), hypertext)
2727+
}
27272728
log( blueWhite(`Writing default report for the directory ${this.shortnameGenome}`))
27282729
}
27292730

@@ -3057,7 +3058,7 @@ function pushCli(cs) {
30573058
mode("quit " + reason)
30583059
if (typeof code == "undefined") { code = 0 } // dont terminate with 0
30593060
log(`Received quit(${code}) ${reason}`)
3060-
killAllTimers()
3061+
// killAllTimers()
30613062
destroyKeyboardUI()
30623063
if ( renderLock === true ) {
30633064
output("halting render") // maybe this happens during graceful shutdown
@@ -4787,15 +4788,15 @@ function pushCli(cs) {
47874788

47884789

47894790
function bugtxt(txt) { // full debug output
4790-
// if (debug === true) {
4791-
// bugout(txt)
4792-
// }
4791+
if (debug) {
4792+
bugout(txt)
4793+
}
47934794
}
47944795
function output(txt) {
47954796
cpuhit++
47964797
if (typeof txt === "undefined" || typeof cliInstance === "undefined") { console.log() ; return; }
47974798

4798-
wTitle(`${ txt }`) // put it on the terminal windowbar or in tmux
4799+
wTitle(`${ removeNonAscii( txt )}`) // put it on the terminal windowbar or in tmux
47994800

48004801
if (cliInstance.quiet === true) {
48014802
redoline(txt)
@@ -4830,7 +4831,7 @@ function pushCli(cs) {
48304831
// return
48314832
if ( debug === true || verbose ) {
48324833
bugout( txt )
4833-
} else if (verbose) {
4834+
} else if ( verbose ) {
48344835
console.log( txt )
48354836
} else {
48364837
redoline( txt )
@@ -4849,9 +4850,7 @@ function pushCli(cs) {
48494850
term.windowTitle( txt )
48504851
}
48514852
function bugout(txt) {
4852-
4853-
console.log( `${helixEmoji}: ${cpuhit} ${maxWidth(16, status)} ${cliInstance.usersPeptide} ${remain} ${txt} `)
4854-
4853+
console.log( `${helixEmoji}: ${cpuhit} ${status} ${cliInstance.usersPeptide} ${remain} ${txt} `)
48554854
}
48564855
function deleteFile(file) {
48574856
let ret = false
@@ -5336,7 +5335,7 @@ function pushCli(cs) {
53365335
} else {
53375336
// if (debounce(25) === true) {
53385337
term.eraseLine()
5339-
console.log( maxWidth( tx/2, txt ))
5338+
console.log( maxWidth( tx/2, removeNonAscii( txt )))
53405339
term.eraseLine()
53415340
term.column( 0 )
53425341
term.up( 1 )
@@ -5723,7 +5722,6 @@ function pushCli(cs) {
57235722
// this.pollForStream();
57245723
// },
57255724
// function( cb ) {
5726-
// server.start( this.args );
57275725
// this.mkRenderFolders();
57285726
// // symlinkGUI(cb);
57295727
// }
@@ -5754,7 +5752,7 @@ function pushCli(cs) {
57545752

57555753
// let this.radMargin = cliInstance.termMarginLeft
57565754
this.radMargin = 16
5757-
output(" ")
5755+
output(`tx: ${tx}`)
57585756
// term.right( this.radMargin )
57595757
terminalRGB( helixEmoji + chalk.rgb(255, 32, 32).bgBlack(arr[0]) , 12, 34, 56)
57605758
term.eraseLine()
@@ -5786,10 +5784,6 @@ function pushCli(cs) {
57865784
terminalRGB(`${ prettyDate(new Date())} v${version} ${arr[6]} `, 220, 120, 70); term.right( this.radMargin ); term.eraseLine()
57875785
terminalRGB(arr[7], 220, 80, 80); term.right( this.radMargin ); term.eraseLine()
57885786
terminalRGB(arr[8], 255, 32, 32); term.eraseLine()
5789-
5790-
5791-
5792-
57935787
}
57945788

57955789
}

src/aminosee-server.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ let starts = -1
2929
let outputPath, filenameServerLock, url, projectprefs, userprefs, port, cliruns, gbprocessed, args, theserver, genomes, webroot, fragment
3030

3131

32-
setArgs()
32+
// setArgs()
3333

3434
module.exports = (options) => {
3535
var tcpPortUsed = require("tcp-port-used")
@@ -39,7 +39,7 @@ module.exports = (options) => {
3939
process.title = `aminosee.funk.nz_server ${fragment}`
4040
output(`AminoSee built-in webserver ${ chalk.underline( fragment )}`)
4141

42-
setArgs(options);
42+
// setArgs(options);
4343
// [ userprefs, projectprefs ] = setupPrefs()
4444
setupPrefs()
4545
log(appFilename)
@@ -66,7 +66,7 @@ module.exports = (options) => {
6666
function setArgs( TheArgs ) {
6767
webroot = path.resolve( os.homedir(), "AminoSee_webroot")
6868
port = defaultPort
69-
log("setArgs running")
69+
output("setArgs running")
7070
if ( typeof TheArgs === "undefined" ) {
7171
args = {
7272
verbose: false,
@@ -288,6 +288,7 @@ function foregroundserver() {
288288
log( `webroot ${webroot}` )
289289
try {
290290
var server = httpserver.createServer({
291+
path: webroot,
291292
root: webroot,
292293
robots: true,
293294
directoryListing: true,
@@ -448,17 +449,12 @@ function readLockPort(file) {
448449

449450
function start() { // return the port number
450451
output(chalk.yellow(`Starting web server at ${chalk.underline(getServerURL())}`))
451-
452-
log("Attempting to start server with args:")
453-
log( args)
454-
if ( args.verbose ) {
455-
log( args )
456-
}
457-
filenameServerLock = path.resolve( args.webroot, "output", "aminosee_server_lock.txt")
452+
log( args )
453+
filenameServerLock = path.join( args.webroot, "output", "aminosee_server_lock.txt")
458454
if ( args.stop == true ) { stop(); return true }
459455
setupPrefs()
460456
buildServer()
461-
notQuiet(`web root: ${webroot}`)
457+
output(`web root: ${webroot}`)
462458
let options = [ webroot, "-p", port, "-o", "--gzip", "-d" ] // -o open -i autoindex
463459
// let options = [ webroot , "", "-p", port, "-o" ]
464460
if ( serverLock() == true ) {
@@ -485,14 +481,13 @@ function start() { // return the port number
485481
}).catch(function () {
486482
})
487483
} else {
488-
484+
output(`Not opening url ${url}`)
489485
}
490486

491487
}
492488
log(`filenameServerLock: ${filenameServerLock}`)
493489
}
494490
return args.openPage
495-
// return port
496491
}
497492

498493

src/aminosee-version.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
// generated by genversion
2-
module.exports = '1.31.4'
2+
module.exports = '1.31.5'

0 commit comments

Comments
 (0)