Exemple #1
0
 def parseDisplay(self):
     """
     read xauth and get IP addr using xlib python bindings
     """
     a=xauth.Xauthority()
     entries=a.entries
     lines=[]
     for entry in entries:
         ipv4=str(shared.parseIPAddress(entry[1], return_ipv4=True))
         if ipv4 is None:
             ipv4=entry[1]
         cookie=self.parseCookie(entry[4])
         print_debug("parseDisplay() ip=%s cookie=%s"%(ipv4, cookie))
         lines.append([ipv4, cookie])
     return lines
except getopt.error, msg:
    print msg
    print "for command line options use tcos-dbus-client --help"
    sys.exit(2)



for o, a in opts:
    if o in ("-d", "--debug"):
        print "DEBUG ACTIVE"
        shared.debug = True
    if o == "--only-local":
        shared.allow_local_display=True


host =  str(shared.parseIPAddress(os.environ["DISPLAY"]))
if host == "" and not shared.allow_local_display:
	print "tcos-dbus-client: Not allowed to run in local DISPLAY"
	sys.exit(0)
	
if host != "" and shared.allow_local_display:
	print "tcos-dbus-client: Not allowed to run in remote DISPLAY: \"%s\"" %(host)
	sys.exit(0)
	
from tcosmonitor.TcosDBus import TcosDBusServer
try:
    server=TcosDBusServer().start()
except KeyboardInterrupt:
    print_debug("Ctrl+C exiting...")
    sys.exit(0)