示例#1
0
def checkwireless():
  profiler = LocalProfilerFactory.getProfiler()
  data = profiler.profile(set(['rete']))
  for device in data.findall('rete/NetworkDevice'):
    logger.debug(ET.tostring(device))
    status = device.find('Status').text
    if (status == 'Enabled'):
        type = device.find('Type').text
        if (type == 'Wireless'):
            raise sysmonitorexception.WARNWLAN
  return True
示例#2
0
def getResProperty(tag, res):
  data = ET.ElementTree()
  try:
      profiler = LocalProfilerFactory.getProfiler()
      data = profiler.profile(set([res]))
  except Exception as e:
    logger.error('Non sono riuscito a trovare lo stato del computer con profiler: %s.' % e)
    raise sysmonitorexception.FAILPROF
  except RisorsaException as e:
    logger.error ("Problema nel tentativo di istanziare la risorsa: %s" % e)
    raise sysmonitorexception.FAILPROF
  except LocalProfilerException as e:
    logger.error ("Problema nel tentativo di istanziare il profiler: %s" % e)
    raise sysmonitorexception.FAILPROF
  wtf = res + '/' + tag
  return data.findall(wtf)
示例#3
0
def getstatus(res):

  logger.debug('Recupero stato della risorsa %s' % res)
  data = ET.ElementTree()
  try:
      profiler = LocalProfilerFactory.getProfiler()
      data = profiler.profile(set([res]))
  except FactoryException as e:
    logger.error ("Problema nel tentativo di istanziare la classe: %s" % e)
    raise sysmonitorexception.FAILPROF
  except RisorsaException as e:
    logger.error ("Problema nel tentativo di istanziare la risorsa %s: %s" % (str(res), e))
    raise sysmonitorexception.FAILPROF
  except LocalProfilerException as e:
    logger.error ("Problema nel tentativo di istanziare il profiler: %s" % e)
    raise sysmonitorexception.FAILPROF
  except Exception as e:
    logger.error('Non sono riuscito a trovare lo stato del computer con SystemProfiler: %s.' % e)
    raise sysmonitorexception.FAILPROF

  return _getvalues(data, tag_results, res)
示例#4
0
def getMac():
  '''
  restituisce indirizzo MAC del computer
  '''
  tag = tag_activeNic.split('.');
  res = tag[0]
  nestedtag = tag[1].split('/')
  tagdev = nestedtag[0]
  tagprop = nestedtag[1]

  tag = tag_mac.split('.');
  nestedtag = tag[1].split('/')
  tagmac = nestedtag[1]

  data = ET.ElementTree()
  try:
      profiler = LocalProfilerFactory.getProfiler()
      data = profiler.profile(set([res]))
  except Exception as e:
    logger.error('Non sono riuscito a trovare lo stato del computer con profiler: %s.' % e)
    raise sysmonitorexception.FAILPROF
  except RisorsaException as e:
    logger.error ("Problema nel tentativo di istanziare la risorsa: %s" % e)
    raise sysmonitorexception.FAILPROF
  except LocalProfilerException as e:
    logger.error ("Problema nel tentativo di istanziare il profiler: %s" % e)
    raise sysmonitorexception.FAILPROF
  tree = ET.ElementTree(data)
  whattolook = res + '/' + tagdev
  listdev = data.findall(whattolook)
  for dev in listdev:
    tree._setroot(dev)
    devxml = tree.getroot()
    val = devxml.find(tagprop)
    if val.text == 'True':
      macelem = devxml.find(tagmac)
      return macelem.text
  return None
示例#5
0
from distutils.core import setup
import py2exe
import sys, os
from SysProf.windows import profiler
from xml.etree import ElementTree as ET
import modulefinder
from glob import glob

sys.path.append("C:\\Microsoft.VC90.CRT")

data_files = [("Microsoft.VC90.CRT", glob(r'C:\Microsoft.VC90.CRT\*.*'))]

profiler = profiler.Profiler()
data = profiler.profile({'CPU'})
print ET.tostring(data)


class Target:
    def __init__(self, **kw):
        self.__dict__.update(kw)
        # for the versioninfo resources
        self.version = "2.2.1"
        self.company_name = "Fondazione Ugo Bordoni"
        self.copyright = "(c)2010-2013 Fondazione Ugo Bordoni"
        self.name = "Nemesys"


myservice = Target(
    # used for the versioninfo resource
    description="Nemesys Service",
    # what to build.  For a service, the module name (not the