Esempio n. 1
0
        def fcn():
            start = time.perf_counter()

            caller = os.path.realpath(inspect.stack()[1][1])
            os.chdir(os.path.dirname(caller))

            # Remove old log file
            log_file = caller[:-3] + '.log'
            if os.path.isfile(log_file):
                os.remove(log_file)

            # First time logging configure for tests
            logging.basicConfig(level=logging.NOTSET)

            clean.screen()
            method()
            clean.cache()

            log_time_delta(start, log_file)
Esempio n. 2
0
                        text = '\'' + self.p.abspath(
                            text) + '\''  # covert path to absolute
                        if '\\' in text:  # reconstruct path for Windows
                            text = '\\\\'.join(text.split('\\'))
                        value = self.__dict__['label_' + attr]
                    elif class_name == 'QComboBox':
                        text = '\'' + value.currentText() + '\''
                        value = self.__dict__['label_' + attr]

                    line = 'self.{} = {}'.format(attr, text)
                    comment = value.text()
                    f.write('# ' + comment + '\n')
                    f.write(line + '\n\n')


# Run test
if __name__ == '__main__':
    clean.screen()
    logging.basicConfig(level=0, format='%(message)s')

    # Create application
    app = QtWidgets.QApplication(sys.argv)

    # Create and open settings window
    p = path.Path()
    s = Settings(p)
    s.open()

    # Clean cached files
    clean.cache(p.src)
Esempio n. 3
0
# Test mesh parser on all CalculiX examples
if __name__ == '__main__':
    clean.screen()
    os.chdir(os.path.dirname(__file__))
    start_time = time.perf_counter()
    print = tests.print

    # Prepare logging
    log_file = __file__[:-3] + '.log'
    h = tests.myHandler(log_file)
    logging.getLogger().addHandler(h)
    logging.getLogger().setLevel(logging.INFO)

    limit = 3000  # how many files to process
    examples_dir = '../../../../examples/ccx_2.16.test'
    counter = 0

    print(log_file, 'MESH PARSER TEST\n\n')
    examples = tests.scan_all_files_in(examples_dir, '.inp', limit)
    for file_name in examples:
        counter += 1
        relpath = os.path.relpath(file_name, start=os.getcwd())
        print(log_file, '\n{}\n{}: {}'.format('=' * 50, counter, relpath))

        # Parse mesh
        m = Mesh(INP_file=file_name)

    print(log_file,
          '\nTotal {:.1f} seconds.'.format(time.perf_counter() - start_time))
    clean.cache()
Esempio n. 4
0
File: cae.py Progetto: calculix/cae
# Main block
m = model.Model()  # generate FEM model
t = tree.Tree(f, m)  # create treeView items based on KOM
j = model.job.Job(f, m)  # create job object with file logging handler
i = importer.Importer(f, m, t, j)  # prepare to import model
actions.actions(f, m, t, j, i)  # window actions

# Import default model
if len(args.inp):
    start_model = os.path.join(path.p.app_home_dir, args.inp)
    i.import_file(start_model)

# Or start empty
else:
    logging.warning('No default start model specified.')
    m.KOM = model.kom.KOM()
    t.generateTreeView(m)

logging.info('Started in {:.1f} seconds.\n'.format(time.perf_counter() -
                                                   start_time))

# Execute application
app.exec()

# Kill CGX after CAE exit
f.kill_slave()

# Recursively clean cached files in all subfolders
clean.cache(path.p.src)