Skip to content
/ sys Public
forked from torch/sys

A system utility package for Torch.

License

Notifications You must be signed in to change notification settings

avnermay/sys

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lua system package

Note: some functions only work on UNIX systems.

Dependencies

Torch7 (www.torch.ch)

Install

$ torch-rocks install sys

Use

$ torch
> require 'sys'

Time / Clock

> t = sys.clock()  -- high precision clock (us precision)
> sys.tic()
> -- do something
> t = sys.toc()    -- high precision tic/toc
> sys.sleep(1.5)   -- sleep 1.5 seconds

Paths

> path,fname = sys.fpath()

Always returns the path of the file in which this call is made. Useful to access local resources (non-lua files).

Execute

By default, Lua's os.execute doesn't pipe its results (stdout). This function uses popen to pipe its results into a Lua string:

> res = sys.execute('ls -l')
> print(res)

Derived from this, a few commands:

> print(sys.uname())
linux

UNIX-only: shortcuts to run bash commands:

> ls()
> ll()
> lla()

sys.COLORS

If you'd like print in colours, follow the following snippets of code. Let start by listing the available colours

$ torch
> for k in pairs(sys.COLORS) do print(k) end

Then, we can generate a shortcut c = sys.COLORS and use it within a print

> c = sys.COLORS
> print(c.magenta .. 'This ' .. c.red .. 'is ' .. c.yellow .. 'a ' .. c.green .. 'rainbow' .. c.cyan .. '!')

About

A system utility package for Torch.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Lua 82.4%
  • C 14.7%
  • CMake 2.9%