コード例 #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
ファイル: Blink1.py プロジェクト: hamdanih/OpenFOAM_test
 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
ファイル: Blink1.py プロジェクト: hamdanih/OpenFOAM_test
 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
ファイル: MeshInformation.py プロジェクト: WarnerChang/PyFoam
    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
ファイル: FoamFileGenerator.py プロジェクト: floli/tools
 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)