Commit 6d78f082 by tarokkk

laborgui: Added rdp waiting screen.

parent a34e071a
...@@ -6,11 +6,19 @@ import os ...@@ -6,11 +6,19 @@ import os
import sys import sys
import gtk import gtk
import gobject import gobject
from multiprocessing import Manager, Process
import threading
import signal
import time
class RDP: class RDP:
def __init__(self, uri): def __init__(self, uri):
gobject.threads_init() gobject.threads_init()
self.scheme, self.username, self.password, self.host, self.port = uri.split(':',4) self.scheme, self.username, self.password, self.host, self.port = uri.split(':',4)
self.manager = Manager()
self.global_vars = self.manager.Namespace()
self.global_vars.pid = 0
self.box = gtk.MessageDialog(parent=None, flags=gtk.DIALOG_MODAL, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_CANCEL, message_format="Connecting to RDP...")
def dialog_box(self,text): def dialog_box(self,text):
# Window = gtk.Window() # Window = gtk.Window()
# Window.set_size_request(250, 100) # Window.set_size_request(250, 100)
...@@ -24,7 +32,20 @@ class RDP: ...@@ -24,7 +32,20 @@ class RDP:
def connect(self): def connect(self):
#rdp:cloud:qYSv3eQJYY:152.66.243.62:23037 #rdp:cloud:qYSv3eQJYY:152.66.243.62:23037
if self.scheme == "rdp": if self.scheme == "rdp":
self.connect_rdp() #print self.global_vars.pid
p = threading.Thread(target=self.connect_rdp, args=[self.global_vars])
p.start()
while self.global_vars.pid == 0:
time.sleep(1)
#print "Rdesktop pid: "+str(self.global_vars.pid)
#print self.box
return_value = self.box.run()
#print "Box return value: "+str(return_value)
if return_value != -5:
#p.terminate()
if self.global_vars.pid > 0:
os.kill(self.global_vars.pid, signal.SIGKILL)
p.join()
elif self.scheme == "nx": elif self.scheme == "nx":
self.connect_nx() self.connect_nx()
elif self.scheme == "sshterm": elif self.scheme == "sshterm":
...@@ -49,15 +70,21 @@ class RDP: ...@@ -49,15 +70,21 @@ class RDP:
except: except:
self.dialog_box("Unable to connect to host: "+self.host+" at port "+self.port) self.dialog_box("Unable to connect to host: "+self.host+" at port "+self.port)
def connect_rdp(self): def connect_rdp(self,global_vars):
rdp_command = ["rdesktop", "-khu", "-E", "-P", "-0", "-f", "-u", self.username, "-p", self.password, self.host+":"+self.port] rdp_command = ["rdesktop", "-khu", "-E", "-P", "-0", "-f", "-u", self.username, "-p", self.password, self.host+":"+self.port]
try: try:
proc = subprocess.check_call(rdp_command, stdout = subprocess.PIPE) proc = subprocess.Popen(rdp_command, stdout = subprocess.PIPE)
global_vars.pid = proc.pid
proc.wait()
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as e:
if e.returncode != 1: if e.returncode != 1:
print e print e
print e.returncode
self.dialog_box("Unable to connect to host: "+self.host+" at port "+self.port) self.dialog_box("Unable to connect to host: "+self.host+" at port "+self.port)
finally:
#print "Finally: "
#print self.box
global_vars.pid = 0
self.box.response(-5)
def connect_nx(self): def connect_nx(self):
#Generate temproary config #Generate temproary config
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment