add argument for rdpclient script
This commit is contained in:
@@ -22,8 +22,7 @@
|
||||
example of use rdpy as rdp client
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
import sys, os, getopt
|
||||
|
||||
# Change path so we find rdpy
|
||||
sys.path.insert(1, os.path.join(sys.path[0], '..'))
|
||||
@@ -36,12 +35,15 @@ class RDPClientQtFactory(rdp.ClientFactory):
|
||||
"""
|
||||
Factory create a RDP GUI client
|
||||
"""
|
||||
def __init__(self, width, height):
|
||||
def __init__(self, width, height, username, password, domain):
|
||||
"""
|
||||
init client with correct definition
|
||||
"""
|
||||
self._width = width
|
||||
self._height = height
|
||||
self._username = username
|
||||
self._passwod = password
|
||||
self._domain = domain
|
||||
self._w = None
|
||||
|
||||
def buildObserver(self, controller):
|
||||
@@ -59,6 +61,9 @@ class RDPClientQtFactory(rdp.ClientFactory):
|
||||
|
||||
#resize session
|
||||
controller.setScreen(self._width, self._height)
|
||||
controller.setUsername(self._username)
|
||||
controller.setPassword(self._passwod)
|
||||
controller.setDomain(self._domain)
|
||||
controller.setPerformanceSession()
|
||||
|
||||
return client
|
||||
@@ -86,7 +91,46 @@ class RDPClientQtFactory(rdp.ClientFactory):
|
||||
reactor.stop()
|
||||
app.exit()
|
||||
|
||||
def help():
|
||||
print "Usage: rdpy-rdpclient [options] ip[:port]"
|
||||
print "\t-u: user name"
|
||||
print "\t-p: password"
|
||||
print "\t-d: domain"
|
||||
print "\t-w: width of screen default value is 1024"
|
||||
print "\t-l: height of screen default value is 800"
|
||||
|
||||
if __name__ == '__main__':
|
||||
#default script argument
|
||||
username = ""
|
||||
password = ""
|
||||
domain = ""
|
||||
width = 1024
|
||||
height = 800
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:], "hu:p:d:w:l")
|
||||
except getopt.GetoptError:
|
||||
help()
|
||||
for opt, arg in opts:
|
||||
if opt == "-h":
|
||||
help()
|
||||
sys.exit()
|
||||
elif opt == "-u":
|
||||
username = arg
|
||||
elif opt == "-p":
|
||||
password = arg
|
||||
elif opt == "-d":
|
||||
domain = arg
|
||||
elif opt == "-w":
|
||||
width = int(arg)
|
||||
elif opt == "-l":
|
||||
height = int(arg)
|
||||
|
||||
if ':' in args[0]:
|
||||
ip, port = args[0].split(':')
|
||||
else:
|
||||
ip, port = args[0], "3389"
|
||||
|
||||
#create application
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
|
||||
@@ -95,7 +139,7 @@ if __name__ == '__main__':
|
||||
qt4reactor.install()
|
||||
|
||||
from twisted.internet import reactor
|
||||
reactor.connectTCP(sys.argv[1], int(sys.argv[2]), RDPClientQtFactory(1024, 800))
|
||||
reactor.connectTCP(ip, int(port), RDPClientQtFactory(width, height, username, password, domain))
|
||||
reactor.runReturn()
|
||||
app.exec_()
|
||||
reactor.stop()
|
||||
Reference in New Issue
Block a user