Code Duplication    Length = 36-46 lines in 61 locations

myems-api/excelexporters/spacecarbon.py 1 location

@@ 24-69 (lines=46) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           base_period_start_datetime_local,
27
           base_period_end_datetime_local,
28
           reporting_start_datetime_local,
29
           reporting_end_datetime_local,
30
           period_type,
31
           language):
32
    ####################################################################################################################
33
    # Step 1: Validate the report data
34
    ####################################################################################################################
35
    if report is None:
36
        return None
37
    print(report)
38
39
    ####################################################################################################################
40
    # Step 2: Generate excel file from the report data
41
    ####################################################################################################################
42
    filename = generate_excel(report,
43
                              name,
44
                              base_period_start_datetime_local,
45
                              base_period_end_datetime_local,
46
                              reporting_start_datetime_local,
47
                              reporting_end_datetime_local,
48
                              period_type,
49
                              language)
50
    ####################################################################################################################
51
    # Step 3: Encode the excel file to Base64
52
    ####################################################################################################################
53
    binary_file_data = b''
54
    try:
55
        with open(filename, 'rb') as binary_file:
56
            binary_file_data = binary_file.read()
57
    except IOError as ex:
58
        print(str(ex))
59
60
    # Base64 encode the bytes
61
    base64_encoded_data = base64.b64encode(binary_file_data)
62
    # get the Base64 encoded data using human-readable characters.
63
    base64_message = base64_encoded_data.decode('utf-8')
64
    # delete the file from server
65
    try:
66
        os.remove(filename)
67
    except NotImplementedError as ex:
68
        print(str(ex))
69
    return base64_message
70
71
72
def generate_excel(report,

myems-api/excelexporters/spaceincome.py 1 location

@@ 24-69 (lines=46) @@
21
####################################################################################################################
22
23
24
def export(report,
25
           name,
26
           base_period_start_datetime_local,
27
           base_period_end_datetime_local,
28
           reporting_start_datetime_local,
29
           reporting_end_datetime_local,
30
           period_type,
31
           language):
32
    ####################################################################################################################
33
    # Step 1: Validate the report data
34
    ####################################################################################################################
35
    if report is None:
36
        return None
37
    print(report)
38
39
    ####################################################################################################################
40
    # Step 2: Generate excel file from the report data
41
    ####################################################################################################################
42
    filename = generate_excel(report,
43
                              name,
44
                              base_period_start_datetime_local,
45
                              base_period_end_datetime_local,
46
                              reporting_start_datetime_local,
47
                              reporting_end_datetime_local,
48
                              period_type,
49
                              language)
50
    ####################################################################################################################
51
    # Step 3: Encode the excel file to Base64
52
    ####################################################################################################################
53
    binary_file_data = b''
54
    try:
55
        with open(filename, 'rb') as binary_file:
56
            binary_file_data = binary_file.read()
57
    except IOError as ex:
58
        print(str(ex))
59
60
    # Base64 encode the bytes
61
    base64_encoded_data = base64.b64encode(binary_file_data)
62
    # get the Base64 encoded data using human-readable characters.
63
    base64_message = base64_encoded_data.decode('utf-8')
64
    # delete the file from server
65
    try:
66
        os.remove(filename)
67
    except NotImplementedError as ex:
68
        print(str(ex))
69
    return base64_message
70
71
72
def generate_excel(report,

myems-api/excelexporters/spacecost.py 1 location

@@ 24-69 (lines=46) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           base_period_start_datetime_local,
27
           base_period_end_datetime_local,
28
           reporting_start_datetime_local,
29
           reporting_end_datetime_local,
30
           period_type,
31
           language):
32
    ####################################################################################################################
33
    # Step 1: Validate the report data
34
    ####################################################################################################################
35
    if report is None:
36
        return None
37
    print(report)
38
39
    ####################################################################################################################
40
    # Step 2: Generate excel file from the report data
41
    ####################################################################################################################
42
    filename = generate_excel(report,
43
                              name,
44
                              base_period_start_datetime_local,
45
                              base_period_end_datetime_local,
46
                              reporting_start_datetime_local,
47
                              reporting_end_datetime_local,
48
                              period_type,
49
                              language)
50
    ####################################################################################################################
51
    # Step 3: Encode the excel file to Base64
52
    ####################################################################################################################
53
    binary_file_data = b''
54
    try:
55
        with open(filename, 'rb') as binary_file:
56
            binary_file_data = binary_file.read()
57
    except IOError as ex:
58
        print(str(ex))
59
60
    # Base64 encode the bytes
61
    base64_encoded_data = base64.b64encode(binary_file_data)
62
    # get the Base64 encoded data using human-readable characters.
63
    base64_message = base64_encoded_data.decode('utf-8')
64
    # delete the file from server
65
    try:
66
        os.remove(filename)
67
    except NotImplementedError as ex:
68
        print(str(ex))
69
    return base64_message
70
71
72
def generate_excel(report,

myems-api/excelexporters/spaceenergyitem.py 1 location

@@ 23-68 (lines=46) @@
20
####################################################################################################################
21
22
23
def export(report,
24
           name,
25
           base_period_start_datetime_local,
26
           base_period_end_datetime_local,
27
           reporting_start_datetime_local,
28
           reporting_end_datetime_local,
29
           period_type,
30
           language):
31
    ####################################################################################################################
32
    # Step 1: Validate the report data
33
    ####################################################################################################################
34
    if report is None:
35
        return None
36
    print(report)
37
38
    ####################################################################################################################
39
    # Step 2: Generate excel file from the report data
40
    ####################################################################################################################
41
    filename = generate_excel(report,
42
                              name,
43
                              base_period_start_datetime_local,
44
                              base_period_end_datetime_local,
45
                              reporting_start_datetime_local,
46
                              reporting_end_datetime_local,
47
                              period_type,
48
                              language)
49
    ####################################################################################################################
50
    # Step 3: Encode the excel file to Base64
51
    ####################################################################################################################
52
    binary_file_data = b''
53
    try:
54
        with open(filename, 'rb') as binary_file:
55
            binary_file_data = binary_file.read()
56
    except IOError as ex:
57
        print(str(ex))
58
59
    # Base64 encode the bytes
60
    base64_encoded_data = base64.b64encode(binary_file_data)
61
    # get the Base64 encoded data using human-readable characters.
62
    base64_message = base64_encoded_data.decode('utf-8')
63
    # delete the file from server
64
    try:
65
        os.remove(filename)
66
    except NotImplementedError as ex:
67
        print(str(ex))
68
    return base64_message
69
70
71
def generate_excel(report,

myems-api/excelexporters/spaceoutput.py 1 location

@@ 23-68 (lines=46) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           base_period_start_datetime_local,
26
           base_period_end_datetime_local,
27
           reporting_start_datetime_local,
28
           reporting_end_datetime_local,
29
           period_type,
30
           language):
31
    ####################################################################################################################
32
    # Step 1: Validate the report data
33
    ####################################################################################################################
34
    if report is None:
35
        return None
36
    print(report)
37
38
    ####################################################################################################################
39
    # Step 2: Generate excel file from the report data
40
    ####################################################################################################################
41
    filename = generate_excel(report,
42
                              name,
43
                              base_period_start_datetime_local,
44
                              base_period_end_datetime_local,
45
                              reporting_start_datetime_local,
46
                              reporting_end_datetime_local,
47
                              period_type,
48
                              language)
49
    ####################################################################################################################
50
    # Step 3: Encode the excel file to Base64
51
    ####################################################################################################################
52
    binary_file_data = b''
53
    try:
54
        with open(filename, 'rb') as binary_file:
55
            binary_file_data = binary_file.read()
56
    except IOError as ex:
57
        print(str(ex))
58
59
    # Base64 encode the bytes
60
    base64_encoded_data = base64.b64encode(binary_file_data)
61
    # get the Base64 encoded data using human-readable characters.
62
    base64_message = base64_encoded_data.decode('utf-8')
63
    # delete the file from server
64
    try:
65
        os.remove(filename)
66
    except NotImplementedError as ex:
67
        print(str(ex))
68
    return base64_message
69
70
71
def generate_excel(report,

myems-api/excelexporters/spaceenergycategory.py 1 location

@@ 23-68 (lines=46) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           base_period_start_datetime_local,
26
           base_period_end_datetime_local,
27
           reporting_start_datetime_local,
28
           reporting_end_datetime_local,
29
           period_type,
30
           language):
31
    ####################################################################################################################
32
    # Step 1: Validate the report data
33
    ####################################################################################################################
34
    if report is None:
35
        return None
36
    print(report)
37
38
    ####################################################################################################################
39
    # Step 2: Generate excel file from the report data
40
    ####################################################################################################################
41
    filename = generate_excel(report,
42
                              name,
43
                              base_period_start_datetime_local,
44
                              base_period_end_datetime_local,
45
                              reporting_start_datetime_local,
46
                              reporting_end_datetime_local,
47
                              period_type,
48
                              language)
49
    ####################################################################################################################
50
    # Step 3: Encode the excel file to Base64
51
    ####################################################################################################################
52
    binary_file_data = b''
53
    try:
54
        with open(filename, 'rb') as binary_file:
55
            binary_file_data = binary_file.read()
56
    except IOError as ex:
57
        print(str(ex))
58
59
    # Base64 encode the bytes
60
    base64_encoded_data = base64.b64encode(binary_file_data)
61
    # get the Base64 encoded data using human-readable characters.
62
    base64_message = base64_encoded_data.decode('utf-8')
63
    # delete the file from server
64
    try:
65
        os.remove(filename)
66
    except NotImplementedError as ex:
67
        print(str(ex))
68
    return base64_message
69
70
71
def generate_excel(report,

myems-api/excelexporters/spaceload.py 1 location

@@ 23-68 (lines=46) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           base_period_start_datetime_local,
26
           base_period_end_datetime_local,
27
           reporting_start_datetime_local,
28
           reporting_end_datetime_local,
29
           period_type,
30
           language):
31
    ####################################################################################################################
32
    # Step 1: Validate the report data
33
    ####################################################################################################################
34
    if report is None:
35
        return None
36
    print(report)
37
38
    ####################################################################################################################
39
    # Step 2: Generate excel file from the report data
40
    ####################################################################################################################
41
    filename = generate_excel(report,
42
                              name,
43
                              base_period_start_datetime_local,
44
                              base_period_end_datetime_local,
45
                              reporting_start_datetime_local,
46
                              reporting_end_datetime_local,
47
                              period_type,
48
                              language)
49
    ####################################################################################################################
50
    # Step 3: Encode the excel file to Base64
51
    ####################################################################################################################
52
    binary_file_data = b''
53
    try:
54
        with open(filename, 'rb') as binary_file:
55
            binary_file_data = binary_file.read()
56
    except IOError as ex:
57
        print(str(ex))
58
59
    # Base64 encode the bytes
60
    base64_encoded_data = base64.b64encode(binary_file_data)
61
    # get the Base64 encoded data using human-readable characters.
62
    base64_message = base64_encoded_data.decode('utf-8')
63
    # delete the file from server
64
    try:
65
        os.remove(filename)
66
    except NotImplementedError as ex:
67
        print(str(ex))
68
    return base64_message
69
70
71
def generate_excel(report,

myems-api/excelexporters/spacesaving.py 1 location

@@ 23-68 (lines=46) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           base_period_start_datetime_local,
26
           base_period_end_datetime_local,
27
           reporting_start_datetime_local,
28
           reporting_end_datetime_local,
29
           period_type,
30
           language):
31
    ####################################################################################################################
32
    # Step 1: Validate the report data
33
    ####################################################################################################################
34
    if report is None:
35
        return None
36
    print(report)
37
38
    ####################################################################################################################
39
    # Step 2: Generate excel file from the report data
40
    ####################################################################################################################
41
    filename = generate_excel(report,
42
                              name,
43
                              base_period_start_datetime_local,
44
                              base_period_end_datetime_local,
45
                              reporting_start_datetime_local,
46
                              reporting_end_datetime_local,
47
                              period_type,
48
                              language)
49
    ####################################################################################################################
50
    # Step 3: Encode the excel file to Base64
51
    ####################################################################################################################
52
    binary_file_data = b''
53
    try:
54
        with open(filename, 'rb') as binary_file:
55
            binary_file_data = binary_file.read()
56
    except IOError as ex:
57
        print(str(ex))
58
59
    # Base64 encode the bytes
60
    base64_encoded_data = base64.b64encode(binary_file_data)
61
    # get the Base64 encoded data using human-readable characters.
62
    base64_message = base64_encoded_data.decode('utf-8')
63
    # delete the file from server
64
    try:
65
        os.remove(filename)
66
    except NotImplementedError as ex:
67
        print(str(ex))
68
    return base64_message
69
70
71
def generate_excel(report,

myems-api/excelexporters/spaceefficiency.py 1 location

@@ 23-68 (lines=46) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           base_period_start_datetime_local,
26
           base_period_end_datetime_local,
27
           reporting_start_datetime_local,
28
           reporting_end_datetime_local,
29
           period_type,
30
           language):
31
    ####################################################################################################################
32
    # Step 1: Validate the report data
33
    ####################################################################################################################
34
    if report is None:
35
        return None
36
    print(report)
37
38
    ####################################################################################################################
39
    # Step 2: Generate excel file from the report data
40
    ####################################################################################################################
41
    filename = generate_excel(report,
42
                              name,
43
                              base_period_start_datetime_local,
44
                              base_period_end_datetime_local,
45
                              reporting_start_datetime_local,
46
                              reporting_end_datetime_local,
47
                              period_type,
48
                              language)
49
    ####################################################################################################################
50
    # Step 3: Encode the excel file to Base64
51
    ####################################################################################################################
52
    binary_file_data = b''
53
    try:
54
        with open(filename, 'rb') as binary_file:
55
            binary_file_data = binary_file.read()
56
    except IOError as ex:
57
        print(str(ex))
58
59
    # Base64 encode the bytes
60
    base64_encoded_data = base64.b64encode(binary_file_data)
61
    # get the Base64 encoded data using human-readable characters.
62
    base64_message = base64_encoded_data.decode('utf-8')
63
    # delete the file from server
64
    try:
65
        os.remove(filename)
66
    except NotImplementedError as ex:
67
        print(str(ex))
68
    return base64_message
69
70
71
def generate_excel(report,

myems-api/excelexporters/spacestatistics.py 1 location

@@ 22-67 (lines=46) @@
19
########################################################################################################################
20
21
22
def export(report,
23
           name,
24
           base_period_start_datetime_local,
25
           base_period_end_datetime_local,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
    print(report)
36
37
    ####################################################################################################################
38
    # Step 2: Generate excel file from the report data
39
    ####################################################################################################################
40
    filename = generate_excel(report,
41
                              name,
42
                              base_period_start_datetime_local,
43
                              base_period_end_datetime_local,
44
                              reporting_start_datetime_local,
45
                              reporting_end_datetime_local,
46
                              period_type,
47
                              language)
48
    ####################################################################################################################
49
    # Step 3: Encode the excel file to Base64
50
    ####################################################################################################################
51
    binary_file_data = b''
52
    try:
53
        with open(filename, 'rb') as binary_file:
54
            binary_file_data = binary_file.read()
55
    except IOError as ex:
56
        print(str(ex))
57
58
    # Base64 encode the bytes
59
    base64_encoded_data = base64.b64encode(binary_file_data)
60
    # get the Base64 encoded data using human-readable characters.
61
    base64_message = base64_encoded_data.decode('utf-8')
62
    # delete the file from server
63
    try:
64
        os.remove(filename)
65
    except NotImplementedError as ex:
66
        print(str(ex))
67
    return base64_message
68
69
70
def generate_excel(report,

myems-api/excelexporters/equipmentsaving.py 1 location

@@ 24-68 (lines=45) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           base_period_start_datetime_local,
27
           base_period_end_datetime_local,
28
           reporting_start_datetime_local,
29
           reporting_end_datetime_local,
30
           period_type,
31
           language):
32
    ####################################################################################################################
33
    # Step 1: Validate the report data
34
    ####################################################################################################################
35
    if report is None:
36
        return None
37
38
    ####################################################################################################################
39
    # Step 2: Generate excel file from the report data
40
    ####################################################################################################################
41
    filename = generate_excel(report,
42
                              name,
43
                              base_period_start_datetime_local,
44
                              base_period_end_datetime_local,
45
                              reporting_start_datetime_local,
46
                              reporting_end_datetime_local,
47
                              period_type,
48
                              language)
49
    ####################################################################################################################
50
    # Step 3: Encode the excel file to Base64
51
    ####################################################################################################################
52
    binary_file_data = b''
53
    try:
54
        with open(filename, 'rb') as binary_file:
55
            binary_file_data = binary_file.read()
56
    except IOError as ex:
57
        print(str(ex))
58
59
    # Base64 encode the bytes
60
    base64_encoded_data = base64.b64encode(binary_file_data)
61
    # get the Base64 encoded data using human-readable characters.
62
    base64_message = base64_encoded_data.decode('utf-8')
63
    # delete the file from server
64
    try:
65
        os.remove(filename)
66
    except NotImplementedError as ex:
67
        print(str(ex))
68
    return base64_message
69
70
71
def generate_excel(report,

myems-api/excelexporters/equipmentcarbon.py 1 location

@@ 24-68 (lines=45) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           base_period_start_datetime_local,
27
           base_period_end_datetime_local,
28
           reporting_start_datetime_local,
29
           reporting_end_datetime_local,
30
           period_type,
31
           language):
32
    ####################################################################################################################
33
    # Step 1: Validate the report data
34
    ####################################################################################################################
35
    if report is None:
36
        return None
37
38
    ####################################################################################################################
39
    # Step 2: Generate excel file from the report data
40
    ####################################################################################################################
41
    filename = generate_excel(report,
42
                              name,
43
                              base_period_start_datetime_local,
44
                              base_period_end_datetime_local,
45
                              reporting_start_datetime_local,
46
                              reporting_end_datetime_local,
47
                              period_type,
48
                              language)
49
    ####################################################################################################################
50
    # Step 3: Encode the excel file to Base64
51
    ####################################################################################################################
52
    binary_file_data = b''
53
    try:
54
        with open(filename, 'rb') as binary_file:
55
            binary_file_data = binary_file.read()
56
    except IOError as ex:
57
        print(str(ex))
58
59
    # Base64 encode the bytes
60
    base64_encoded_data = base64.b64encode(binary_file_data)
61
    # get the Base64 encoded data using human-readable characters.
62
    base64_message = base64_encoded_data.decode('utf-8')
63
    # delete the file from server
64
    try:
65
        os.remove(filename)
66
    except NotImplementedError as ex:
67
        print(str(ex))
68
    return base64_message
69
70
71
def generate_excel(report,

myems-api/excelexporters/equipmentcost.py 1 location

@@ 24-68 (lines=45) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           base_period_start_datetime_local,
27
           base_period_end_datetime_local,
28
           reporting_start_datetime_local,
29
           reporting_end_datetime_local,
30
           period_type,
31
           language):
32
    ####################################################################################################################
33
    # Step 1: Validate the report data
34
    ####################################################################################################################
35
    if report is None:
36
        return None
37
38
    ####################################################################################################################
39
    # Step 2: Generate excel file from the report data
40
    ####################################################################################################################
41
    filename = generate_excel(report,
42
                              name,
43
                              base_period_start_datetime_local,
44
                              base_period_end_datetime_local,
45
                              reporting_start_datetime_local,
46
                              reporting_end_datetime_local,
47
                              period_type,
48
                              language)
49
    ####################################################################################################################
50
    # Step 3: Encode the excel file to Base64
51
    ####################################################################################################################
52
    binary_file_data = b''
53
    try:
54
        with open(filename, 'rb') as binary_file:
55
            binary_file_data = binary_file.read()
56
    except IOError as ex:
57
        print(str(ex))
58
59
    # Base64 encode the bytes
60
    base64_encoded_data = base64.b64encode(binary_file_data)
61
    # get the Base64 encoded data using human-readable characters.
62
    base64_message = base64_encoded_data.decode('utf-8')
63
    # delete the file from server
64
    try:
65
        os.remove(filename)
66
    except NotImplementedError as ex:
67
        print(str(ex))
68
    return base64_message
69
70
71
def generate_excel(report,

myems-api/excelexporters/equipmentincome.py 1 location

@@ 24-68 (lines=45) @@
21
####################################################################################################################
22
23
24
def export(report,
25
           name,
26
           base_period_start_datetime_local,
27
           base_period_end_datetime_local,
28
           reporting_start_datetime_local,
29
           reporting_end_datetime_local,
30
           period_type,
31
           language):
32
    ####################################################################################################################
33
    # Step 1: Validate the report data
34
    ####################################################################################################################
35
    if report is None:
36
        return None
37
38
    ####################################################################################################################
39
    # Step 2: Generate excel file from the report data
40
    ####################################################################################################################
41
    filename = generate_excel(report,
42
                              name,
43
                              base_period_start_datetime_local,
44
                              base_period_end_datetime_local,
45
                              reporting_start_datetime_local,
46
                              reporting_end_datetime_local,
47
                              period_type,
48
                              language)
49
    ####################################################################################################################
50
    # Step 3: Encode the excel file to Base64
51
    ####################################################################################################################
52
    binary_file_data = b''
53
    try:
54
        with open(filename, 'rb') as binary_file:
55
            binary_file_data = binary_file.read()
56
    except IOError as ex:
57
        print(str(ex))
58
59
    # Base64 encode the bytes
60
    base64_encoded_data = base64.b64encode(binary_file_data)
61
    # get the Base64 encoded data using human-readable characters.
62
    base64_message = base64_encoded_data.decode('utf-8')
63
    # delete the file from server
64
    try:
65
        os.remove(filename)
66
    except NotImplementedError as ex:
67
        print(str(ex))
68
    return base64_message
69
70
71
def generate_excel(report,

myems-api/excelexporters/equipmentoutput.py 1 location

@@ 23-67 (lines=45) @@
20
####################################################################################################################
21
22
23
def export(report,
24
           name,
25
           base_period_start_datetime_local,
26
           base_period_end_datetime_local,
27
           reporting_start_datetime_local,
28
           reporting_end_datetime_local,
29
           period_type,
30
           language):
31
    ####################################################################################################################
32
    # Step 1: Validate the report data
33
    ####################################################################################################################
34
    if report is None:
35
        return None
36
37
    ####################################################################################################################
38
    # Step 2: Generate excel file from the report data
39
    ####################################################################################################################
40
    filename = generate_excel(report,
41
                              name,
42
                              base_period_start_datetime_local,
43
                              base_period_end_datetime_local,
44
                              reporting_start_datetime_local,
45
                              reporting_end_datetime_local,
46
                              period_type,
47
                              language)
48
    ####################################################################################################################
49
    # Step 3: Encode the excel file to Base64
50
    ####################################################################################################################
51
    binary_file_data = b''
52
    try:
53
        with open(filename, 'rb') as binary_file:
54
            binary_file_data = binary_file.read()
55
    except IOError as ex:
56
        print(str(ex))
57
58
    # Base64 encode the bytes
59
    base64_encoded_data = base64.b64encode(binary_file_data)
60
    # get the Base64 encoded data using human-readable characters.
61
    base64_message = base64_encoded_data.decode('utf-8')
62
    # delete the file from server
63
    try:
64
        os.remove(filename)
65
    except NotImplementedError as ex:
66
        print(str(ex))
67
    return base64_message
68
69
70
def generate_excel(report,

myems-api/excelexporters/equipmentenergycategory.py 1 location

@@ 23-67 (lines=45) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           base_period_start_datetime_local,
26
           base_period_end_datetime_local,
27
           reporting_start_datetime_local,
28
           reporting_end_datetime_local,
29
           period_type,
30
           language):
31
    ####################################################################################################################
32
    # Step 1: Validate the report data
33
    ####################################################################################################################
34
    if report is None:
35
        return None
36
37
    ####################################################################################################################
38
    # Step 2: Generate excel file from the report data
39
    ####################################################################################################################
40
    filename = generate_excel(report,
41
                              name,
42
                              base_period_start_datetime_local,
43
                              base_period_end_datetime_local,
44
                              reporting_start_datetime_local,
45
                              reporting_end_datetime_local,
46
                              period_type,
47
                              language)
48
    ####################################################################################################################
49
    # Step 3: Encode the excel file to Base64
50
    ####################################################################################################################
51
    binary_file_data = b''
52
    try:
53
        with open(filename, 'rb') as binary_file:
54
            binary_file_data = binary_file.read()
55
    except IOError as ex:
56
        print(str(ex))
57
58
    # Base64 encode the bytes
59
    base64_encoded_data = base64.b64encode(binary_file_data)
60
    # get the Base64 encoded data using human-readable characters.
61
    base64_message = base64_encoded_data.decode('utf-8')
62
    # delete the file from server
63
    try:
64
        os.remove(filename)
65
    except NotImplementedError as ex:
66
        print(str(ex))
67
    return base64_message
68
69
70
def generate_excel(report,

myems-api/excelexporters/equipmentstatistics.py 1 location

@@ 23-67 (lines=45) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           base_period_start_datetime_local,
26
           base_period_end_datetime_local,
27
           reporting_start_datetime_local,
28
           reporting_end_datetime_local,
29
           period_type,
30
           language):
31
    ####################################################################################################################
32
    # Step 1: Validate the report data
33
    ####################################################################################################################
34
    if report is None:
35
        return None
36
37
    ####################################################################################################################
38
    # Step 2: Generate excel file from the report data
39
    ####################################################################################################################
40
    filename = generate_excel(report,
41
                              name,
42
                              base_period_start_datetime_local,
43
                              base_period_end_datetime_local,
44
                              reporting_start_datetime_local,
45
                              reporting_end_datetime_local,
46
                              period_type,
47
                              language)
48
    ####################################################################################################################
49
    # Step 3: Encode the excel file to Base64
50
    ####################################################################################################################
51
    binary_file_data = b''
52
    try:
53
        with open(filename, 'rb') as binary_file:
54
            binary_file_data = binary_file.read()
55
    except IOError as ex:
56
        print(str(ex))
57
58
    # Base64 encode the bytes
59
    base64_encoded_data = base64.b64encode(binary_file_data)
60
    # get the Base64 encoded data using human-readable characters.
61
    base64_message = base64_encoded_data.decode('utf-8')
62
    # delete the file from server
63
    try:
64
        os.remove(filename)
65
    except NotImplementedError as ex:
66
        print(str(ex))
67
    return base64_message
68
69
70
def generate_excel(report,

myems-api/excelexporters/equipmentefficiency.py 1 location

@@ 23-67 (lines=45) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           base_period_start_datetime_local,
26
           base_period_end_datetime_local,
27
           reporting_start_datetime_local,
28
           reporting_end_datetime_local,
29
           period_type,
30
           language):
31
    ####################################################################################################################
32
    # Step 1: Validate the report data
33
    ####################################################################################################################
34
    if report is None:
35
        return None
36
37
    ####################################################################################################################
38
    # Step 2: Generate excel file from the report data
39
    ####################################################################################################################
40
    filename = generate_excel(report,
41
                              name,
42
                              base_period_start_datetime_local,
43
                              base_period_end_datetime_local,
44
                              reporting_start_datetime_local,
45
                              reporting_end_datetime_local,
46
                              period_type,
47
                              language)
48
    ####################################################################################################################
49
    # Step 3: Encode the excel file to Base64
50
    ####################################################################################################################
51
    binary_file_data = b''
52
    try:
53
        with open(filename, 'rb') as binary_file:
54
            binary_file_data = binary_file.read()
55
    except IOError as ex:
56
        print(str(ex))
57
58
    # Base64 encode the bytes
59
    base64_encoded_data = base64.b64encode(binary_file_data)
60
    # get the Base64 encoded data using human-readable characters.
61
    base64_message = base64_encoded_data.decode('utf-8')
62
    # delete the file from server
63
    try:
64
        os.remove(filename)
65
    except NotImplementedError as ex:
66
        print(str(ex))
67
    return base64_message
68
69
70
def generate_excel(report,

myems-api/excelexporters/equipmentenergyitem.py 1 location

@@ 23-67 (lines=45) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           base_period_start_datetime_local,
26
           base_period_end_datetime_local,
27
           reporting_start_datetime_local,
28
           reporting_end_datetime_local,
29
           period_type,
30
           language):
31
    ####################################################################################################################
32
    # Step 1: Validate the report data
33
    ####################################################################################################################
34
    if report is None:
35
        return None
36
37
    ####################################################################################################################
38
    # Step 2: Generate excel file from the report data
39
    ####################################################################################################################
40
    filename = generate_excel(report,
41
                              name,
42
                              base_period_start_datetime_local,
43
                              base_period_end_datetime_local,
44
                              reporting_start_datetime_local,
45
                              reporting_end_datetime_local,
46
                              period_type,
47
                              language)
48
    ####################################################################################################################
49
    # Step 3: Encode the excel file to Base64
50
    ####################################################################################################################
51
    binary_file_data = b''
52
    try:
53
        with open(filename, 'rb') as binary_file:
54
            binary_file_data = binary_file.read()
55
    except IOError as ex:
56
        print(str(ex))
57
58
    # Base64 encode the bytes
59
    base64_encoded_data = base64.b64encode(binary_file_data)
60
    # get the Base64 encoded data using human-readable characters.
61
    base64_message = base64_encoded_data.decode('utf-8')
62
    # delete the file from server
63
    try:
64
        os.remove(filename)
65
    except NotImplementedError as ex:
66
        print(str(ex))
67
    return base64_message
68
69
70
def generate_excel(report,

myems-api/excelexporters/equipmentload.py 1 location

@@ 23-67 (lines=45) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           base_period_start_datetime_local,
26
           base_period_end_datetime_local,
27
           reporting_start_datetime_local,
28
           reporting_end_datetime_local,
29
           period_type,
30
           language):
31
    ####################################################################################################################
32
    # Step 1: Validate the report data
33
    ####################################################################################################################
34
    if report is None:
35
        return None
36
37
    ####################################################################################################################
38
    # Step 2: Generate excel file from the report data
39
    ####################################################################################################################
40
    filename = generate_excel(report,
41
                              name,
42
                              base_period_start_datetime_local,
43
                              base_period_end_datetime_local,
44
                              reporting_start_datetime_local,
45
                              reporting_end_datetime_local,
46
                              period_type,
47
                              language)
48
    ####################################################################################################################
49
    # Step 3: Encode the excel file to Base64
50
    ####################################################################################################################
51
    binary_file_data = b''
52
    try:
53
        with open(filename, 'rb') as binary_file:
54
            binary_file_data = binary_file.read()
55
    except IOError as ex:
56
        print(str(ex))
57
58
    # Base64 encode the bytes
59
    base64_encoded_data = base64.b64encode(binary_file_data)
60
    # get the Base64 encoded data using human-readable characters.
61
    base64_message = base64_encoded_data.decode('utf-8')
62
    # delete the file from server
63
    try:
64
        os.remove(filename)
65
    except NotImplementedError as ex:
66
        print(str(ex))
67
    return base64_message
68
69
70
def generate_excel(report,

myems-api/excelexporters/virtualmetersaving.py 1 location

@@ 22-66 (lines=45) @@
19
# Step 3: Encode the excel file to Base64
20
########################################################################################################################
21
22
def export(report,
23
           name,
24
           base_period_start_datetime_local,
25
           base_period_end_datetime_local,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              base_period_start_datetime_local,
42
                              base_period_end_datetime_local,
43
                              reporting_start_datetime_local,
44
                              reporting_end_datetime_local,
45
                              period_type,
46
                              language)
47
    ####################################################################################################################
48
    # Step 3: Encode the excel file to Base64
49
    ####################################################################################################################
50
    binary_file_data = b''
51
    try:
52
        with open(filename, 'rb') as binary_file:
53
            binary_file_data = binary_file.read()
54
    except IOError as ex:
55
        print(str(ex))
56
57
    # Base64 encode the bytes
58
    base64_encoded_data = base64.b64encode(binary_file_data)
59
    # get the Base64 encoded data using human-readable characters.
60
    base64_message = base64_encoded_data.decode('utf-8')
61
    # delete the file from server
62
    try:
63
        os.remove(filename)
64
    except NotImplementedError as ex:
65
        print(str(ex))
66
    return base64_message
67
68
69
def generate_excel(report,

myems-api/excelexporters/virtualmeterenergy.py 1 location

@@ 22-66 (lines=45) @@
19
# Step 3: Encode the excel file to Base64
20
########################################################################################################################
21
22
def export(report,
23
           name,
24
           base_period_start_datetime_local,
25
           base_period_end_datetime_local,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              base_period_start_datetime_local,
42
                              base_period_end_datetime_local,
43
                              reporting_start_datetime_local,
44
                              reporting_end_datetime_local,
45
                              period_type,
46
                              language)
47
    ####################################################################################################################
48
    # Step 3: Encode the excel file to Base64
49
    ####################################################################################################################
50
    binary_file_data = b''
51
    try:
52
        with open(filename, 'rb') as binary_file:
53
            binary_file_data = binary_file.read()
54
    except IOError as ex:
55
        print(str(ex))
56
57
    # Base64 encode the bytes
58
    base64_encoded_data = base64.b64encode(binary_file_data)
59
    # get the Base64 encoded data using human-readable characters.
60
    base64_message = base64_encoded_data.decode('utf-8')
61
    # delete the file from server
62
    try:
63
        os.remove(filename)
64
    except NotImplementedError as ex:
65
        print(str(ex))
66
    return base64_message
67
68
69
def generate_excel(report,

myems-api/excelexporters/metersaving.py 1 location

@@ 22-66 (lines=45) @@
19
# Step 3: Encode the excel file to Base64
20
########################################################################################################################
21
22
def export(report,
23
           name,
24
           base_period_start_datetime_local,
25
           base_period_end_datetime_local,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              base_period_start_datetime_local,
42
                              base_period_end_datetime_local,
43
                              reporting_start_datetime_local,
44
                              reporting_end_datetime_local,
45
                              period_type,
46
                              language)
47
    ####################################################################################################################
48
    # Step 3: Encode the excel file to Base64
49
    ####################################################################################################################
50
    binary_file_data = b''
51
    try:
52
        with open(filename, 'rb') as binary_file:
53
            binary_file_data = binary_file.read()
54
    except IOError as ex:
55
        print(str(ex))
56
57
    # Base64 encode the bytes
58
    base64_encoded_data = base64.b64encode(binary_file_data)
59
    # get the Base64 encoded data using human-readable characters.
60
    base64_message = base64_encoded_data.decode('utf-8')
61
    # delete the file from server
62
    try:
63
        os.remove(filename)
64
    except NotImplementedError as ex:
65
        print(str(ex))
66
    return base64_message
67
68
69
def generate_excel(report,

myems-api/excelexporters/offlinemeterenergy.py 1 location

@@ 22-66 (lines=45) @@
19
# Step 3: Encode the excel file to Base64
20
########################################################################################################################
21
22
def export(result,
23
           name,
24
           base_period_start_datetime_local,
25
           base_period_end_datetime_local,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if result is None:
34
        return None
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(result,
40
                              name,
41
                              base_period_start_datetime_local,
42
                              base_period_end_datetime_local,
43
                              reporting_start_datetime_local,
44
                              reporting_end_datetime_local,
45
                              period_type,
46
                              language)
47
    ####################################################################################################################
48
    # Step 3: Encode the excel file to Base64
49
    ####################################################################################################################
50
    binary_file_data = b''
51
    try:
52
        with open(filename, 'rb') as binary_file:
53
            binary_file_data = binary_file.read()
54
    except IOError as ex:
55
        print(str(ex))
56
57
    # Base64 encode the bytes
58
    base64_encoded_data = base64.b64encode(binary_file_data)
59
    # get the Base64 encoded data using human-readable characters.
60
    base64_message = base64_encoded_data.decode('utf-8')
61
    # delete the file from server
62
    try:
63
        os.remove(filename)
64
    except NotImplementedError as ex:
65
        print(str(ex))
66
    return base64_message
67
68
69
def generate_excel(report,

myems-api/excelexporters/combinedequipmentincome.py 1 location

@@ 24-65 (lines=42) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
    print(report)
36
37
    ####################################################################################################################
38
    # Step 2: Generate excel file from the report data
39
    ####################################################################################################################
40
    filename = generate_excel(report,
41
                              name,
42
                              reporting_start_datetime_local,
43
                              reporting_end_datetime_local,
44
                              period_type,
45
                              language)
46
    ####################################################################################################################
47
    # Step 3: Encode the excel file to Base64
48
    ####################################################################################################################
49
    binary_file_data = b''
50
    try:
51
        with open(filename, 'rb') as binary_file:
52
            binary_file_data = binary_file.read()
53
    except IOError as ex:
54
        print(str(ex))
55
56
    # Base64 encode the bytes
57
    base64_encoded_data = base64.b64encode(binary_file_data)
58
    # get the Base64 encoded data using human-readable characters.
59
    base64_message = base64_encoded_data.decode('utf-8')
60
    # delete the file from server
61
    try:
62
        os.remove(filename)
63
    except NotImplementedError as ex:
64
        print(str(ex))
65
    return base64_message
66
67
68
def generate_excel(report,

myems-api/excelexporters/combinedequipmentcost.py 1 location

@@ 24-65 (lines=42) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
    print(report)
36
37
    ####################################################################################################################
38
    # Step 2: Generate excel file from the report data
39
    ####################################################################################################################
40
    filename = generate_excel(report,
41
                              name,
42
                              reporting_start_datetime_local,
43
                              reporting_end_datetime_local,
44
                              period_type,
45
                              language)
46
    ####################################################################################################################
47
    # Step 3: Encode the excel file to Base64
48
    ####################################################################################################################
49
    binary_file_data = b''
50
    try:
51
        with open(filename, 'rb') as binary_file:
52
            binary_file_data = binary_file.read()
53
    except IOError as ex:
54
        print(str(ex))
55
56
    # Base64 encode the bytes
57
    base64_encoded_data = base64.b64encode(binary_file_data)
58
    # get the Base64 encoded data using human-readable characters.
59
    base64_message = base64_encoded_data.decode('utf-8')
60
    # delete the file from server
61
    try:
62
        os.remove(filename)
63
    except NotImplementedError as ex:
64
        print(str(ex))
65
    return base64_message
66
67
68
def generate_excel(report,

myems-api/excelexporters/combinedequipmentsaving.py 1 location

@@ 24-65 (lines=42) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
    print(report)
36
37
    ####################################################################################################################
38
    # Step 2: Generate excel file from the report data
39
    ####################################################################################################################
40
    filename = generate_excel(report,
41
                              name,
42
                              reporting_start_datetime_local,
43
                              reporting_end_datetime_local,
44
                              period_type,
45
                              language)
46
    ####################################################################################################################
47
    # Step 3: Encode the excel file to Base64
48
    ####################################################################################################################
49
    binary_file_data = b''
50
    try:
51
        with open(filename, 'rb') as binary_file:
52
            binary_file_data = binary_file.read()
53
    except IOError as ex:
54
        print(str(ex))
55
56
    # Base64 encode the bytes
57
    base64_encoded_data = base64.b64encode(binary_file_data)
58
    # get the Base64 encoded data using human-readable characters.
59
    base64_message = base64_encoded_data.decode('utf-8')
60
    # delete the file from server
61
    try:
62
        os.remove(filename)
63
    except NotImplementedError as ex:
64
        print(str(ex))
65
    return base64_message
66
67
68
def generate_excel(report,

myems-api/excelexporters/combinedequipmentcarbon.py 1 location

@@ 24-65 (lines=42) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
    print(report)
36
37
    ####################################################################################################################
38
    # Step 2: Generate excel file from the report data
39
    ####################################################################################################################
40
    filename = generate_excel(report,
41
                              name,
42
                              reporting_start_datetime_local,
43
                              reporting_end_datetime_local,
44
                              period_type,
45
                              language)
46
    ####################################################################################################################
47
    # Step 3: Encode the excel file to Base64
48
    ####################################################################################################################
49
    binary_file_data = b''
50
    try:
51
        with open(filename, 'rb') as binary_file:
52
            binary_file_data = binary_file.read()
53
    except IOError as ex:
54
        print(str(ex))
55
56
    # Base64 encode the bytes
57
    base64_encoded_data = base64.b64encode(binary_file_data)
58
    # get the Base64 encoded data using human-readable characters.
59
    base64_message = base64_encoded_data.decode('utf-8')
60
    # delete the file from server
61
    try:
62
        os.remove(filename)
63
    except NotImplementedError as ex:
64
        print(str(ex))
65
    return base64_message
66
67
68
def generate_excel(report,

myems-api/excelexporters/metertrend.py 1 location

@@ 23-64 (lines=42) @@
20
########################################################################################################################
21
22
23
def export(result,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if result is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(result,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
45
    ####################################################################################################################
46
    # Step 3: Encode the excel file to Base64
47
    ####################################################################################################################
48
    binary_file_data = b''
49
    try:
50
        with open(filename, 'rb') as binary_file:
51
            binary_file_data = binary_file.read()
52
    except IOError as ex:
53
        print(str(ex))
54
55
    # Base64 encode the bytes
56
    base64_encoded_data = base64.b64encode(binary_file_data)
57
    # get the Base64 encoded data using human-readable characters.
58
    base64_message = base64_encoded_data.decode('utf-8')
59
    # delete the file from server
60
    try:
61
        os.remove(filename)
62
    except NotImplementedError as ex:
63
        print(str(ex))
64
    return base64_message
65
66
67
def generate_excel(report,

myems-api/excelexporters/combinedequipmentenergyitem.py 1 location

@@ 23-64 (lines=42) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
    print(report)
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              reporting_start_datetime_local,
42
                              reporting_end_datetime_local,
43
                              period_type,
44
                              language)
45
    ####################################################################################################################
46
    # Step 3: Encode the excel file to Base64
47
    ####################################################################################################################
48
    binary_file_data = b''
49
    try:
50
        with open(filename, 'rb') as binary_file:
51
            binary_file_data = binary_file.read()
52
    except IOError as ex:
53
        print(str(ex))
54
55
    # Base64 encode the bytes
56
    base64_encoded_data = base64.b64encode(binary_file_data)
57
    # get the Base64 encoded data using human-readable characters.
58
    base64_message = base64_encoded_data.decode('utf-8')
59
    # delete the file from server
60
    try:
61
        os.remove(filename)
62
    except NotImplementedError as ex:
63
        print(str(ex))
64
    return base64_message
65
66
67
def generate_excel(report,

myems-api/excelexporters/combinedequipmentoutput.py 1 location

@@ 23-64 (lines=42) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
    print(report)
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              reporting_start_datetime_local,
42
                              reporting_end_datetime_local,
43
                              period_type,
44
                              language)
45
    ####################################################################################################################
46
    # Step 3: Encode the excel file to Base64
47
    ####################################################################################################################
48
    binary_file_data = b''
49
    try:
50
        with open(filename, 'rb') as binary_file:
51
            binary_file_data = binary_file.read()
52
    except IOError as ex:
53
        print(str(ex))
54
55
    # Base64 encode the bytes
56
    base64_encoded_data = base64.b64encode(binary_file_data)
57
    # get the Base64 encoded data using human-readable characters.
58
    base64_message = base64_encoded_data.decode('utf-8')
59
    # delete the file from server
60
    try:
61
        os.remove(filename)
62
    except NotImplementedError as ex:
63
        print(str(ex))
64
    return base64_message
65
66
67
def generate_excel(report,

myems-api/excelexporters/combinedequipmentstatistics.py 1 location

@@ 23-64 (lines=42) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
    print(report)
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              reporting_start_datetime_local,
42
                              reporting_end_datetime_local,
43
                              period_type,
44
                              language)
45
    ####################################################################################################################
46
    # Step 3: Encode the excel file to Base64
47
    ####################################################################################################################
48
    binary_file_data = b''
49
    try:
50
        with open(filename, 'rb') as binary_file:
51
            binary_file_data = binary_file.read()
52
    except IOError as ex:
53
        print(str(ex))
54
55
    # Base64 encode the bytes
56
    base64_encoded_data = base64.b64encode(binary_file_data)
57
    # get the Base64 encoded data using human-readable characters.
58
    base64_message = base64_encoded_data.decode('utf-8')
59
    # delete the file from server
60
    try:
61
        os.remove(filename)
62
    except NotImplementedError as ex:
63
        print(str(ex))
64
    return base64_message
65
66
67
def generate_excel(report,

myems-api/excelexporters/tenantcost.py 1 location

@@ 24-64 (lines=41) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              reporting_start_datetime_local,
42
                              reporting_end_datetime_local,
43
                              period_type,
44
                              language)
45
    ####################################################################################################################
46
    # Step 3: Encode the excel file to Base64
47
    ####################################################################################################################
48
    binary_file_data = b''
49
    try:
50
        with open(filename, 'rb') as binary_file:
51
            binary_file_data = binary_file.read()
52
    except IOError as ex:
53
        print(str(ex))
54
55
    # Base64 encode the bytes
56
    base64_encoded_data = base64.b64encode(binary_file_data)
57
    # get the Base64 encoded data using human-readable characters.
58
    base64_message = base64_encoded_data.decode('utf-8')
59
    # delete the file from server
60
    try:
61
        os.remove(filename)
62
    except NotImplementedError as ex:
63
        print(str(ex))
64
    return base64_message
65
66
67
def generate_excel(report,

myems-api/excelexporters/storecarbon.py 1 location

@@ 24-64 (lines=41) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              reporting_start_datetime_local,
42
                              reporting_end_datetime_local,
43
                              period_type,
44
                              language)
45
    ####################################################################################################################
46
    # Step 3: Encode the excel file to Base64
47
    ####################################################################################################################
48
    binary_file_data = b''
49
    try:
50
        with open(filename, 'rb') as binary_file:
51
            binary_file_data = binary_file.read()
52
    except IOError as ex:
53
        print(str(ex))
54
55
    # Base64 encode the bytes
56
    base64_encoded_data = base64.b64encode(binary_file_data)
57
    # get the Base64 encoded data using human-readable characters.
58
    base64_message = base64_encoded_data.decode('utf-8')
59
    # delete the file from server
60
    try:
61
        os.remove(filename)
62
    except NotImplementedError as ex:
63
        print(str(ex))
64
    return base64_message
65
66
67
def generate_excel(report,

myems-api/excelexporters/tenantcarbon.py 1 location

@@ 24-64 (lines=41) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              reporting_start_datetime_local,
42
                              reporting_end_datetime_local,
43
                              period_type,
44
                              language)
45
    ####################################################################################################################
46
    # Step 3: Encode the excel file to Base64
47
    ####################################################################################################################
48
    binary_file_data = b''
49
    try:
50
        with open(filename, 'rb') as binary_file:
51
            binary_file_data = binary_file.read()
52
    except IOError as ex:
53
        print(str(ex))
54
55
    # Base64 encode the bytes
56
    base64_encoded_data = base64.b64encode(binary_file_data)
57
    # get the Base64 encoded data using human-readable characters.
58
    base64_message = base64_encoded_data.decode('utf-8')
59
    # delete the file from server
60
    try:
61
        os.remove(filename)
62
    except NotImplementedError as ex:
63
        print(str(ex))
64
    return base64_message
65
66
67
def generate_excel(report,

myems-api/excelexporters/shopfloorcost.py 1 location

@@ 24-64 (lines=41) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              reporting_start_datetime_local,
42
                              reporting_end_datetime_local,
43
                              period_type,
44
                              language)
45
    ####################################################################################################################
46
    # Step 3: Encode the excel file to Base64
47
    ####################################################################################################################
48
    binary_file_data = b''
49
    try:
50
        with open(filename, 'rb') as binary_file:
51
            binary_file_data = binary_file.read()
52
    except IOError as ex:
53
        print(str(ex))
54
55
    # Base64 encode the bytes
56
    base64_encoded_data = base64.b64encode(binary_file_data)
57
    # get the Base64 encoded data using human-readable characters.
58
    base64_message = base64_encoded_data.decode('utf-8')
59
    # delete the file from server
60
    try:
61
        os.remove(filename)
62
    except NotImplementedError as ex:
63
        print(str(ex))
64
    return base64_message
65
66
67
def generate_excel(report,

myems-api/excelexporters/shopfloorcarbon.py 1 location

@@ 24-64 (lines=41) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              reporting_start_datetime_local,
42
                              reporting_end_datetime_local,
43
                              period_type,
44
                              language)
45
    ####################################################################################################################
46
    # Step 3: Encode the excel file to Base64
47
    ####################################################################################################################
48
    binary_file_data = b''
49
    try:
50
        with open(filename, 'rb') as binary_file:
51
            binary_file_data = binary_file.read()
52
    except IOError as ex:
53
        print(str(ex))
54
55
    # Base64 encode the bytes
56
    base64_encoded_data = base64.b64encode(binary_file_data)
57
    # get the Base64 encoded data using human-readable characters.
58
    base64_message = base64_encoded_data.decode('utf-8')
59
    # delete the file from server
60
    try:
61
        os.remove(filename)
62
    except NotImplementedError as ex:
63
        print(str(ex))
64
    return base64_message
65
66
67
def generate_excel(report,

myems-api/excelexporters/storecost.py 1 location

@@ 24-64 (lines=41) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              reporting_start_datetime_local,
42
                              reporting_end_datetime_local,
43
                              period_type,
44
                              language)
45
    ####################################################################################################################
46
    # Step 3: Encode the excel file to Base64
47
    ####################################################################################################################
48
    binary_file_data = b''
49
    try:
50
        with open(filename, 'rb') as binary_file:
51
            binary_file_data = binary_file.read()
52
    except IOError as ex:
53
        print(str(ex))
54
55
    # Base64 encode the bytes
56
    base64_encoded_data = base64.b64encode(binary_file_data)
57
    # get the Base64 encoded data using human-readable characters.
58
    base64_message = base64_encoded_data.decode('utf-8')
59
    # delete the file from server
60
    try:
61
        os.remove(filename)
62
    except NotImplementedError as ex:
63
        print(str(ex))
64
    return base64_message
65
66
67
def generate_excel(report,

myems-api/excelexporters/shopfloorsaving.py 1 location

@@ 24-64 (lines=41) @@
21
####################################################################################################################
22
23
24
def export(report,
25
           name,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              reporting_start_datetime_local,
42
                              reporting_end_datetime_local,
43
                              period_type,
44
                              language)
45
    ####################################################################################################################
46
    # Step 3: Encode the excel file to Base64
47
    ####################################################################################################################
48
    binary_file_data = b''
49
    try:
50
        with open(filename, 'rb') as binary_file:
51
            binary_file_data = binary_file.read()
52
    except IOError as ex:
53
        print(str(ex))
54
55
    # Base64 encode the bytes
56
    base64_encoded_data = base64.b64encode(binary_file_data)
57
    # get the Base64 encoded data using human-readable characters.
58
    base64_message = base64_encoded_data.decode('utf-8')
59
    # delete the file from server
60
    try:
61
        os.remove(filename)
62
    except NotImplementedError as ex:
63
        print(str(ex))
64
    return base64_message
65
66
67
def generate_excel(report,

myems-api/excelexporters/tenantsaving.py 1 location

@@ 24-64 (lines=41) @@
21
########################################################################################################################
22
23
24
def export(report,
25
           name,
26
           reporting_start_datetime_local,
27
           reporting_end_datetime_local,
28
           period_type,
29
           language):
30
    ####################################################################################################################
31
    # Step 1: Validate the report data
32
    ####################################################################################################################
33
    if report is None:
34
        return None
35
36
    ####################################################################################################################
37
    # Step 2: Generate excel file from the report data
38
    ####################################################################################################################
39
    filename = generate_excel(report,
40
                              name,
41
                              reporting_start_datetime_local,
42
                              reporting_end_datetime_local,
43
                              period_type,
44
                              language)
45
    ####################################################################################################################
46
    # Step 3: Encode the excel file to Base64
47
    ####################################################################################################################
48
    binary_file_data = b''
49
    try:
50
        with open(filename, 'rb') as binary_file:
51
            binary_file_data = binary_file.read()
52
    except IOError as ex:
53
        print(str(ex))
54
55
    # Base64 encode the bytes
56
    base64_encoded_data = base64.b64encode(binary_file_data)
57
    # get the Base64 encoded data using human-readable characters.
58
    base64_message = base64_encoded_data.decode('utf-8')
59
    # delete the file from server
60
    try:
61
        os.remove(filename)
62
    except NotImplementedError as ex:
63
        print(str(ex))
64
    return base64_message
65
66
67
def generate_excel(report,

myems-api/excelexporters/shopfloorstatistics.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/storeenergycategory.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/shopfloorenergycategory.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/combinedequipmentload.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/storesaving.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/tenantstatistics.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/combinedequipmentefficiency.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/shopfloorenergyitem.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/storeload.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/combinedequipmentenergycategory.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/tenantenergyitem.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/storeenergyitem.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/tenantload.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report, name, reporting_start_datetime_local, reporting_end_datetime_local, period_type, language):

myems-api/excelexporters/shopfloorload.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/tenantenergycategory.py 1 location

@@ 23-63 (lines=41) @@
20
########################################################################################################################
21
22
23
def export(report,
24
           name,
25
           reporting_start_datetime_local,
26
           reporting_end_datetime_local,
27
           period_type,
28
           language):
29
    ####################################################################################################################
30
    # Step 1: Validate the report data
31
    ####################################################################################################################
32
    if report is None:
33
        return None
34
35
    ####################################################################################################################
36
    # Step 2: Generate excel file from the report data
37
    ####################################################################################################################
38
    filename = generate_excel(report,
39
                              name,
40
                              reporting_start_datetime_local,
41
                              reporting_end_datetime_local,
42
                              period_type,
43
                              language)
44
    ####################################################################################################################
45
    # Step 3: Encode the excel file to Base64
46
    ####################################################################################################################
47
    binary_file_data = b''
48
    try:
49
        with open(filename, 'rb') as binary_file:
50
            binary_file_data = binary_file.read()
51
    except IOError as ex:
52
        print(str(ex))
53
54
    # Base64 encode the bytes
55
    base64_encoded_data = base64.b64encode(binary_file_data)
56
    # get the Base64 encoded data using human-readable characters.
57
    base64_message = base64_encoded_data.decode('utf-8')
58
    # delete the file from server
59
    try:
60
        os.remove(filename)
61
    except NotImplementedError as ex:
62
        print(str(ex))
63
    return base64_message
64
65
66
def generate_excel(report,

myems-api/excelexporters/storestatistics.py 1 location

@@ 22-62 (lines=41) @@
19
########################################################################################################################
20
21
22
def export(report,
23
           name,
24
           reporting_start_datetime_local,
25
           reporting_end_datetime_local,
26
           period_type,
27
           language):
28
    ####################################################################################################################
29
    # Step 1: Validate the report data
30
    ####################################################################################################################
31
    if report is None:
32
        return None
33
34
    ####################################################################################################################
35
    # Step 2: Generate excel file from the report data
36
    ####################################################################################################################
37
    filename = generate_excel(report,
38
                              name,
39
                              reporting_start_datetime_local,
40
                              reporting_end_datetime_local,
41
                              period_type,
42
                              language)
43
    ####################################################################################################################
44
    # Step 3: Encode the excel file to Base64
45
    ####################################################################################################################
46
    binary_file_data = b''
47
    try:
48
        with open(filename, 'rb') as binary_file:
49
            binary_file_data = binary_file.read()
50
    except IOError as ex:
51
        print(str(ex))
52
53
    # Base64 encode the bytes
54
    base64_encoded_data = base64.b64encode(binary_file_data)
55
    # get the Base64 encoded data using human-readable characters.
56
    base64_message = base64_encoded_data.decode('utf-8')
57
    # delete the file from server
58
    try:
59
        os.remove(filename)
60
    except NotImplementedError as ex:
61
        print(str(ex))
62
    return base64_message
63
64
65
def generate_excel(report,

myems-api/excelexporters/tenantbill.py 1 location

@@ 21-61 (lines=41) @@
18
########################################################################################################################
19
20
21
def export(report,
22
           name,
23
           reporting_start_datetime_local,
24
           reporting_end_datetime_local,
25
           period_type,
26
           language):
27
    ####################################################################################################################
28
    # Step 1: Validate the report data
29
    ####################################################################################################################
30
    if report is None:
31
        return None
32
33
    ####################################################################################################################
34
    # Step 2: Generate excel file from the report data
35
    ####################################################################################################################
36
    filename = generate_excel(report,
37
                              name,
38
                              reporting_start_datetime_local,
39
                              reporting_end_datetime_local,
40
                              period_type,
41
                              language)
42
    ####################################################################################################################
43
    # Step 3: Encode the excel file to Base64
44
    ####################################################################################################################
45
    binary_file_data = b''
46
    try:
47
        with open(filename, 'rb') as binary_file:
48
            binary_file_data = binary_file.read()
49
    except IOError as ex:
50
        print(str(ex))
51
52
    # Base64 encode the bytes
53
    base64_encoded_data = base64.b64encode(binary_file_data)
54
    # get the Base64 encoded data using human-readable characters.
55
    base64_message = base64_encoded_data.decode('utf-8')
56
    # delete the file from server
57
    try:
58
        os.remove(filename)
59
    except NotImplementedError as ex:
60
        print(str(ex))
61
    return base64_message
62
63
64
def generate_excel(report,

myems-api/excelexporters/meterenergy.py 1 location

@@ 22-60 (lines=39) @@
19
# Step 3: Encode the excel file to Base64
20
########################################################################################################################
21
22
def export(report, name, reporting_start_datetime_local, reporting_end_datetime_local, base_period_start_datetime,
23
           base_period_end_datetime, period_type, language):
24
    ####################################################################################################################
25
    # Step 1: Validate the report data
26
    ####################################################################################################################
27
    if report is None:
28
        return None
29
30
    ####################################################################################################################
31
    # Step 2: Generate excel file from the report data
32
    ####################################################################################################################
33
    filename = generate_excel(report,
34
                              name,
35
                              reporting_start_datetime_local,
36
                              reporting_end_datetime_local,
37
                              base_period_start_datetime,
38
                              base_period_end_datetime,
39
                              period_type,
40
                              language)
41
    ####################################################################################################################
42
    # Step 3: Encode the excel file to Base64
43
    ####################################################################################################################
44
    binary_file_data = b''
45
    try:
46
        with open(filename, 'rb') as binary_file:
47
            binary_file_data = binary_file.read()
48
    except IOError as ex:
49
        print(str(ex))
50
51
    # Base64 encode the bytes
52
    base64_encoded_data = base64.b64encode(binary_file_data)
53
    # get the Base64 encoded data using human-readable characters.
54
    base64_message = base64_encoded_data.decode('utf-8')
55
    # delete the file from server
56
    try:
57
        os.remove(filename)
58
    except NotImplementedError as ex:
59
        print(str(ex))
60
    return base64_message
61
62
63
def generate_excel(report, name, reporting_start_datetime_local, reporting_end_datetime_local,

myems-api/excelexporters/metercomparison.py 1 location

@@ 22-58 (lines=37) @@
19
# Step 3: Encode the excel file to Base64
20
########################################################################################################################
21
22
def export(result, name1, name2, reporting_start_datetime_local, reporting_end_datetime_local, period_type, language):
23
    ####################################################################################################################
24
    # Step 1: Validate the report data
25
    ####################################################################################################################
26
    if result is None:
27
        return None
28
29
    ####################################################################################################################
30
    # Step 2: Generate excel file from the report data
31
    ####################################################################################################################
32
    filename = generate_excel(result,
33
                              name1,
34
                              name2,
35
                              reporting_start_datetime_local,
36
                              reporting_end_datetime_local,
37
                              period_type,
38
                              language)
39
    ####################################################################################################################
40
    # Step 3: Encode the excel file to Base64
41
    ####################################################################################################################
42
    binary_file_data = b''
43
    try:
44
        with open(filename, 'rb') as binary_file:
45
            binary_file_data = binary_file.read()
46
    except IOError as ex:
47
        print(str(ex))
48
49
    # Base64 encode the bytes
50
    base64_encoded_data = base64.b64encode(binary_file_data)
51
    # get the Base64 encoded data using human-readable characters.
52
    base64_message = base64_encoded_data.decode('utf-8')
53
    # delete the file from server
54
    try:
55
        os.remove(filename)
56
    except NotImplementedError as ex:
57
        print(str(ex))
58
    return base64_message
59
60
61
def generate_excel(report, name1, name2, reporting_start_datetime_local, reporting_end_datetime_local, period_type,

myems-api/excelexporters/metertracking.py 1 location

@@ 19-55 (lines=37) @@
16
# Step 3: Encode the excelexporters file to Base64
17
########################################################################################################################
18
19
def export(result, space_name, energy_category_name, reporting_start_datetime_local, reporting_end_datetime_local,
20
           language):
21
    ####################################################################################################################
22
    # Step 1: Validate the report data
23
    ####################################################################################################################
24
    if result is None:
25
        return None
26
27
    ####################################################################################################################
28
    # Step 2: Generate excel file from the report data
29
    ####################################################################################################################
30
    filename = generate_excel(result,
31
                              space_name,
32
                              energy_category_name,
33
                              reporting_start_datetime_local,
34
                              reporting_end_datetime_local,
35
                              language)
36
    ####################################################################################################################
37
    # Step 3: Encode the excel file to Base64
38
    ####################################################################################################################
39
    binary_file_data = b''
40
    try:
41
        with open(filename, 'rb') as binary_file:
42
            binary_file_data = binary_file.read()
43
    except IOError as ex:
44
        print(str(ex))
45
46
    # Base64 encode the bytes
47
    base64_encoded_data = base64.b64encode(binary_file_data)
48
    # get the Base64 encoded data using human-readable characters.
49
    base64_message = base64_encoded_data.decode('utf-8')
50
    # delete the file from server
51
    try:
52
        os.remove(filename)
53
    except NotImplementedError as ex:
54
        print(str(ex))
55
    return base64_message
56
57
58
def generate_excel(report, space_name, energy_category_name, reporting_start_datetime_local,

myems-api/excelexporters/metersubmetersbalance.py 1 location

@@ 22-57 (lines=36) @@
19
# Step 3: Encode the excelexporters file to Base64
20
########################################################################################################################
21
22
def export(result, name, reporting_start_datetime_local, reporting_end_datetime_local, period_type, language):
23
    ####################################################################################################################
24
    # Step 1: Validate the report data
25
    ####################################################################################################################
26
    if result is None:
27
        return None
28
29
    ####################################################################################################################
30
    # Step 2: Generate excel file from the report data
31
    ####################################################################################################################
32
    filename = generate_excel(result,
33
                              name,
34
                              reporting_start_datetime_local,
35
                              reporting_end_datetime_local,
36
                              period_type,
37
                              language)
38
    ####################################################################################################################
39
    # Step 3: Encode the excel file to Base64
40
    ####################################################################################################################
41
    binary_file_data = b''
42
    try:
43
        with open(filename, 'rb') as binary_file:
44
            binary_file_data = binary_file.read()
45
    except IOError as ex:
46
        print(str(ex))
47
48
    # Base64 encode the bytes
49
    base64_encoded_data = base64.b64encode(binary_file_data)
50
    # get the Base64 encoded data using human-readable characters.
51
    base64_message = base64_encoded_data.decode('utf-8')
52
    # delete the file from server
53
    try:
54
        os.remove(filename)
55
    except NotImplementedError as ex:
56
        print(str(ex))
57
    return base64_message
58
59
60
def generate_excel(report, name, reporting_start_datetime_local, reporting_end_datetime_local, period_type, language):