Code Duplication    Length = 32-40 lines in 59 locations

myems-api/excelexporters/combinedequipmentcost.py 1 location

@@ 22-61 (lines=40) @@
19
########################################################################################################################
20
21
22
def export(report,
23
           name,
24
           reporting_start_datetime_local,
25
           reporting_end_datetime_local,
26
           period_type):
27
    ####################################################################################################################
28
    # Step 1: Validate the report data
29
    ####################################################################################################################
30
    if report is None:
31
        return None
32
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
61
    return base64_message
62
63
64
def generate_excel(report,

myems-api/excelexporters/spacecost.py 1 location

@@ 22-61 (lines=40) @@
19
########################################################################################################################
20
21
22
def export(report,
23
           name,
24
           reporting_start_datetime_local,
25
           reporting_end_datetime_local,
26
           period_type):
27
    ####################################################################################################################
28
    # Step 1: Validate the report data
29
    ####################################################################################################################
30
    if report is None:
31
        return None
32
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
61
    return base64_message
62
63
64
def generate_excel(report,

myems-api/excelexporters/combinedequipmentsaving.py 1 location

@@ 22-61 (lines=40) @@
19
########################################################################################################################
20
21
22
def export(report,
23
           name,
24
           reporting_start_datetime_local,
25
           reporting_end_datetime_local,
26
           period_type):
27
    ####################################################################################################################
28
    # Step 1: Validate the report data
29
    ####################################################################################################################
30
    if report is None:
31
        return None
32
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
61
    return base64_message
62
63
64
def generate_excel(report,

myems-api/excelexporters/combinedequipmentincome.py 1 location

@@ 22-61 (lines=40) @@
19
########################################################################################################################
20
21
22
def export(report,
23
           name,
24
           reporting_start_datetime_local,
25
           reporting_end_datetime_local,
26
           period_type):
27
    ####################################################################################################################
28
    # Step 1: Validate the report data
29
    ####################################################################################################################
30
    if report is None:
31
        return None
32
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
61
    return base64_message
62
63
64
def generate_excel(report,

myems-api/excelexporters/spaceincome.py 1 location

@@ 22-61 (lines=40) @@
19
####################################################################################################################
20
21
22
def export(report,
23
           name,
24
           reporting_start_datetime_local,
25
           reporting_end_datetime_local,
26
           period_type):
27
    ####################################################################################################################
28
    # Step 1: Validate the report data
29
    ####################################################################################################################
30
    if report is None:
31
        return None
32
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
61
    return base64_message
62
63
64
def generate_excel(report,

myems-api/excelexporters/metertrend.py 1 location

@@ 21-60 (lines=40) @@
18
########################################################################################################################
19
20
21
def export(result,
22
           name,
23
           reporting_start_datetime_local,
24
           reporting_end_datetime_local,
25
           period_type):
26
    ####################################################################################################################
27
    # Step 1: Validate the report data
28
    ####################################################################################################################
29
    if result is None:
30
        return None
31
32
    ####################################################################################################################
33
    # Step 2: Generate excel file from the report data
34
    ####################################################################################################################
35
    filename = generate_excel(result,
36
                              name,
37
                              reporting_start_datetime_local,
38
                              reporting_end_datetime_local,
39
                              period_type)
40
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/combinedequipmentstatistics.py 1 location

@@ 21-60 (lines=40) @@
18
########################################################################################################################
19
20
21
def export(report,
22
           name,
23
           reporting_start_datetime_local,
24
           reporting_end_datetime_local,
25
           period_type):
26
    ####################################################################################################################
27
    # Step 1: Validate the report data
28
    ####################################################################################################################
29
    if report is None:
30
        return None
31
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/spaceenergycategory.py 1 location

@@ 21-60 (lines=40) @@
18
########################################################################################################################
19
20
21
def export(report,
22
           name,
23
           reporting_start_datetime_local,
24
           reporting_end_datetime_local,
25
           period_type):
26
    ####################################################################################################################
27
    # Step 1: Validate the report data
28
    ####################################################################################################################
29
    if report is None:
30
        return None
31
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/spaceoutput.py 1 location

@@ 21-60 (lines=40) @@
18
########################################################################################################################
19
20
21
def export(report,
22
           name,
23
           reporting_start_datetime_local,
24
           reporting_end_datetime_local,
25
           period_type):
26
    ####################################################################################################################
27
    # Step 1: Validate the report data
28
    ####################################################################################################################
29
    if report is None:
30
        return None
31
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/combinedequipmentenergyitem.py 1 location

@@ 21-60 (lines=40) @@
18
########################################################################################################################
19
20
21
def export(report,
22
           name,
23
           reporting_start_datetime_local,
24
           reporting_end_datetime_local,
25
           period_type):
26
    ####################################################################################################################
27
    # Step 1: Validate the report data
28
    ####################################################################################################################
29
    if report is None:
30
        return None
31
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/combinedequipmentoutput.py 1 location

@@ 21-60 (lines=40) @@
18
########################################################################################################################
19
20
21
def export(report,
22
           name,
23
           reporting_start_datetime_local,
24
           reporting_end_datetime_local,
25
           period_type):
26
    ####################################################################################################################
27
    # Step 1: Validate the report data
28
    ####################################################################################################################
29
    if report is None:
30
        return None
31
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/spaceenergyitem.py 1 location

@@ 21-60 (lines=40) @@
18
####################################################################################################################
19
20
21
def export(report,
22
           name,
23
           reporting_start_datetime_local,
24
           reporting_end_datetime_local,
25
           period_type):
26
    ####################################################################################################################
27
    # Step 1: Validate the report data
28
    ####################################################################################################################
29
    if report is None:
30
        return None
31
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/spacesaving.py 1 location

@@ 21-60 (lines=40) @@
18
########################################################################################################################
19
20
21
def export(report,
22
           name,
23
           reporting_start_datetime_local,
24
           reporting_end_datetime_local,
25
           period_type):
26
    ####################################################################################################################
27
    # Step 1: Validate the report data
28
    ####################################################################################################################
29
    if report is None:
30
        return None
31
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/spaceefficiency.py 1 location

@@ 21-60 (lines=40) @@
18
########################################################################################################################
19
20
21
def export(report,
22
           name,
23
           reporting_start_datetime_local,
24
           reporting_end_datetime_local,
25
           period_type):
26
    ####################################################################################################################
27
    # Step 1: Validate the report data
28
    ####################################################################################################################
29
    if report is None:
30
        return None
31
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/spaceload.py 1 location

@@ 21-60 (lines=40) @@
18
########################################################################################################################
19
20
21
def export(report,
22
           name,
23
           reporting_start_datetime_local,
24
           reporting_end_datetime_local,
25
           period_type):
26
    ####################################################################################################################
27
    # Step 1: Validate the report data
28
    ####################################################################################################################
29
    if report is None:
30
        return None
31
    print(report)
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report, name, reporting_start_datetime_local, reporting_end_datetime_local, period_type):

myems-api/excelexporters/spacestatistics.py 1 location

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

myems-api/excelexporters/shopfloorcost.py 1 location

@@ 22-60 (lines=39) @@
19
########################################################################################################################
20
21
22
def export(report,
23
           name,
24
           reporting_start_datetime_local,
25
           reporting_end_datetime_local,
26
           period_type):
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/equipmentsaving.py 1 location

@@ 22-60 (lines=39) @@
19
########################################################################################################################
20
21
22
def export(report,
23
           name,
24
           reporting_start_datetime_local,
25
           reporting_end_datetime_local,
26
           period_type):
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/shopfloorsaving.py 1 location

@@ 22-60 (lines=39) @@
19
####################################################################################################################
20
21
22
def export(report,
23
           name,
24
           reporting_start_datetime_local,
25
           reporting_end_datetime_local,
26
           period_type):
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/tenantcost.py 1 location

@@ 22-60 (lines=39) @@
19
########################################################################################################################
20
21
22
def export(report,
23
           name,
24
           reporting_start_datetime_local,
25
           reporting_end_datetime_local,
26
           period_type):
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/tenantsaving.py 1 location

@@ 22-60 (lines=39) @@
19
########################################################################################################################
20
21
22
def export(report,
23
           name,
24
           reporting_start_datetime_local,
25
           reporting_end_datetime_local,
26
           period_type):
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
    ####################################################################################################################
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
        pass
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
        pass
60
    return base64_message
61
62
63
def generate_excel(report,

myems-api/excelexporters/equipmentoutput.py 1 location

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

myems-api/excelexporters/storecost.py 1 location

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

myems-api/excelexporters/tenantload.py 1 location

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

myems-api/excelexporters/combinedequipmentload.py 1 location

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

myems-api/excelexporters/shopfloorload.py 1 location

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

myems-api/excelexporters/equipmentincome.py 1 location

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

myems-api/excelexporters/storesaving.py 1 location

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

myems-api/excelexporters/tenantenergyitem.py 1 location

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

myems-api/excelexporters/combinedequipmentefficiency.py 1 location

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

myems-api/excelexporters/tenantenergycategory.py 1 location

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

myems-api/excelexporters/equipmentefficiency.py 1 location

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

myems-api/excelexporters/equipmentload.py 1 location

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

myems-api/excelexporters/equipmentstatistics.py 1 location

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

myems-api/excelexporters/equipmentenergyitem.py 1 location

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

myems-api/excelexporters/equipmentcost.py 1 location

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

myems-api/excelexporters/storeload.py 1 location

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

myems-api/excelexporters/tenantstatistics.py 1 location

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

myems-api/excelexporters/combinedequipmentenergycategory.py 1 location

@@ 20-58 (lines=39) @@
17
########################################################################################################################
18
19
20
def export(report,
21
           name,
22
           reporting_start_datetime_local,
23
           reporting_end_datetime_local,
24
           period_type):
25
    ####################################################################################################################
26
    # Step 1: Validate the report data
27
    ####################################################################################################################
28
    if report is None:
29
        return None
30
31
    ####################################################################################################################
32
    # Step 2: Generate excel file from the report data
33
    ####################################################################################################################
34
    filename = generate_excel(report,
35
                              name,
36
                              reporting_start_datetime_local,
37
                              reporting_end_datetime_local,
38
                              period_type)
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
        pass
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
        pass
58
    return base64_message
59
60
61
def generate_excel(report,

myems-api/excelexporters/shopfloorenergycategory.py 1 location

@@ 20-58 (lines=39) @@
17
########################################################################################################################
18
19
20
def export(report,
21
           name,
22
           reporting_start_datetime_local,
23
           reporting_end_datetime_local,
24
           period_type):
25
    ####################################################################################################################
26
    # Step 1: Validate the report data
27
    ####################################################################################################################
28
    if report is None:
29
        return None
30
31
    ####################################################################################################################
32
    # Step 2: Generate excel file from the report data
33
    ####################################################################################################################
34
    filename = generate_excel(report,
35
                              name,
36
                              reporting_start_datetime_local,
37
                              reporting_end_datetime_local,
38
                              period_type)
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
        pass
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
        pass
58
    return base64_message
59
60
61
def generate_excel(report,

myems-api/excelexporters/shopfloorstatistics.py 1 location

@@ 20-58 (lines=39) @@
17
########################################################################################################################
18
19
20
def export(report,
21
           name,
22
           reporting_start_datetime_local,
23
           reporting_end_datetime_local,
24
           period_type):
25
    ####################################################################################################################
26
    # Step 1: Validate the report data
27
    ####################################################################################################################
28
    if report is None:
29
        return None
30
31
    ####################################################################################################################
32
    # Step 2: Generate excel file from the report data
33
    ####################################################################################################################
34
    filename = generate_excel(report,
35
                              name,
36
                              reporting_start_datetime_local,
37
                              reporting_end_datetime_local,
38
                              period_type)
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
        pass
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
        pass
58
    return base64_message
59
60
61
def generate_excel(report,

myems-api/excelexporters/storeenergyitem.py 1 location

@@ 20-58 (lines=39) @@
17
########################################################################################################################
18
19
20
def export(report,
21
           name,
22
           reporting_start_datetime_local,
23
           reporting_end_datetime_local,
24
           period_type):
25
    ####################################################################################################################
26
    # Step 1: Validate the report data
27
    ####################################################################################################################
28
    if report is None:
29
        return None
30
31
    ####################################################################################################################
32
    # Step 2: Generate excel file from the report data
33
    ####################################################################################################################
34
    filename = generate_excel(report,
35
                              name,
36
                              reporting_start_datetime_local,
37
                              reporting_end_datetime_local,
38
                              period_type)
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
        pass
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
        pass
58
    return base64_message
59
60
61
def generate_excel(report,

myems-api/excelexporters/shopfloorenergyitem.py 1 location

@@ 20-58 (lines=39) @@
17
########################################################################################################################
18
19
20
def export(report,
21
           name,
22
           reporting_start_datetime_local,
23
           reporting_end_datetime_local,
24
           period_type):
25
    ####################################################################################################################
26
    # Step 1: Validate the report data
27
    ####################################################################################################################
28
    if report is None:
29
        return None
30
31
    ####################################################################################################################
32
    # Step 2: Generate excel file from the report data
33
    ####################################################################################################################
34
    filename = generate_excel(report,
35
                              name,
36
                              reporting_start_datetime_local,
37
                              reporting_end_datetime_local,
38
                              period_type)
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
        pass
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
        pass
58
    return base64_message
59
60
61
def generate_excel(report,

myems-api/excelexporters/storeenergycategory.py 1 location

@@ 20-58 (lines=39) @@
17
########################################################################################################################
18
19
20
def export(report,
21
           name,
22
           reporting_start_datetime_local,
23
           reporting_end_datetime_local,
24
           period_type):
25
    ####################################################################################################################
26
    # Step 1: Validate the report data
27
    ####################################################################################################################
28
    if report is None:
29
        return None
30
31
    ####################################################################################################################
32
    # Step 2: Generate excel file from the report data
33
    ####################################################################################################################
34
    filename = generate_excel(report,
35
                              name,
36
                              reporting_start_datetime_local,
37
                              reporting_end_datetime_local,
38
                              period_type)
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
        pass
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
        pass
58
    return base64_message
59
60
61
def generate_excel(report,

myems-api/excelexporters/tenantbill.py 1 location

@@ 19-57 (lines=39) @@
16
########################################################################################################################
17
18
19
def export(report,
20
           name,
21
           reporting_start_datetime_local,
22
           reporting_end_datetime_local,
23
           period_type):
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
                              period_type)
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
        pass
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
        pass
57
    return base64_message
58
59
60
def generate_excel(report,

myems-api/excelexporters/storestatistics.py 1 location

@@ 19-57 (lines=39) @@
16
########################################################################################################################
17
18
19
def export(report,
20
           name,
21
           reporting_start_datetime_local,
22
           reporting_end_datetime_local,
23
           period_type):
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
                              period_type)
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
        pass
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
        pass
57
    return base64_message
58
59
60
def generate_excel(report,

myems-api/excelexporters/meterenergy.py 1 location

@@ 20-54 (lines=35) @@
17
# Step 3: Encode the excelexporters file to Base64
18
########################################################################################################################
19
20
def export(result, name, reporting_start_datetime_local, reporting_end_datetime_local, period_type):
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
                              name,
32
                              reporting_start_datetime_local,
33
                              reporting_end_datetime_local,
34
                              period_type)
35
    ####################################################################################################################
36
    # Step 3: Encode the excel file to Base64
37
    ####################################################################################################################
38
    binary_file_data = b''
39
    try:
40
        with open(filename, 'rb') as binary_file:
41
            binary_file_data = binary_file.read()
42
    except IOError as ex:
43
        pass
44
45
    # Base64 encode the bytes
46
    base64_encoded_data = base64.b64encode(binary_file_data)
47
    # get the Base64 encoded data using human-readable characters.
48
    base64_message = base64_encoded_data.decode('utf-8')
49
    # delete the file from server
50
    try:
51
        os.remove(filename)
52
    except NotImplementedError as ex:
53
        pass
54
    return base64_message
55
56
57
def generate_excel(report, name, reporting_start_datetime_local, reporting_end_datetime_local, period_type):

myems-api/excelexporters/metersubmetersbalance.py 1 location

@@ 20-54 (lines=35) @@
17
# Step 3: Encode the excelexporters file to Base64
18
########################################################################################################################
19
20
def export(result, name, reporting_start_datetime_local, reporting_end_datetime_local, period_type):
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
                              name,
32
                              reporting_start_datetime_local,
33
                              reporting_end_datetime_local,
34
                              period_type)
35
    ####################################################################################################################
36
    # Step 3: Encode the excel file to Base64
37
    ####################################################################################################################
38
    binary_file_data = b''
39
    try:
40
        with open(filename, 'rb') as binary_file:
41
            binary_file_data = binary_file.read()
42
    except IOError as ex:
43
        pass
44
45
    # Base64 encode the bytes
46
    base64_encoded_data = base64.b64encode(binary_file_data)
47
    # get the Base64 encoded data using human-readable characters.
48
    base64_message = base64_encoded_data.decode('utf-8')
49
    # delete the file from server
50
    try:
51
        os.remove(filename)
52
    except NotImplementedError as ex:
53
        pass
54
    return base64_message
55
56
57
def generate_excel(report, name, reporting_start_datetime_local, reporting_end_datetime_local, period_type):

myems-api/excelexporters/virtualmeterenergy.py 1 location

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

myems-api/excelexporters/offlinemeterenergy.py 1 location

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

myems-api/excelexporters/tenantbatch.py 1 location

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

myems-api/excelexporters/meterbatch.py 1 location

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

myems-api/excelexporters/combinedequipmentbatch.py 1 location

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

myems-api/excelexporters/shopfloorbatch.py 1 location

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

myems-api/excelexporters/metertracking.py 1 location

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

myems-api/excelexporters/equipmentbatch.py 1 location

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

myems-api/excelexporters/storebatch.py 1 location

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

myems-api/excelexporters/equipmenttracking.py 1 location

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

myems-api/excelexporters/equipmentenergycategory.py 1 location

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