1
0
mirror of https://github.com/kepler155c/opus synced 2025-05-04 16:34:13 +00:00

stack traces

This commit is contained in:
kepler155c@gmail.com 2019-03-07 13:14:16 -05:00
parent a4145951f7
commit 89f95ca45b
4 changed files with 16 additions and 16 deletions

View File

@ -567,24 +567,21 @@ function Util.widthify(s, len, align)
if slen > len then if slen > len then
return _ssub(s, 1, len) return _ssub(s, 1, len)
elseif slen == len then elseif slen == len then
return s return s
end
if align == 'center' then elseif align == 'center' then
local space = math.floor((len-slen) / 2) local space = math.floor((len - slen) / 2)
local filler = _srep(' ', space + 1) s = _srep(' ', space) .. s
s = _ssub(filler, 1, space) .. s return s .. _srep(' ', len - #s)
s = s .. _srep(' ', len - #s)
elseif align == 'right' then elseif align == 'right' then
s = _srep(' ', len - #s) .. s return _srep(' ', len - slen) .. s
else -- 'left'
s = s .. _srep(' ', len - #s)
end end
return s return s .. _srep(' ', len - slen)
end end
-- http://snippets.luacode.org/?p=snippets/trim_whitespace_from_string_76 -- http://snippets.luacode.org/?p=snippets/trim_whitespace_from_string_76

View File

@ -15,17 +15,17 @@ UI:configure('Network', ...)
local gridColumns = { local gridColumns = {
{ heading = 'Label', key = 'label' }, { heading = 'Label', key = 'label' },
{ heading = 'Dist', key = 'distance' }, { heading = 'Dist', key = 'distance', align = 'right' },
{ heading = 'Status', key = 'status' }, { heading = 'Status', key = 'status' },
} }
local config = Config.load('network', { }) local config = Config.load('network', { })
if UI.term.width >= 30 then if UI.term.width >= 30 then
table.insert(gridColumns, { heading = 'Fuel', key = 'fuel', width = 5 }) table.insert(gridColumns, { heading = 'Fuel', key = 'fuel', width = 5, align = 'right' })
end end
if UI.term.width >= 40 then if UI.term.width >= 40 then
table.insert(gridColumns, { heading = 'Uptime', key = 'uptime' }) table.insert(gridColumns, { heading = 'Uptime', key = 'uptime', align = 'right' })
end end
local page = UI.Page { local page = UI.Page {
@ -262,8 +262,10 @@ function page.grid:getDisplayValues(row)
if row.uptime then if row.uptime then
if row.uptime < 60 then if row.uptime < 60 then
row.uptime = string.format("%ds", math.floor(row.uptime)) row.uptime = string.format("%ds", math.floor(row.uptime))
elseif row.uptime < 3600 then
row.uptime = string.format("%sm", math.floor(row.uptime / 60))
else else
row.uptime = string.format("%sm", math.floor(row.uptime/6)/10) row.uptime = string.format("%sh", math.floor(row.uptime / 3600))
end end
end end
if row.fuel then if row.fuel then

View File

@ -13,6 +13,7 @@ sandboxEnv.shell = shell
_G.requireInjector(_ENV) _G.requireInjector(_ENV)
local trace = require('trace')
local Util = require('util') local Util = require('util')
local DIR = (parentShell and parentShell.dir()) or "" local DIR = (parentShell and parentShell.dir()) or ""
@ -88,7 +89,7 @@ function shell.run(...)
local env = setmetatable(Util.shallowCopy(sandboxEnv), { __index = _G }) local env = setmetatable(Util.shallowCopy(sandboxEnv), { __index = _G })
_G.requireInjector(env) _G.requireInjector(env)
local r = { pcall(run, env, ...) } local r = { trace(run, env, ...) }
if _ENV.multishell then if _ENV.multishell then
_ENV.multishell.setTitle(_ENV.multishell.getCurrent(), oldTitle or 'shell') _ENV.multishell.setTitle(_ENV.multishell.getCurrent(), oldTitle or 'shell')

View File

@ -139,7 +139,7 @@ function multishell.openTab(tab)
if err then if err then
printError(tostring(err)) printError(tostring(err))
if stacktrace then -- alternatively log stack to _debug if stacktrace then -- alternatively log stack to _debug
print('\n' .. stacktrace) --print('\n' .. stacktrace)
end end
end end
print('\nPress enter to close') print('\nPress enter to close')