IoTReady / aws_iot_demo

Expected 2 blank lines FLK-E302
Style
Minor
13 occurrences in this check
expected 2 blank lines, found 1
 3import os
 4import psutil
 5
 6def get_cpu_usage_pct(): 7    """
 8    Obtains the system's average CPU load as measured over a period of 500 milliseconds.
 9    :returns: System CPU load as a percentage.
expected 2 blank lines, found 1
11    """
12    return psutil.cpu_percent(interval=0.5)
13
14def get_cpu_frequency():15    """
16    Obtains the real-time value of the current CPU frequency.
17    :returns: Current CPU frequency in MHz.
expected 2 blank lines, found 1
39    # Give the result back to the caller.
40    return result
41
42def get_ram_usage():43    """
44    Obtains the absolute number of RAM bytes currently in use by the system.
45    :returns: System RAM usage in bytes.
expected 2 blank lines, found 1
47    """
48    return int(psutil.virtual_memory().total - psutil.virtual_memory().available)
49
50def get_ram_total():51    """
52    Obtains the total amount of RAM in bytes available to the system.
53    :returns: Total system RAM in bytes.
expected 2 blank lines, found 1
19    """
20    return int(psutil.cpu_freq().current)
21
22def get_cpu_temp():23    """
24    Obtains the current value of the CPU temperature.
25    :returns: Current value of the CPU temperature if successful, zero value otherwise.
expected 2 blank lines, found 1
50    }
51    return metrics
52
53def main(handler):54    """ Gets system metrics and updates the device shadow suing the aws_shadow_updater helper library.
55    """
56    payload = get_metrics()
expected 2 blank lines, found 1
34    }
35    return aws_iot.init_device_shadow_handler(aws_iot_config)
36
37def get_metrics():38    """
39    Groups the metrics together into an object that we can print to the terminal and/or 
40    send to AWS IoT.
expected 2 blank lines, found 1
17    assert os.path.exists(device_private_key), "Device Private Key not found"
18    return root_ca_cert, device_cert, device_private_key
19
20def get_shadow_handler(device_id):21    """
22    Given a device_id, creates a configuration for connecting to AWS IoT, creates and returns a device_shadow_handler.
23    """
expected 2 blank lines, found 1
 7import sysmon
 8import aws_shadow_updater as aws_iot
 9
10def get_aws_iot_certs(device_id):11    certs_dir = os.getenv('CERTS_DIR')
12    root_ca_cert = os.path.join(certs_dir, "AmazonRootCA1.pem") # Adjust per your Root CA settings
13    device_cert = os.path.join(certs_dir, "{}-certificate.pem.crt".format(device_id))
expected 2 blank lines, found 1
86
87    return deviceShadowHandler
88
89def update_device_shadow(handler, payload):90    json_payload = json.dumps({
91        "state": {
92            "reported": payload
expected 2 blank lines, found 1
32    if responseStatus == "rejected":
33        print("Delete request " + token + " rejected!")
34
35def init_device_shadow_handler(args):36    host = args.get("host")
37    rootCAPath = args.get("rootCAPath")
38    certificatePath = args.get("certificatePath")
expected 2 blank lines, found 1
22    if responseStatus == "rejected":
23        print("Update request " + token + " rejected!")
24
25def shadow_delete_callback(payload, responseStatus, token):26    if responseStatus == "timeout":
27        print("Delete request " + token + " time out!")
28    if responseStatus == "accepted":
expected 2 blank lines, found 1
13# }
14
15# Custom Shadow callback
16def shadow_update_callback(payload, responseStatus, token):17    if responseStatus == "timeout":
18        print("Update request " + token + " time out!")
19    if responseStatus == "accepted":