예제 #1
0
 def ParLot(self):
     """Execute the JDC calling Build and Exec methods."""
     # not used for Code_Aster
     j = self.jdc
     try:
         ier = j.Build()
         if ier or not j.cr.estvide():
             self.MESSAGE(
                 _(u"ERREUR A LA CONSTRUCTION DES MACROS - INTERRUPTION"))
             print convert(self.format_CR(j.cr))
             return 1
     except:
         self.MESSAGE(_(u"ERREUR INOPINEE - INTERRUPTION"))
         traceback.print_exc()
         return 1
     cr = j.report()
     if not cr.estvide():
         self.MESSAGE(
             _(u"ERREUR A LA VERIFICATION DES MACROS - INTERRUPTION"))
         print convert(self.format_CR(cr))
         return 1
     try:
         ier = j.Exec()
         if ier:
             self.MESSAGE(_(u"ERREUR A L'EXECUTION - INTERRUPTION"))
             return 1
     except EOFError:
         return 0
     except:
         self.MESSAGE(_(u"ERREUR INOPINEE - INTERRUPTION"))
         traceback.print_exc()
         return 1
예제 #2
0
 def main(self, params={}, coreopts=None):
     """Programme principal. Appelle les methodes internes qui realisent les
     divers traitements
     """
     if not coreopts:
         coreopts = aster_settings.getargs()
     self.coreopts = coreopts
     try:
         self.InitEnv()
         self.InitJDC(params)
         self._mem_stat_init()
         self.CompileJDC()
         self.ExecCompileJDC()
         self._mem_stat_jdc()
         if self.jdc.par_lot == 'NON':
             print convert(_(u"""--- Fin de l'exécution"""))
             self.SyntaxCheck()
             self.Finish()
             self.interrupt(0)
         self.CheckCata()
         self.ChangeJDC()
         self.Execute(params)
         self.Finish()
     except Interrupt, exc:
         return exc.returncode
예제 #3
0
 def __getitem__(self, key):
     from strfunc import convert
     text_error = convert(_(u"ASSD.__getitem__ est déprécié car la référence à "
                            u"l'objet ETAPE parent sera supprimée."))
     # raise NotImplementedError(text_error)
     from warnings import warn
     warn(text_error, DeprecationWarning, stacklevel=2)
     return self.etape[key]
예제 #4
0
 def MESSAGE(self, chaine):
     """La fonction MESSAGE n'est utilisee que dans le script courant pour afficher
     des messages sur la sortie des erreurs.
     """
     sys.stdout.flush()
     sortie = sys.stdout
     sortie.write("JDC.py : ")
     sortie.write(convert(chaine))
     sortie.write('\n')
     sortie.flush()
예제 #5
0
 def ParLotMixte(self):
     """Execute the JDC using BuildExec"""
     from Noyau.N_JDC import MemoryErrorMsg
     j = self.jdc
     j.set_par_lot("NON")
     try:
         j.BuildExec()
         ier = 0
         if not j.cr.estvide():
             self.MESSAGE(_(u"ERREUR A L'EXECUTION - INTERRUPTION"))
             ier = 1
             print convert(self.format_CR(j.cr))
         return ier
     except MemoryError:
         self.MESSAGE("ERREUR INOPINEE - INTERRUPTION")
         self.MESSAGE(MemoryErrorMsg)
         traceback.print_exc()
         return 1
     except:
         self.MESSAGE("ERREUR INOPINEE - INTERRUPTION")
         traceback.print_exc()
         return 1
예제 #6
0
 def format(self, code):
     """Return the related message of the exception with formatting
     as `code` says."""
     try:
         from Utilitai.Utmess import message_exception
         txt = []
         for err in self.related:
             txt.append(message_exception(code, err))
         txt.append(message_exception(code, self))
         txt = os.linesep.join(txt)
     except:
         txt = self.basic_format()
     return convert(txt)
예제 #7
0
    def AfficheTexteCommande(self, sortie=sys.stdout):
        """
        Methode : ETAPE.AfficheTexteCommande
        Intention : afficher sur la sortie standard (par defaut) le cartouche de
                        la commande avant son execution.
        """
        from Utilitai.Utmess import UTMESS
        voir = not isinstance(self.parent, MACRO_ETAPE) or \
            self.jdc.impr_macro == 1 or self.parent.show_children
        # top départ du chrono de la commande
        etiq = self.nom
        # id unique pour l'étape. L'attribut n'est pas déclaré dans
        # l'__init__...
        count = (self.icmd or 0)
        self.id_timer = str(time.time() + count)
        if isinstance(self.parent, MACRO_ETAPE):
            etiq = ' . ' + etiq
        if voir:
            self.jdc.timer.Start(self.id_timer, name=etiq)

        # impression du fichier .code : compte rendu des commandes et
        # mots clés activés par l'ETAPE
        if self.jdc.fico != None:
            fcode = CodeVisitor(self.jdc.fico)
            self.accept(fcode)
            aster.affiche('CODE', fcode.get_text())

        if voir:
            # Affichage numero de la commande (4 digits)
            if self.sd != None:
                type_concept = self.sd.__class__.__name__
            else:
                type_concept = '-'

            UTMESS('I', 'VIDE_1')
            UTMESS('I', 'SUPERVIS2_70')
            if self.icmd != None:
                UTMESS('I', 'SUPERVIS2_71', vali=self.icmd, valk=type_concept)
                UTMESS('I', 'SUPERVIS2_70')
            else:
                # commande non comptabilisée (INCLUDE)
                UTMESS('I', 'SUPERVIS2_72', valk=type_concept)

            # recuperation du texte de la commande courante
            if self.jdc.ctree:
                self.accept(self.jdc.ctree)
            cmdtext = CommandTextVisitor()
            self.accept(cmdtext)
            aster.affiche('MESSAGE', convert(cmdtext.get_text()))

        return
예제 #8
0
 def InitJDC(self, params):
     """Construit et execute le jeu de commandes
     """
     fort1 = self.coreopts.get_option('fort1')
     f = open(fort1, 'r')
     text = f.read()
     dash = "# " + "-" * 90
     print dash
     print convert(
         _(u"""# Impression du contenu du fichier de commandes à exécuter :"""
           ))
     print dash
     print convert(text)
     print dash
     f.close()
     args = {}
     self.jdc = self.JdC(procedure=text,
                         cata=self.cata,
                         nom=fort1,
                         context_ini=params,
                         **args)
     # on enregistre les objets dans aster_core dès que le jdc est créé
     aster_core.register(self.jdc, self.coreopts)
     self.jdc.set_syntax_check(self.coreopts.get_option('syntax'))
예제 #9
0
파일: N_CR.py 프로젝트: jacojvr/Code_Aster
 def __str__(self):
     """Return the report representation"""
     # convert into the output encoding
     txt = convert(self.__unicode__())
     return txt
예제 #10
0
def default_print(text):
    """Basic print function."""
    print convert(text)