syspy  0.1
syspy windows system information tool with python
syspy.info.info.Info Class Reference

Public Member Functions

def __init__ (self)
 
def getUsers (self)
 
def getBootTime (self)
 
def getProcessIter (self)
 

Detailed Description

Definition at line 10 of file info.py.

Constructor & Destructor Documentation

def syspy.info.info.Info.__init__ (   self)

Definition at line 12 of file info.py.

Here is the call graph for this function:

Member Function Documentation

def syspy.info.info.Info.getBootTime (   self)
Return the system boot time expressed in seconds since the epoch.

Definition at line 64 of file info.py.

Here is the caller graph for this function:

def syspy.info.info.Info.getProcessIter (   self)
Return an iterator yielding a Process class instance for all running processes on the local machine.
Every instance is only created once and then cached into an internal
table which is updated every time an element is yielded.
Cached Process instances are checked for identity so that you’re
safe in case a PID has been reused by another process,
in which case the cached instance is updated.
This is should be preferred over psutil.pids() for iterating over processes.

    >>> for proc in psutil.process_iter():
    ...     try:
    ...             pinfo = proc.as_dict(attrs=['pid', 'name'])
    ...     except psutil.NoSuchProcess:
    ...             pass
    ...     else:
    ...             print(pinfo)
    ...
    {'pid': 0, 'name': 'System Idle Process'}
    {'pid': 4, 'name': 'System'}
    {'pid': 216, 'name': None}
    {'pid': 252, 'name': None}
    {'pid': 404, 'name': None}
    {'pid': 488, 'name': None}
    {'pid': 500, 'name': None}
    {'pid': 544, 'name': None}
    {'pid': 568, 'name': None}

Definition at line 72 of file info.py.

Here is the caller graph for this function:

def syspy.info.info.Info.getUsers (   self)
Return users currently connected on the system as a list of namedtuples including the following fields:

user: the name of the user.
terminal: the tty or pseudo-tty associated with the user, if any, else None.
host: the host name associated with the entry, if any.
started: the creation time as a floating point number expressed in seconds since the epoch.

    >>> import psutil
    >>> psutil.users()
    [suser(name='ali', terminal=None, host='0.0.0.0', started=1430050230.0)]
    >>> lusers = list(psutil.users())
    >>> lusers
    [suser(name='ali', terminal=None, host='0.0.0.0', started=1430050230.0)]
    >>> lusers[0]
    suser(name='ali', terminal=None, host='0.0.0.0', started=1430050230.0)
    >>> lusers[0][1]
    >>> lusers[0][0]
    'ali'
    >>> lusers[0][3]
    1430050230.0
    >>> lusers[0][3]..strftime("%Y-%m-%d %H:%M:%S")
      File "<stdin>", line 1
lusers[0][3]..strftime("%Y-%m-%d %H:%M:%S")
             ^
    SyntaxError: invalid syntax
    >>> lusers[0][3].strftime("%Y-%m-%d %H:%M:%S")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'float' object has no attribute 'strftime'
    >>> import datetime
    >>> datetime.datetime.fromtimestamp(lusers[0][3].strftime("%Y-%m-%d %H:%M:%S"))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    AttributeError: 'float' object has no attribute 'strftime'
    >>>

Definition at line 17 of file info.py.

Here is the caller graph for this function:


The documentation for this class was generated from the following file: