-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNormalUtil.py
50 lines (35 loc) · 950 Bytes
/
NormalUtil.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
#!/usr/bin/env python
# encoding: utf-8
import re
periodRecoderFile = '/home/sk/image/cloudExData/periodRecoder.db'
periodRecoder = 'PERIODRECODER'
provisionInfoFile = '/home/sk/image/cloudExData/provisionInfo.db'
predictProvisionVMNumbers = 'PPVMN'
reactiveProvisionVMNumbers = 'RPVMN'
def isNumber(strToTest):
pattern = r'^\d+$'
m = re.match(pattern, strToTest)
if m:
return True
else:
return False
def isDecimal(strToTest):
if not strToTest:
return False
pattern = r'^\d+\.\d+$'
m = re.match(pattern, strToTest)
if m:
return True
else:
return False
def errorResultJson(msg):
return {'error': msg}
def successResultJson(msg):
return {'success': msg}
def avgNumberList(nl):
avg = float(sum(nl)) / len(nl)
return round(avg, 2)
def popNoneInList(targetList):
for item in targetList:
if not item:
targetList.remove(item)