Automated test system I am creating an automated test system (scope bloat - the original intent was a one-off bash automation of a particular test case that has turned into creating a system that will do many other things). I've done a few things similar to this, but somehow never got to using classes; everything was down at the functions level in modules I wrote for past projects.

I'm looking for a simple check/confirmation that I'm approaching this right. It's a communications module intended to connect via telnet to a remote Linux machine, then pull various I2C reads from a device that the Linux machine is connected to. 

I want to make sure that I am creating this correctly correctly, and declaring objects correctly so the functions/methods in the class object will perform their individual tasks correctly. I think I'm on the right track but having people a little more experienced take a look couldn't hurt. In particular, I want to make sure I'm setting the class up for instantiation correctly, and declaring self/__init__ in the right way.

Note: the code here worked reasonably well when it was separate functions not gathered under a unifying class structure, but I was mucking about with global declarations which made me nervous, and it took more tweaking than I was happy with.

class Communications: #logs in to the remote as root.
    def __init__(self):
        self.term = telnetlib.open('10.100.100.103')
        print ('logging in now')
        term.read_until(b"ogin: ")
        term.write('root\n')
        time.sleep(3)
        term.read_very_eager()

    #device power-up and power-down
    def node_startup(node):
        if node == 1:
            node_command = 'node_on 1\n'
        elif node == 2:
            node_command = 'node_on 2\n'
        term.write(node_command)
        print (b'powering node', node, 'on\n')

    def node_shutdown(node):
        if node == 1:
            node_command = 'node_off 1\n'
        elif node == 2:
            node_command = 'node_off 2\n'
        term.write(node_command)
        print (b'shutting node', node, ' down')

    #device sample retrieval
    def get_voltage_i2c(bus, device, datapoint, test, node):
        i2c_sample =  term.write('i2cget -y -f %d %d 0x 8b w &gt;&gt; /tmp/%s_%d.txt\n' %(bus, device, test, node))

    def get_current_i2c(bus, device, datapoint, test, node):
        i2c_sample =  term.write('i2cget -y -f %d %d %d %s %d w &gt;&gt; /tmp/%s_%d.txt\n' %(bus, device, datapoint, test, node))


    def get_power_i2c(bus, device, datapoint, test, node):
        i2c_sample =  term.write('i2cget -y -f %d %d %d %s %d w &gt;&gt; /tmp/%s_%d.txt\n' %(bus, device, datapoint, test, node))

    #output-scraper to slurp results from the output files the i2cgets write to. (devnote: incomplete at time of posting)
    def get_sample_results():
        time.sleep(30)
        term.read_very_eager()
        term.write(b'cat ')
First thing I noticed is you don't seem to be checking if your commands are executed. There's no Exception handling to be found.

Second, avoid the use of magic numbers.

telnetlib.open('10.100.100.103') should be telnetlib.open(TARGET_IP)

time.sleep(3) should be time.sleep(SLEEP_INIT)

Etcetera. Ofcourse, those variables should be declared on the top of your file. Although Python does not support constant by default, there's a workaround if you're interested.