Write a string to Status Column A in the remote.it Portal

This is a trivial example showing how to write information to the status columns.  In general you will not be writing a fixed string to the status columns.  Rather, you will read something from the device itself, such as a MAC address or the filtered printout of executing a console command.

The specifics of what information to retrieve and how to filter and present it are left up to the user.

#!/usr/bin/env python
# hello_remote_it.py
# sends 'hello remoteit!' to status column A of device

import os
import sys
import subprocess

#print output to log
sys.stdout = open('pyscriptlog.txt', 'w')
print(sys.argv[1:])

#check connectd package
def check_connectd():
    if(os.path.isfile("/usr/bin/connectd_task_notify") and os.path.isfile("/usr/bin/task_notify.sh")):
        print("target device running both connectd and weavedconnectd")
        return("/usr/bin/connectd_task_notify")

    elif (os.path.isfile("/usr/bin/connectd_task_notify")):
        print("target device running connectd")
        return("/usr/bin/connectd_task_notify")

    elif(os.path.isfile("/usr/bin/task_notify.sh")):
        print("target device running weavedconnectd")
        return("/usr/bin/task_notify.sh")

    else:
        print("target device has neither...how is that possible?")
        exit()

#necessary for utilities
clear = " "
message = "Hello remoteit!"
finalize_job = "Job Complete"
task_id = sys.argv[1]
api = sys.argv[2]
task_notifier = check_connectd()
columns = ['a','b','c','d','e']

#clear status columns
for column in columns:
    subprocess.Popen([task_notifier, column, task_id, api, clear]).wait()

#send message to column A
subprocess.Popen([task_notifier, "a", task_id, api, message]).wait()

#tell connectd job is done
subprocess.Popen([task_notifier, "1", task_id, api, finalize_job]).wait()
/pre>
Was this article helpful?
0 out of 0 found this helpful