Ejemplo n.º 1
0
    print("C++ FMU OK")
  else:
    print("No C++-based FMUs (files not generated in correct location)")
except subprocess.CalledProcessError as e:
  pass

try:
  os.unlink("HelloWorld")
except OSError:
  pass
print(subprocess.check_output(["%s/bin/omc" % omhome, "HelloWorld.mos"], stderr=subprocess.STDOUT))
assert(os.path.exists("HelloWorld"))
abortSimulationFlag="-abortSlowSimulation" if simulationAcceptsFlag("-abortSlowSimulation") else ""
alarmFlag="-alarm" if simulationAcceptsFlag("-alarm=480") else ""

configs_lst = [readConfig(c, rmlStyle=rmlStyle, abortSimulationFlag=abortSimulationFlag, alarmFlag=alarmFlag, overrideDefaults=overrideDefaults, defaultCustomCommands=defaultCustomCommands) for c in configs]
configs = []
preparedReferenceDirs = {}
for c in configs_lst:
  configs = configs + c
for (lib,c) in configs:
  if "referenceFiles" in c:
    c["referenceFilesURL"] = c["referenceFiles"]
    if isinstance(c["referenceFiles"], basestring):
      m = re.search("^[$][A-Z]+", c["referenceFiles"])
      if m:
        k = m.group(0)[1:]
        if k not in os.environ:
          raise Exception("Environment variable %s not defined, but used in JSON config for reference files" % k)
        c["referenceFiles"] = c["referenceFiles"].replace(m.group(0), os.environ[k])
    elif "giturl" in c["referenceFiles"]:
Ejemplo n.º 2
0
if configs == []:
  raise Exception("Error: Expected at least one configuration file to start the library test")

branches = [br.split("/")[-1] for br in args.branches.split(" ")]

dates = {}
dates_str = {}
fields = ["exectime", "parsing", "frontend", "backend", "simcode", "templates", "compile", "simulate", "verify"]
entryhead = "<tr><th>Branch</th><th>Total</th><th>Parsing</th><th>Frontend</th><th>Backend</th><th>SimCode</th><th>Templates</th><th>Compilation</th><th>Simulation</th><th>Verification</th>\n"

libs = {}

import cgi, sqlite3, time, datetime
from omcommon import friendlyStr, multiple_replace

configs_lst = [shared.readConfig(c) for c in configs]
configs = []
for c in configs_lst:
  configs = configs + c
libnames = set(shared.libname(library,conf) for (library,conf) in configs)

conn = sqlite3.connect('sqlite3.db')
cursor = conn.cursor()

nmodels = {}
nsimulate = {}
exectime = {}

for branch in branches:
  cursor.execute("SELECT date FROM [%s] ORDER BY date DESC LIMIT 1" % branch)
  v = cursor.fetchone()[0]
try:
    os.unlink("HelloWorld")
except OSError:
    pass
print(
    subprocess.check_output(omc_cmd + ["HelloWorld.mos"],
                            stderr=subprocess.STDOUT).decode().strip())
assert (os.path.exists("HelloWorld"))
abortSimulationFlag = "-abortSlowSimulation" if simulationAcceptsFlag(
    "-abortSlowSimulation") else ""
alarmFlag = "-alarm" if simulationAcceptsFlag("-alarm=480") else ""

configs_lst = [
    readConfig(c,
               abortSimulationFlag=abortSimulationFlag,
               alarmFlag=alarmFlag,
               overrideDefaults=overrideDefaults,
               defaultCustomCommands=defaultCustomCommands,
               extrasimflags=extrasimflags) for c in configs
]
configs = []
preparedReferenceDirs = {}
for c in configs_lst:
    configs = configs + c
for (lib, c) in configs:
    if "referenceFiles" in c:
        c["referenceFilesURL"] = c["referenceFiles"]
        if isinstance(c["referenceFiles"], (str, bytes)):
            m = re.search("^[$][A-Z]+", c["referenceFiles"])
            if m:
                k = m.group(0)[1:]
                if k not in os.environ:
Ejemplo n.º 4
0
 def elab(self, rel_page, post=False):
     if "?" in rel_page:
         rel_page, args=rel_page.split("?")[0], rel_page.split("?")[1]
     else:
         args=""
     page=config.paths.webdisk+rel_page
     if page[-1]=="/":
         for e in config.misc.index_search_order:
             if os.path.exists(page+"index"+e):
                 page+="index"+e
                 rel_page+="index"+e
                 break
     if   "gzip"    in self.header("Accept-Encoding"): self.compression = "gzip"
     elif "deflate" in self.header("Accept-Encoding"): self.compression = "deflate"
     page=shared.decodeurl(page)
     cfg=None
     dir=""
     adm=False
     fold=rel_page.split(os.sep)
     for i in range(len(fold)):
         f=fold[i]
         dir=os.path.join(dir, f)
         if os.path.exists(os.path.join(config.paths.webdisk, dir, config.paths.folder_cfg)):
             adm=False
             cfg=shared.readConfig(os.path.join(config.paths.webdisk, dir, config.paths.folder_cfg))
             for e in cfg:
                 adm=adm or cfg[e].is_admin_script
                 if adm: break
             if adm:
                 page=os.path.join(config.paths.webdisk, dir, e)
                 cfg=cfg[e]
                 break
     if adm:
         debug(I, "[%s][%d] Folderscript trovato \"%s\"", self.addr, self.dbgnum, e)
     else:
         debug(D, "[%s][%d] Richiesto file \"%s\"", self.addr, self.dbgnum, rel_page)
         cfg=None
     ispage=ispyml=False
     for e in config.misc.index_search_order:
         try:
             ispage=page.split(".")[-1] in e
             ispyml=ispage and "py" in page.split(".")[-1] 
             if ispage:
                 break
         except:pass
     self.state=self.S_PREPARING
     if os.path.isdir(page):
         debug(I, "[%s][%d] Index file non trovato, invio 404", self.addr, self.dbgnum)
         self.sendError(404)
     elif os.path.exists(page):
         if not cfg:
             cfg=os.path.join(os.path.split(page)[0], config.paths.folder_cfg)
             cfg=shared.readConfig(cfg)[os.path.split(page)[1]]
         if ispage:
             if ispyml:
                 pdata=""
                 if post and cfg.receive_post:
                     self.state=self.S_RECEIVING_POST
                     try:
                         plen=int(self.header("Content-Length"))
                         if plen:
                             debug(I, "[%s][%d] Ricezione dati da POST (%d bytes)", self.addr, self.dbgnum, plen)
                             pdata=""
                             while plen > config.buffers.tcp_receive_buffer:
                                 pdata+=self.cl.recv(config.buffers.tcp_receive_buffer)
                                 plen-=config.buffers.tcp_receive_buffer
                             if plen: pdata+=self.cl.recv(plen)
                         else:
                             debug(I, "[%s][%d] POST vuoto", self.addr, self.dbgnum)
                             pdata=""
                     except:
                         debug(I, "[%s][%d] Ricezione dati da POST (? bytes)", self.addr, self.dbgnum)
                         pdata=""
                         precvd=self.cl.recv(config.buffers.post_undefined_length)
                         while precvd:
                             pdata+=precvd
                             precvd=self.cl.recv(config.buffers.post_undefined_length)
                     debug(D, "[%s][%d] Ricevuti %d bytes da POST", self.addr, self.dbgnum, len(pdata))
                 if cfg.is_admin_script:
                     cfg["request_page"]=os.sep.join(fold[i+1:])
                 pyml.PyMl(page, self.request, args, pdata, self.header, self.cl, cfg)
                 self.state=self.S_TERMINATED
             else:
                 if adm:  debug(I, "[%s][%d] folderscript ignorato: %s non PyMl", self.addr, self.dbgnum, page)
                 if post: debug(I, "[%s][%d] POST ignorato: %s non PyMl", self.addr, self.dbgnum, page)
                 p=self.preparePage(page, rel_page, cfg)
                 self.state=self.S_SENDING
                 if p:
                     debug(I, "[%s][%d] Pagina trovata, invio...(text/html)", self.addr, self.dbgnum)
                     self.cl.send("HTTP/1.1 200 OK\r\nLocation: %s\r\nContent-Length: %d\r\nContent-Type: text/html; charset=%s\r\nContent-Encoding: %s\r\n%sConnection: close\r\n\r\n"%(self.header("Host"), p.size(), self.coding.upper(), p.compression(), shared.generateDate()))
                     if self.request!="HEAD":
                         if self.send(str(p)): return
                 else:
                     debug(E, "[%s][%d] Errore interno, invio 500...", self.addr, self.dbgnum)
                     self.sendError(500)
         else:
             if adm:  debug(I, "[%s][%d] folderscript ignorato: %s non PyMl", self.addr, self.dbgnum, page)
             if post: debug(I, "[%s][%d] POST ignorato: %s non PyMl", self.addr, self.dbgnum, page)
             p=self.prepareFile(page, rel_page, cfg)
             for d in p:
                 if d == False:
                     debug(E, "[%s][%d] Errore interno, invio 500...", self.addr, self.dbgnum)
                     self.sendError(500)
                     break
                 elif type(d)==list:
                     debug(I, "[%s][%d] File trovato, streaming%s...(%s)", self.addr, self.dbgnum, " porzione" if "206" in d[2] else "", d[1])
                     self.cl.send("HTTP/1.1 %s\r\nLocation: %s\r\n%sContent-Type: %s; charset=%s\r\nContent-Encoding: %s\r\n%sConnection: close\r\n\r\n"%(d[2], self.header("Host"), ("Content-Length: %d\r\n"%d[0]) if d[0] >= 0 else "", d[1], self.coding.upper(), d[3], shared.generateDate()))
                     self.state=self.S_STREAMING
                 elif d:
                     if self.send(d): return
     else:
         debug(I, "[%s][%d] File non trovato, invio 404...", self.addr, self.dbgnum)
         self.sendError(404)
     debug(I, "[%s][%d] Client scollegato per fine comunicazione", self.addr, self.dbgnum)
     self.cl.close()
     self.state=self.S_TERMINATED
Ejemplo n.º 5
0
try:
    os.unlink("HelloWorld")
except OSError:
    pass
print(
    subprocess.check_output(["%s/bin/omc" % omhome, "HelloWorld.mos"],
                            stderr=subprocess.STDOUT))
assert (os.path.exists("HelloWorld"))
abortSimulationFlag = "-abortSlowSimulation" if simulationAcceptsFlag(
    "-abortSlowSimulation") else ""
alarmFlag = "-alarm" if simulationAcceptsFlag("-alarm=480") else ""

configs_lst = [
    readConfig(c,
               rmlStyle=rmlStyle,
               abortSimulationFlag=abortSimulationFlag,
               alarmFlag=alarmFlag,
               defaultCustomCommands=defaultCustomCommands) for c in configs
]
configs = []
for c in configs_lst:
    configs = configs + c
for (lib, c) in configs:
    if "referenceFiles" in c:
        m = re.search("^[$][A-Z]+", c["referenceFiles"])
        if m:
            k = m.group(0)[1:]
            if k not in os.environ:
                raise Exception(
                    "Environment variable %s not defined, but used in JSON config for reference files"
                    % k)