File: version.py

package info (click to toggle)
eclipse-titan 6.1.0-1
  • links: PTS
  • area: main
  • in suites: stretch
  • size: 79,084 kB
  • ctags: 29,092
  • sloc: cpp: 210,764; ansic: 44,862; yacc: 21,034; sh: 12,594; makefile: 12,225; lex: 8,972; xml: 5,348; java: 4,849; perl: 3,780; python: 2,834; php: 175
file content (66 lines) | stat: -rwxr-xr-x 2,025 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
##############################################################################
# Copyright (c) 2000-2016 Ericsson Telecom AB
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at
# http://www.eclipse.org/legal/epl-v10.html
#
# Contributors:
#   Balasko, Jeno
#   Pandi, Krisztian
#
##############################################################################
import datetime
 
from tempfile import mkstemp
from shutil import move
from os import remove, close

from subprocess import call
from sys import exit

def getnumberfromfileline(line):
    lineasstring = str(line);
    numberfromfile = lineasstring[-3:];
    number = int(numberfromfile) + 1;
    print number;
    if number >= 99:
	print 'Number is over the limit: >=99. File is not modified!'
        exit();
    return number
    

def replace(file_path):
    #Create temp file
    fh, abs_path = mkstemp()
    new_file = open(abs_path,'w')
    old_file = open(file_path)
    for line in old_file:
		if '#define TTCN3_PATCHLEVEL' in line:
				newline = str('#define TTCN3_PATCHLEVEL ') + str(getnumberfromfileline(line)) + str('\n');
				new_file.write(newline);
		elif '#define TTCN3_VERSION 30' in line:
		                number = getnumberfromfileline(line);
				if number <= 9:
					newline = str('#define TTCN3_VERSION 302') +'0' + str(number) + str('\n');
				else:
					newline = str('#define TTCN3_VERSION 302') + str(number) + str('\n');
				new_file.write(newline);
		else:
			new_file.write(line)
    #close temp file
    new_file.close()
    close(fh)
    old_file.close()
    #Remove original file
    remove(file_path)
    #Move new file
    move(abs_path, file_path)
 
#( d.isoweekday() in range(1, 6)
#d = datetime.datetime.now();
#if d.isoweekday() == 2 or d.isoweekday() == 4 :
replace ("version.h");  
#call(["git", "commit", "-m 'TTCN3_PATCHLEVEL update'" ,"version.h"]);
#	call(["git", "push"]);