示例#1
0
    def __setitem__(self,key,value):
        if not type(value)==dict:
            raise PyFoamException("Type of boundary element must be dict, is"+str(type(value)))
        for k in ["type","nFaces","startFace"]:
            if k not in value:
                raise PyFoamException("Required key "+str(k)+" is missing from"+str(value)+"not a valid patch")

        self.content[key]=value
示例#2
0
 def play(self,patternName):
     """Plays a defined pattern"""
     if patternName not in self.patterns:
         self.reloadPatterns()
         if patternName not in self.patterns:
             raise PyFoamException("blink(1) pattern",patternName,
                                   "unknown. Available:",
                                   ", ".join(self.patterns))
     response=self.__sendCommand("pattern/play",pname=patternName)
示例#3
0
 def __init__(self,
              ticColor=None):
     """Constructs the object. Tests for blink-device only in the beginning.
     If none is found an exception is thrown"""
     self.__baseURL=conf().get("Blink1","baseurl")
     self.__timeout=conf().getfloat("Blink1","allowedtimeout")
     try:
         response=self.__sendCommand("id")
     except requests.ConnectionError:
         e=sys.exc_info()[1]
         raise PyFoamException("No blink(1) at",self.__baseURL,":",e)
     if len(response["blink1_serialnums"])<1:
         raise PyFoamException("Seems that no blink(1) is plugged in")
     self.reloadPatterns()
     self.__threads=[]
     self.__tictocColor=ticColor if ticColor else conf().get("Blink1","tictoccolor")
     self.__lastTicTime=-1
     self.__ticToc=True
示例#4
0
    def nrOfCells(self):
        try:
            return self.cells
        except:
            try:
                try:
                    owner=ParsedFileHeader(path.join(self.sol.polyMeshDir(time=self.time,processor=self.processor),"owner"))
                except IOError:
                    owner=ParsedFileHeader(path.join(self.sol.polyMeshDir(processor=self.processor),"owner"))

                mat=re.compile('.+nCells: *([0-9]+) .+').match(owner["note"])
                self.cells=int(mat.group(1))
                return self.cells
            except:
                raise PyFoamException("Not Implemented")
示例#5
0
文件: Pandas.py 项目: blueCFD/PyFoam
 def __init__(self,*text):
      descr="Problem in wrapper to pandas-library"
      #          super(FatalErrorPyFoamException,self).__init__(descr,*text) # does not work with Python 2.4
      PyFoamException.__init__(self,descr,*text)
示例#6
0
#  ICE Revision: $Id$
"""Base class for all parser classes based on PLY

Most of this class was shamelessly stolen from the examples"""

import sys
from PyFoam.Error import PyFoamException

if sys.version_info < (2, 3):
    raise PyFoamException("Version " + str(sys.version_info) +
                          " is not sufficient for ply (2.3 needed)")

import PyFoam.ThirdParty.ply.lex as lex
import PyFoam.ThirdParty.ply.yacc as yacc

import os

from PyFoam.FoamInformation import getUserTempDir


class PlyParser(object):
    """
    Base class for a lexer/parser that has the rules defined as methods
    """
    tokens = ()
    precedence = ()

    def __init__(self, **kw):
        """Constructs the parser and the lexer"""
        self.debug = kw.get('debug', 2)
        self.names = {}
示例#7
0
 def __init__(self,descr):
     PyFoamException.__init__(self,descr)
示例#8
0
 def __init__(self, *text):
     descr = "Problem in wrapper to pandas-library"
     #          super(FatalErrorPyFoamException,self).__init__(descr,*text) # does not work with Python 2.4
     PyFoamException.__init__(self, descr, *text)
示例#9
0
 def __init__(self, descr):
     PyFoamException.__init__(self, descr)