# 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
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
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
#++ # 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
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
# 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
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
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