def __init__(self, host, port, fileName, fileSize, stdout, dbFileName):
        mps = MPSConfig(args.database[0].name)
        self.session = mps.session
        self.host = host
        self.port = port
        self.fileName = fileName
        self.fileSize = fileSize
        self.stdout = stdout
        self.file = None

        # create dgram udp socket
        try:
            self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        except socket.error:
            print 'Failed to create socket'
            sys.exit()

        if (self.fileName != None):
            if (self.openNewLogFile() == False):
                exit(1)


#      currentFileName = '{0}-{1}.hist'.format(fileName, datetime.datetime.now().strftime('%Y.%m.%d-%H:%M:%S'))
#      try:
#          self.file = open(currentFileName, 'w')
#      except IOError as e:
#          if e.errno == errno.EACCES:
#              print 'ERROR: No permission to write file {0}'.format(currentFileName)
#          else:
#              print 'ERROR: errno={0}, cannot write to file {1}'.format(e.errno, currentFileName)
#          exit(-1)

        myAddr = (self.host, self.port)
        self.sock.bind(myAddr)
 def __init__(self, db, rt_db, verbose, print_all):
     self.mps = MPSConfig(
         args.database[0].name,
         args.database[0].name.split('.')[0] + '_runtime.db')
     self.session = self.mps.session
     self.rt_session = self.mps.runtime_session
     self.mps_names = MpsName(self.session)
     self.verbose = verbose
     self.print_all = print_all
     self.rt = RuntimeChecker(self.session, self.rt_session, self.verbose)
Example #3
0
 def __init__(self, db, rt_db, verbose, force_write, no_check=False):
     self.mps = MPSConfig(
         args.database[0].name,
         args.database[0].name.split('.')[0] + '_runtime.db')
     self.session = self.mps.session
     self.rt_session = self.mps.runtime_session
     self.mps_names = MpsName(self.session)
     self.rt = RuntimeChecker(self.session, self.rt_session, False)
     self.force_write = force_write
     self.verbose = verbose
     self.no_check = no_check
Example #4
0
 def __init__(self, dbFileName, debug, docbook):
     self.docbook = docbook
     self.databaseFileName = dbFileName
     mps = MPSConfig(args.database[0].name)
     self.session = mps.session
     self.debug = debug
     apps = self.session.query(models.ApplicationCard).\
         order_by(models.ApplicationCard.global_id.desc())
     self.highest_app_id = apps[0].global_id
     for id in range(0, self.highest_app_id + 1):
         try:
             app = self.session.query(models.ApplicationCard).\
                 filter(models.ApplicationCard.global_id == id).one()
         except:
             app = None
         self.apps.append(App(app, self.session))
Example #5
0
from mps_config import MPSConfig, models
from sqlalchemy import MetaData
#The MPSConfig object points to our database file.
conf = MPSConfig()

#Clear everything out of the database.
conf.clear_all()

#session is a connection to that database.
session = conf.session

#Save this stuff
session.commit()
Example #6
0
                    help='If provided generate screens only for the specified link node'\
                      'need --link-nodes and related options specified')

parser.add_argument('-v',
                    action='store_true',
                    default=False,
                    dest='verbose',
                    help='Verbose output')

args = parser.parse_args()
verbose = args.verbose

mps_app_reader = MpsAppReader(db_file=args.database[0].name,
                              verbose=args.verbose)

mps = MPSConfig(args.database[0].name)
session = mps.session
mps_name = MpsName(session)

link_nodes = None
link_node = None
if (args.link_nodes):
    link_nodes = session.query(models.LinkNode).all()
    create_link_node_directories(args.link_nodes, link_nodes, mps_name)
    if (args.link_node):
        link_node = args.link_node
        if (len(filter(lambda x: x.get_name() == link_node, link_nodes)) != 1):
            print 'ERROR: Can\'t find sioc named {0}'.format(link_node)
            exit(0)
        else:
            link_nodes = filter(lambda x: x.get_name() == link_node,
Example #7
0
import ioc_tools
from mps_config import MPSConfig, models
mps=MPSConfig()
ioc_tools.dump_db_to_yaml(mps,'db.yaml')
Example #8
0
    def __enter__(self):
        # Open the MPS database
        self.mps_db = MPSConfig(self.db_file)

        # Return a session to the database
        return self.mps_db.session
Example #9
0
    else:
        print 'Runtime database OK'


#    if (verbose):
#      for k,i in missing.iteritems():
#        print '  id={0} name={1}'.format(k, i)

#=== MAIN ==================================================================================

parser = argparse.ArgumentParser(
    description='Check for duplicate channel assignments')
parser.add_argument('database',
                    metavar='db',
                    type=file,
                    nargs=1,
                    help='database file name (e.g. mps_gun.db)')

args = parser.parse_args()

mps = MPSConfig(args.database[0].name,
                args.database[0].name.split('.')[0] + '_runtime.db')
session = mps.session
rt_session = mps.runtime_session

checkChannels(session)
checkLinkNodes(session)
#checkRuntime(session, rt_session)

session.close()
Example #10
0
from mps_config import MPSConfig, models
from sqlalchemy import MetaData
#The MPSConfig object points to our database file.
conf = MPSConfig(filename="huge.db")

#Clear everything out of the database.
conf.clear_all()

numMitigationDevices = 5
numChannels = 5000
channelsPerCrate = 50
#numChannels = 10
#channelsPerCrate = 10
numCrates = numChannels / channelsPerCrate
numCards = numCrates  # Yep, one card per crate
channelsPerCard = channelsPerCrate
channelsPerDevice = 2  # e.g. IN and OUT switch
devicesPerCard = channelsPerCard / channelsPerDevice
numBeamClasses = 2**(2**channelsPerDevice)

session = conf.session

# Mitigation Devices
mitigationDevices = []
for i in range(0, numMitigationDevices):
    device = models.MitigationDevice(name="Device " + str(i))
    mitigationDevices.append(device)
    session.add(device)

# Beam Classes
beamClasses = []
Example #11
0
#
# +-----+-----+-----+-----+-----+--------+
# | M1  | SL  | M2  | M3  | CP  | Beam   |
# +-----+-----+-----+-----+-----+--------+
# | In  | Any | Any | In  | On  | 120 Hz |
# +-----+-----+-----+-----+-----+--------+
# | Out | In  | Out | Out | On  | 120 Hz |
# +-----+-----+-----+-----+-----+--------+
# | Out | Out | Out | Out | Any | 120 Hz |
# +-----+-----+-----+-----+-----+--------+
# * All other combinations go to 0 Hz
#
#

#The MPSConfig object points to our database file.
conf = MPSConfig('mps_sxrss.db')

#Clear everything out of the database.
conf.clear_all()

#session is a connection to that database.
session = conf.session

#First lets define our mitigation devices.
shutter = models.MitigationDevice(name="Shutter", destination_mask=1)
session.add(shutter)

#Make some beam classes.
class_0 = models.BeamClass(number=0,
                           name="0 Hz",
                           integration_window=10,
Example #12
0
 def __init__(self, db_file_name, rt_file_name):
     self.mps = MPSConfig(db_file_name, rt_file_name)
     self.session = self.mps.session
     self.rt_session = self.mps.runtime_session
     self.mps_names = MpsName(self.session)