import sys
from librk2.auth import Auth
from librk2.exceptions import LibrkError
from librk2.cr.server import CrServer
from librk2.helpers.ip4finder import IP4Finder
try:
auth = Auth('my program', interactive=True)
server = IP4Finder(auth, "1.1.1.1")
deviceid = CrServer(auth, (server.device_id))
except LibrkError as ex:
print(ex.message)
sys.exit(ex.code)
sys.stdout=open("test.txt","w")
print("Current Machine type: {0}".format(deviceid.os_type))
sys.stdout.close()
After using sys.stdout=open
and sys.stdout.close
, the output is being written to only text file, but not coming on the terminal.
I want the output to be visible on the terminal as well as write to a text file. Consider it like a logging.