1 # -*- coding: utf-8 -*-
3 # Copyright (C) 2016-2024 EDF R&D
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 ###############################################################################
21 ###############################################################################
22 from time import localtime
24 from subprocess import Popen
26 ###############################################################################
28 ###############################################################################
32 Return a string in the format : year/month/day hour:min:sec
34 real_time = localtime()
36 '{0:04d}'.format(real_time.tm_year) + '/' + \
37 '{0:02d}'.format(real_time.tm_mon) + '/' + \
38 '{0:02d}'.format(real_time.tm_mday) + ' ' + \
39 '{0:02d}'.format(real_time.tm_hour) + ':' + \
40 '{0:02d}'.format(real_time.tm_min) + ':' + \
41 '{0:02d}'.format(real_time.tm_sec)
46 def tol_equality(vars, tol=1.e-4):
48 Check whether two numbers (vars[0] and vars[1]) are approximately equal (with 'tol' tollerance)
51 return abs(float(vars[1]) / float(vars[0]) - 1.) < tol
52 except ZeroDivisionError:
53 return abs(vars[1] - vars[0]) < tol
56 def Edit_File(filename):
57 if os.name == 'nt': # Windows
60 editor = ['gedit', '-s']
61 file_display = Popen(editor + [f'{filename}'])
65 if __name__ == '__main__':
66 print('\n AUTODIAGNOSTIC\n ==============\n')