Example #1
0
#!/usr/bin/python
import os
import sys
import isys
USE_ISYS = False

# only mount dev and umount dev dolog, so we use server Logger
from miutils.milogger import ServerLogger_Long
Log = ServerLogger_Long.get_instance(ServerLogger_Long, __name__)
dolog = Log.i

class AttrDict(dict):
    """A dict class, holding the dict. Two extra method to get dict
    value, e.g.:
    attrs = attrs_dict(cat)
    attrs.tips
    attrs('tips')"""
    def __init__(self, d={}):
        self.d = d
    def __call__(self, arg):
        return self.get(arg, None)
    def __getattr__(self, attr):
        return self.get(attr, None)

class NamedTuple(tuple):
    """Access a tuple by attribute name. e.g.:
    class AutoPartTuple(NamedTuple):
        attr_oder = ['mountpoint', 'size', 'filesystem']

    part = ('/', '32G', 'ext2')
    part = AutoPartTuple(part)
Example #2
0
 def get_instance(TAG):
     return ServerLogger_Long.get_instance(ServerLogger_Long, TAG)