Sending an uptime to a remote server through SSH with the method pxssh
It sounds like the problem is not the code but how to package it up in a such a way that only functions that you want to call get called when you want to call them.

A part of the solution is as you have defined it ...

if __name__ == '__main__':
    conn_up()


... this would ensure that conn_up() gets called, but you could just treat conn_up as a constructor and pull all the code from it and put it in another function which you then call on demand.

From further discussion with you on discord it seems that the issue is also in part about extending this in the future so I would advise packaging this up in to a class that you might add functions to, then can add to your "if __name__ == '__main__':" block additional functions as you add them, or through some other logic in a new "onStart()" function or something.

There's a great post on this here ...

Hope this helps.