Completed
Push — master ( fe66bc...2a24eb )
by Manas
18:11
created

testpacks.checks.actions.checks.ExamplesTest   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 105
Duplicated Lines 0 %
Metric Value
wmc 19
dl 0
loc 105
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A test_repeat_with_items() 0 7 1
A test_environment() 0 7 2
A test_join() 0 7 3
A test_handle_retry() 0 4 1
A test_handle_error_task_default() 0 9 2
B test_branching() 0 27 4
A test_handle_error() 0 9 2
A test_with_items_batch_processing() 0 13 2
A test_repeat() 0 7 1
A test_workbook_multiple_subflows() 0 4 1
1
#!/usr/bin/python
2
3
import sys
4
5
6
def print_load_avg(args):
7
    period = args[1]
8
9
    loadavg_file = '/proc/loadavg'
10
    cpuinfo_file = '/proc/cpuinfo'
11
    cpus = 0
12
13
    try:
14
        fh = open(loadavg_file, 'r')
15
        load = fh.readline().split()[0:3]
16
        fh.close()
17
    except:
18
        sys.stderr.write('Error opening %s\n' % loadavg_file)
19
        sys.exit(2)
20
21
    try:
22
        fh = open(cpuinfo_file, 'r')
23
        for line in fh:
24
            if 'processor' in line:
25
                cpus += 1
26
        fh.close()
27
    except:
28
        sys.stderr.write('Error opeing %s\n' % cpuinfo_file)
29
30
    one_min = '1 min load/core: %s' % str(float(load[0]) / cpus)
31
    five_min = '5 min load/core: %s' % str(float(load[1]) / cpus)
32
    fifteen_min = '15 min load/core: %s' % str(float(load[2]) / cpus)
33
34
    if period == '1' or period == 'one':
35
        print(one_min)
36
    elif period == '5' or period == 'five':
37
        print(five_min)
38
    elif period == '15' or period == 'fifteen':
39
        print(fifteen_min)
40
    else:
41
        print(one_min + " " + five_min + " " + fifteen_min)
42
43
44
if __name__ == '__main__':
45
    print_load_avg(sys.argv)
46