Exemplo n.º 1
0
path    = sos.path

def gen (pref, dols, pred) :
    for d in dols :
        dol = path.join (pref, d) if pref else d
        if path.islink (dol) :
            dol = path.realpath (dol)
        if path.isdir (dol) :
            if pred (dol) :
                yield d
            elif path.exists (path.join (dol, ".VX")):
                for r in gen (dol, sos.listdir (dol), pred) :
                    yield path.join (d, r)
# end def gen

def _Command () :
    result     = set ()
    add        = result.update
    opts, args = LNX.options.split (sys.argv [1:])
    for a in args :
        for dol in sos.expanded_glob (a) :
            add (gen ("", [dol], LNX.vcs_typer))
    print ("\n".join (sorted (result)))
# end def _main

if __name__ != "__main__" :
    LNX._Export_Module ()
if __name__ == "__main__" :
    _Command ()
### __END__ LNX.VCS_Finder
Exemplo n.º 2
0
                        map[kk] = v

    # end def _setup

    def __getattr__(self, name):
        if self._dict is None:
            self._setup()
        result = self._dict[name]
        setattr(self, name, result)
        return result

    # end def __getattr__

    def __getitem__(self, key):
        if self._dict is None:
            self._setup()
        return self._dict[key]

    # end def __getitem__


# end class _Cpu_Info_

cpu_info = _Cpu_Info_()

if __name__ != "__main__":
    LNX._Export("cpu_info")
else:
    print "%(model name)s/%(cpu MHz)s" % cpu_info
### __END__ LNX.cpu_info
Exemplo n.º 3
0
    # end def _get_total

    def __str__ (self) :
        result = []
        for i, b in enumerate (self.batteries) :
            result.append \
                ( "Battery #%d    : %12s, %6.2f%%, %2.2d:%2.2d, %7s / %7s"
                % ( i, b.bat_status
                  , b.percent or 0, b.hours or 0, b.minutes or 0
                  , b.remaining_capacity, b.full_capacity
                  )
                )
        t = self.total
        result.append \
            ( "All batteries : %12s, %6.2f%%, %2.2d:%2.2d, %7s / %7s"
            % ( t.bat_status
              , t.percent or 0, t.hours or 0, t.minutes or 0
              , t.remaining_capacity, t.full_capacity
              )
            )
        return "\n".join (result)
    # end def __str__

# end class Bat_Charge

if __name__ != "__main__" :
    LNX._Export ("*")
if __name__ == "__main__" :
    print Bat_Charge ()
### __END__ Bat_Charge
Exemplo n.º 4
0
                    map [k] = v
                    keys.add (k)
                    kk = self._space_rep (k)
                    if kk != k :
                        map [kk] = v
    # end def _setup

    def __getattr__ (self, name) :
        if self._dict is None :
            self._setup ()
        result = self._dict [name]
        setattr (self, name, result)
        return result
    # end def __getattr__

    def __getitem__ (self, key) :
        if self._dict is None :
            self._setup ()
        return self._dict [key]
    # end def __getitem__

# end class _Cpu_Info_

cpu_info = _Cpu_Info_ ()

if __name__ != "__main__" :
    LNX._Export ("cpu_info")
else :
    print "%(model name)s/%(cpu MHz)s" % cpu_info
### __END__ LNX.cpu_info
Exemplo n.º 5
0
from   __future__  import unicode_literals

from   _LNX           import LNX
from   _TFL           import TFL

from   _TFL.predicate import dusplit

import sys

def split (argv) :
    try :
        eoo = argv.index ("--")
    except ValueError :
        args, opts = dusplit (argv, lambda x : x.startswith ("-"), 2)
    else :
        opts = argv [:eoo]
        args = argv [eoo + 1:]
    return opts, args
# end def split

def _Command () :
    opts, args = split (sys.argv [1:])
    print (" ".join (opts))
# end def _Command

if __name__ != "__main__" :
    LNX._Export_Module ()
if __name__ == "__main__" :
    _Command ()
### __END__ LNX.options
Exemplo n.º 6
0
#++
# Name
#    up_since
#
# Purpose
#    Provide the date/time at which the kernel was booted
#
# Revision Dates
#    10-Nov-2010 (CT) Creation
#    ««revision-date»»···
#--

import datetime


def up_since():
    now = datetime.datetime.now()
    with open("/proc/uptime") as f:
        since = float(f.readline().split()[0])
    return now - datetime.timedelta(seconds=since)


# end def up_since

if __name__ != "__main__":
    from _LNX import LNX
    LNX._Export("up_since")
else:
    print up_since().strftime("%Y/%m/%d %H:%M")
### __END__ up_since
Exemplo n.º 7
0
    def add_type(self, name, repo_dir_name):
        self.type_map[name] = repo_dir_name

    # end def add_type


# end class VCS_Typer

vcs_typer = VCS_Typer(cvs="CVS", git=".git", hg=".hg", svn=".svn")


def _main(cmd):
    result = vcs_typer(cmd.arg)
    if result:
        print result
    else:
        raise SystemExit(9)


# end def _main

_Command = TFL.CAO.Cmd(
    handler=_main, args=("arg:P?Path to repository",), min_args=1, max_args=1, description="Identify type of repository"
)

if __name__ != "__main__":
    LNX._Export("*", "vcs_typer")
if __name__ == "__main__":
    _Command()
### __END__ LNX.VCS_Typer
Exemplo n.º 8
0
#    LNX.up_since
#
# Purpose
#    Provide the date/time at which the kernel was booted
#
# Revision Dates
#    10-Nov-2010 (CT) Creation
#    22-Mar-2018 (CT) Make Python-3 compatible
#    ««revision-date»»···
#--

from   __future__  import absolute_import
from   __future__  import division
from   __future__  import print_function

import datetime

def up_since () :
    now = datetime.datetime.now ()
    with open ("/proc/uptime") as f :
        since = float (f.readline ().split () [0])
    return now - datetime.timedelta (seconds = since)
# end def up_since

if __name__ != "__main__" :
    from _LNX import LNX
    LNX._Export ("up_since")
else :
    print (up_since ().strftime ("%Y/%m/%d %H:%M"))
### __END__ LNX.up_since
Exemplo n.º 9
0
vcs_typer = VCS_Typer \
    ( cvs      = "CVS"
    , git      = ".git"
    , hg       = ".hg"
    , svn      = ".svn"
    )

def _main (cmd) :
    result = vcs_typer (cmd.arg)
    if result :
        print (result)
    else :
        raise SystemExit (9)
# end def _main

_Command = TFL.CAO.Cmd \
    ( handler       = _main
    , args          =
        ( "arg:P?Path to repository", )
    , min_args      = 1
    , max_args      = 1
    , description   = "Identify type of repository"
    )

if __name__ != "__main__" :
    LNX._Export ("*", "vcs_typer")
if __name__ == "__main__" :
    _Command ()
### __END__ LNX.VCS_Typer
Exemplo n.º 10
0
    def __str__(self):
        result = []
        for i, b in enumerate(self.batteries):
            result.append \
                ( "Battery #%d    : %12s, %6.2f%%, %2.2d:%2.2d, %7s / %7s"
                % ( i, b.bat_status
                  , b.percent or 0, b.hours or 0, b.minutes or 0
                  , b.remaining_capacity, b.full_capacity
                  )
                )
        t = self.total
        result.append \
            ( "All batteries : %12s, %6.2f%%, %2.2d:%2.2d, %7s / %7s"
            % ( t.bat_status
              , t.percent or 0, t.hours or 0, t.minutes or 0
              , t.remaining_capacity, t.full_capacity
              )
            )
        return "\n".join(result)

    # end def __str__


# end class Bat_Charge

if __name__ != "__main__":
    LNX._Export("*")
if __name__ == "__main__":
    print(Bat_Charge())
### __END__ Bat_Charge