forked from ToninoTarsi/swpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversion.py
55 lines (47 loc) · 1.53 KB
/
version.py
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
###########################################################################
# Sint Wind PI
# Copyright 2012 by Tonino Tarsi <[email protected]>
#
# Please refer to the LICENSE file for conditions
# Visit http://www.vololiberomontecucco.it
#
##########################################################################
import sys
import struct
import ConfigParser
import os
import ftplib
import Image
import ImageFont, ImageDraw, ImageOps
import urllib2
import time
class Version(object):
"""Class defining software configuration."""
def __init__(self,versionfile):
self.versionfile = versionfile
if ( not os.path.isfile(versionfile)):
self.ver = "00.00.00"
self.magior = 0
self.minor = 0
self.build = 0
else:
f = open(versionfile, "r")
self.ver = f.read()
self.magior = int(self.ver.split('.')[0])
self.minor = int(self.ver.split('.')[1])
self.build = int(self.ver.split('.')[2])
def getVersion(self):
return self.ver
def incBuild(self):
self.build = self.build+1
if ( self.build > 99 ) :
self.minor = self.minor + 1
self.build = 0
self.ver = "%2.2d.%2.2d.%2.2d" % (self.magior ,self.minor ,self.build)
f = open(self.versionfile, "w")
f.write(self.ver)
if __name__ == '__main__':
v = Version("VERSION")
print v.getVersion()
v.incBuild()
print v.getVersion()