Exemplo n.º 1
0
 def __init__(self, database_filename):
     self._database_filename = database_filename
     self._config = ConfigParser.RawConfigParser()
     self._config.read(self._database_filename)
     if not self._config.has_section(_SECTION):
         self._config.add_section(_SECTION)
     self.hw_uuid_file = get_config_attr('HW_UUID', '/etc/smolt/hw-uuid')
Exemplo n.º 2
0
 def __init__(self, database_filename):
     self._database_filename = database_filename
     self._config = configparser.RawConfigParser()
     self._config.read(self._database_filename)
     if not self._config.has_section(_SECTION):
         self._config.add_section(_SECTION)
     self.hw_uuid_file = get_config_attr('HW_UUID', '/etc/smolt/hw-uuid')
Exemplo n.º 3
0
def UuidDb():
    """Simple singleton wrapper with lazy initialization"""
    global _uuid_db_instance
    if _uuid_db_instance is None:
        import config
        from smolt import get_config_attr
        _uuid_db_instance =  _UuidDb(get_config_attr("UUID_DB", os.path.expanduser('~/.smolt/uuiddb.cfg')))
    return _uuid_db_instance
Exemplo n.º 4
0
def UuidDb():
    """Simple singleton wrapper with lazy initialization"""
    global _uuid_db_instance
    if _uuid_db_instance == None:
        import config
        from smolt import get_config_attr
        _uuid_db_instance =  _UuidDb(get_config_attr("UUID_DB", os.path.expanduser('~/.smolt/uuiddb.cfg')))
    return _uuid_db_instance
Exemplo n.º 5
0
    def device_map(self, bus='pci'):
        import os
        HWDATA_DIRS = [ get_config_attr("HWDATA_DIR"), '/usr/share/hwdata','/usr/share/misc' ]
        for hwd_file in HWDATA_DIRS:
            fn = "%s/%s.ids" % (hwd_file, bus)
            if os.path.isfile(fn + ".gz"):
                import gzip
                try:
                    fo = gzip.open(fn + ".gz", 'r')
                    break
                except IOError:
                    pass
            else:
                try:
                    fo = open(fn, 'r')
                    break
                except IOError:
                    pass
        else:
            raise Exception('Hardware data file not found.  Please set the location HWDATA_DIR in config.py')
         
            
            
        vendors = {}
        curvendor = None
        curdevice = None
        for line in fo.readlines():
            if line.startswith('#') or not line.strip():
                continue
            elif not line.startswith('\t'):
                curvendor = myVendor()
                try:
                    curvendor.num = int(line[0:4], 16)
                except:
                    continue
                curvendor.name = line[6:-1]
                vendors[curvendor.num] = curvendor
                continue

            elif line.startswith('\t\t'):
                line = line.replace('\t', '')
                thisdev = myDevice()
                try:
                    thisdev.vendor = int(line[0:4], 16)
                except:
                    continue
                try:
                    thisdev.num = int(line[5:9], 16)
                except:
                    continue
                thisdev.name = line[11:-1]
                subvend = myVendor()
                try:
                    subvend.num = thisdev.vendor
                except:
                    continue
                subvend.name = ""

                if not curdevice.subvendors.has_key(subvend.num):
                    curdevice.subvendors[subvend.num] = subvend
                    subvend.devices[thisdev.num] = thisdev
                else:
                    subvend = curdevice.subvendors[subvend.num]
                    subvend.devices[thisdev.num] = thisdev

                continue

            elif line.startswith('\t'):
                line = line.replace('\t', '')
                curdevice = myDevice()
                try:
                    curdevice.num = int(line[0:4], 16)
                except:
                    continue
                curdevice.name = line[6:-1]
                try:
                    curdevice.vendor = int(curvendor.num)
                except:
                    continue
                curvendor.devices[curdevice.num] = curdevice
                continue
            else:
                print line
                continue
        fo.close()
        # This introduces a bug, will fix later.
#        vendors[0] = myVendor()
#        vendors[0].name = 'N/A'
        return vendors
Exemplo n.º 6
0
def read_os():
    return smolt_config.get_config_attr("OS", "Calvin and Hobbes")
Exemplo n.º 7
0
    def device_map(self, bus='pci'):
        import os
        HWDATA_DIRS = [
            get_config_attr("HWDATA_DIR"), '/usr/share/hwdata',
            '/usr/share/misc', '/usr/share/'
        ]
        for hwd_file in HWDATA_DIRS:
            fn = "%s/%s.ids" % (hwd_file, bus)
            if os.path.isfile(fn + ".gz"):
                import gzip
                try:
                    fo = gzip.open(fn + ".gz", 'r')
                    break
                except IOError:
                    pass
            else:
                try:
                    fo = open(fn, 'r')
                    break
                except IOError:
                    pass
        else:
            raise Exception(
                'Hardware data file not found.  Please set the location HWDATA_DIR in config.py'
            )

        vendors = {}
        curvendor = None
        curdevice = None
        for line in fo.readlines():
            if line.startswith('#') or not line.strip():
                continue
            elif not line.startswith('\t'):
                curvendor = myVendor()
                try:
                    curvendor.num = int(line[0:4], 16)
                except:
                    continue
                curvendor.name = line[6:-1]
                vendors[curvendor.num] = curvendor
                continue

            elif line.startswith('\t\t'):
                line = line.replace('\t', '')
                thisdev = myDevice()
                try:
                    thisdev.vendor = int(line[0:4], 16)
                except:
                    continue
                try:
                    thisdev.num = int(line[5:9], 16)
                except:
                    continue
                thisdev.name = line[11:-1]
                subvend = myVendor()
                try:
                    subvend.num = thisdev.vendor
                except:
                    continue
                subvend.name = ""

                if not curdevice.subvendors.has_key(subvend.num):
                    curdevice.subvendors[subvend.num] = subvend
                    subvend.devices[thisdev.num] = thisdev
                else:
                    subvend = curdevice.subvendors[subvend.num]
                    subvend.devices[thisdev.num] = thisdev

                continue

            elif line.startswith('\t'):
                line = line.replace('\t', '')
                curdevice = myDevice()
                try:
                    curdevice.num = int(line[0:4], 16)
                except:
                    continue
                curdevice.name = line[6:-1]
                try:
                    curdevice.vendor = int(curvendor.num)
                except:
                    continue
                curvendor.devices[curdevice.num] = curdevice
                continue
            else:
                print line
                continue
        fo.close()
        # This introduces a bug, will fix later.
        #        vendors[0] = myVendor()
        #        vendors[0].name = 'N/A'
        return vendors
Exemplo n.º 8
0
def create_default_uuiddb():
    from smolt_config import get_config_attr
    _database_filename = get_config_attr(
        "UUID_DB", os.path.expanduser('~/.smolt/uuiddb.cfg'))
    return _UuidDb(_database_filename)
Exemplo n.º 9
0
Arquivo: smolt.py Projeto: yvlf/mythtv
from logging.handlers import RotatingFileHandler
import codecs
import MultipartPostHandler
import urllib2

try:
    import subprocess
except ImportError, e:
    pass

WITHHELD_MAGIC_STRING = 'WITHHELD'
SELINUX_ENABLED = 1
SELINUX_DISABLED = 0
SELINUX_WITHHELD = -1

fs_types = get_config_attr("FS_TYPES", ["ext2", "ext3", "xfs", "reiserfs"])
fs_mounts = dict.fromkeys(
    get_config_attr("FS_MOUNTS", ["/", "/home", "/etc", "/var", "/boot"]),
    True)
fs_m_filter = get_config_attr("FS_M_FILTER", False)
fs_t_filter = get_config_attr("FS_T_FILTER", False)

smoonURL = get_config_attr("SMOON_URL", "http://smolts.org/")
secure = get_config_attr("SECURE", 0)
hw_uuid_file = get_config_attr("HW_UUID", "/etc/smolt/hw-uuid")
admin_token_file = get_config_attr("ADMIN_TOKEN", '')

clientVersion = '1.3.2'
smoltProtocol = '0.97'
supported_protocols = [
    '0.97',
Exemplo n.º 10
0
    for page in r['query']['pages']:
        try:
            if int(page) > 0:
                found.append('\t%swiki/%s' %
                             (smoonURL, r['query']['pages'][page]['title']))
        except KeyError:
            pass

    if found:
        print(_("\tErrata Found!"))
        for f in found:
            print("\t%s" % f)
    else:
        print(
            _("\tNo errata found, if this machine is having issues please go to"
              ))
        print(
            _("\tyour profile and create a wiki page for the device so others can"
              ))
        print(_("\tbenefit"))


if __name__ == "__main__":
    from gate import create_passing_gate
    gate = create_passing_gate()
    smoonURL = get_config_attr("SMOON_URL", "http://smolts.org/")
    profile = smolt.create_profile(gate, smolt.read_uuid())
    scan(profile, smoonURL, gate)
    rating(profile, smoonURL, gate)
Exemplo n.º 11
0
import MultipartPostHandler
import urllib2

try:
    import subprocess
except ImportError, e:
    pass


WITHHELD_MAGIC_STRING = 'WITHHELD'
SELINUX_ENABLED = 1
SELINUX_DISABLED = 0
SELINUX_WITHHELD = -1


fs_types = get_config_attr("FS_TYPES", ["ext2", "ext3", "xfs", "reiserfs"])
fs_mounts = dict.fromkeys(get_config_attr("FS_MOUNTS", ["/", "/home", "/etc", "/var", "/boot"]), True)
fs_m_filter = get_config_attr("FS_M_FILTER", False)
fs_t_filter = get_config_attr("FS_T_FILTER", False)

smoonURL = get_config_attr("SMOON_URL", "http://smolts.org/")
secure = get_config_attr("SECURE", 0)
hw_uuid_file = get_config_attr("HW_UUID", "/etc/smolt/hw-uuid")
admin_token_file = get_config_attr("ADMIN_TOKEN", '' )

clientVersion = '1.3.2'
smoltProtocol = '0.97'
supported_protocols = ['0.97',]
user_agent = 'smolt/%s' % smoltProtocol
timeout = 120.0
proxies = None
Exemplo n.º 12
0
def create_default_uuiddb():
    from smolt_config import get_config_attr
    _database_filename = get_config_attr("UUID_DB", os.path.expanduser('~/.smolt/uuiddb.cfg'))
    return _UuidDb(_database_filename)
Exemplo n.º 13
0
    scanData = 'action=query&titles=%s&format=json' % searchDevices
    try:
         r = json.load(urllib.urlopen(scanURL, scanData))
    except ValueError:
        print "Could not wiki for errata!"
        return
    found = []

    for page in r['query']['pages']:
        try:
            if int(page) > 0:
                found.append('\t%swiki/%s' % (smoonURL, r['query']['pages'][page]['title']))
        except KeyError:
            pass

    if found:
        print _("\tErrata Found!")
        for f in found: print "\t%s" % f
    else:
        print _("\tNo errata found, if this machine is having issues please go to")
        print _("\tyour profile and create a wiki page for the device so others can")
        print _("\tbenefit")
      
if __name__ == "__main__":  
    from gate import create_passing_gate
    gate = create_passing_gate()
    smoonURL = get_config_attr("SMOON_URL", "http://smolts.org/")
    profile = smolt.create_profile(gate, smolt.read_uuid())
    scan(profile, smoonURL, gate)
    rating(profile, smoonURL, gate)
Exemplo n.º 14
0
def read_os():
    return smolt_config.get_config_attr("OS", "Calvin and Hobbes")