Sync with 5.4.0
[deliverable/titan.core.git] / common / version.py
CommitLineData
970ed795 1###############################################################################
3abe9331 2# Copyright (c) 2000-2015 Ericsson Telecom AB
970ed795
EL
3# All rights reserved. This program and the accompanying materials
4# are made available under the terms of the Eclipse Public License v1.0
5# which accompanies this distribution, and is available at
6# http://www.eclipse.org/legal/epl-v10.html
7###############################################################################
8import datetime
9
10from tempfile import mkstemp
11from shutil import move
12from os import remove, close
13
14from subprocess import call
15from sys import exit
16
17def getnumberfromfileline(line):
18 lineasstring = str(line);
19 numberfromfile = lineasstring[-3:];
20 number = int(numberfromfile) + 1;
21 print number;
22 if number >= 99:
23 print 'Number is over the limit: >=99. File is not modified!'
24 exit();
25 return number
26
27
28def replace(file_path):
29 #Create temp file
30 fh, abs_path = mkstemp()
31 new_file = open(abs_path,'w')
32 old_file = open(file_path)
33 for line in old_file:
34 if '#define TTCN3_PATCHLEVEL' in line:
35 newline = str('#define TTCN3_PATCHLEVEL ') + str(getnumberfromfileline(line)) + str('\n');
36 new_file.write(newline);
37 elif '#define TTCN3_VERSION 30' in line:
38 number = getnumberfromfileline(line);
39 if number <= 9:
40 newline = str('#define TTCN3_VERSION 302') +'0' + str(number) + str('\n');
41 else:
42 newline = str('#define TTCN3_VERSION 302') + str(number) + str('\n');
43 new_file.write(newline);
44 else:
45 new_file.write(line)
46 #close temp file
47 new_file.close()
48 close(fh)
49 old_file.close()
50 #Remove original file
51 remove(file_path)
52 #Move new file
53 move(abs_path, file_path)
54
55#( d.isoweekday() in range(1, 6)
56#d = datetime.datetime.now();
57#if d.isoweekday() == 2 or d.isoweekday() == 4 :
58replace ("version.h");
59#call(["git", "commit", "-m 'TTCN3_PATCHLEVEL update'" ,"version.h"]);
60# call(["git", "push"]);
61
This page took 0.025537 seconds and 5 git commands to generate.