Code: Select all
# Basic Information 0.1b
# By Toast 08-11-15
#
# Licensed under LGPL
# http://en.wikipedia.org/wiki/GNU_Lesser_General_Public_License
#
# Prints out Hostname and PID for process
# Simple script (example for DSHub)
#
# Changes 0.1a
# Added support for log (basic_info.log)
# Added working directory, Java/Platform Version and user id to this version
# Added Garbage Collector
#
# Changes 0.1b
# Cleaned up script
# Added License info
import sys, socket, os, sys, platform, gc, time
gc.enable()
hostname = socket.gethostname()
pathname = os.path.dirname(sys.argv[0])
print "Basic Info:","\n","Hostname:", hostname,"\n","Platform:", platform.platform(aliased=1, terse=0),"\n",'Working Directory:', sys.argv[0] ,os.path.abspath(pathname),"\n",'Parent Process ID:', os.getpid(),"\n",'Real User ID:', os.getuid(),"\n\n","Saving to information to basic_info.log"
f = open('basic_info.log', 'w')
print >> f, "Basic Info:","\n\n","Hostname:", hostname,"\n","Platform:", platform.platform(aliased=1, terse=0),"\n",'Working Directory:', sys.argv[0] ,os.path.abspath(pathname),"\n",'Parent Process ID:', os.getpid(),"\n",'Real User ID:', os.getuid()
print >> f, ""
gmt = time.gmtime(time.time())
fmt = '%a, %d %b %Y %H:%M:%S GMT'
str = time.strftime(fmt, gmt)
hdr = str
print >> f, "Log Generated at:", hdr
print All info saved to basic_info.log ..
f.close()