Commit 06c3b682 by Őry Máté

remove laborclient

parent d4aef292
include cloud.svg
include cloud.desktop
#!/usr/bin/python
import cloudgui
if __name__ == '__main__':
try:
browser = cloudgui.gui.Browser()
browser.main()
finally:
browser.umount_sshfs_folder()
[Desktop Entry]
Version=0.1
Name=Cloud GUI
Comment=Tool to use IK Cloud
Exec=cloud
Icon=/usr/share/icons/cloud.svg
Terminal=false
Type=Application
Categories=Utility;Application;
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="32px"
height="32px"
id="svg4113"
version="1.1"
inkscape:version="0.48.3.1 r9886"
sodipodi:docname="cloud.svg"
inkscape:export-filename="/home/maat/Munka/IK/cloud/miscellaneous/laborclient/cloudgui/cloud.png"
inkscape:export-xdpi="180"
inkscape:export-ydpi="180">
<defs
id="defs4115">
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3034"
id="radialGradient6745"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.91098464,-0.68941106,-0.52931253,-0.699431,40.047884,602.97172)"
cx="391.42856"
cy="287.43375"
fx="391.42856"
fy="287.43375"
r="145.96571" />
<linearGradient
inkscape:collect="always"
id="linearGradient3034">
<stop
style="stop-color:#aaccee;stop-opacity:1;"
offset="0"
id="stop3036" />
<stop
style="stop-color:#aaccee;stop-opacity:0;"
offset="1"
id="stop3038" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3024"
id="radialGradient6747"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.80253714,-0.60679623,0.29834416,0.39458642,-154.50478,207.30449)"
cx="318.85928"
cy="314.71725"
fx="318.85928"
fy="314.71725"
r="145.96571" />
<linearGradient
inkscape:collect="always"
id="linearGradient3024">
<stop
style="stop-color:#b3defd;stop-opacity:0.5"
offset="0"
id="stop3026" />
<stop
style="stop-color:#b3defd;stop-opacity:0;"
offset="1"
id="stop3028" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3050"
id="radialGradient6749"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.95668304,-0.34646122,0.16844062,0.46511873,-181.17636,116.47568)"
cx="292.64816"
cy="299.75269"
fx="292.64816"
fy="299.75269"
r="145.96571" />
<linearGradient
id="linearGradient3050"
inkscape:collect="always">
<stop
id="stop3052"
offset="0"
style="stop-color:#b3defd;stop-opacity:0.5" />
<stop
id="stop3054"
offset="1"
style="stop-color:#b3defd;stop-opacity:0.7" />
</linearGradient>
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3034"
id="radialGradient7457"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.91098464,-0.68941106,-0.52931253,-0.699431,40.047884,602.97172)"
cx="391.42856"
cy="287.43375"
fx="391.42856"
fy="287.43375"
r="145.96571" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3024"
id="radialGradient7459"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.80253714,-0.60679623,0.29834416,0.39458642,-154.50478,207.30449)"
cx="318.85928"
cy="314.71725"
fx="318.85928"
fy="314.71725"
r="145.96571" />
<radialGradient
inkscape:collect="always"
xlink:href="#linearGradient3050"
id="radialGradient7461"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.95668304,-0.34646122,0.16844062,0.46511873,-181.17636,116.47568)"
cx="292.64816"
cy="299.75269"
fx="292.64816"
fy="299.75269"
r="145.96571" />
<radialGradient
r="145.96571"
fy="299.75269"
fx="292.64816"
cy="299.75269"
cx="292.64816"
gradientTransform="matrix(0.95668304,-0.34646122,0.16844062,0.46511873,-181.17636,116.47568)"
gradientUnits="userSpaceOnUse"
id="radialGradient4111"
xlink:href="#linearGradient3050"
inkscape:collect="always" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="7.9180417"
inkscape:cx="6.6070506"
inkscape:cy="11.63422"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:window-width="950"
inkscape:window-height="1061"
inkscape:window-x="0"
inkscape:window-y="17"
inkscape:window-maximized="0" />
<metadata
id="metadata4118">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<g
id="g6661"
transform="matrix(0.10449644,0,0,0.10449644,-9.9531247,2.8799027)"
inkscape:export-filename="/home/maat/Munka/IK/cloud/miscellaneous/homepage/IK Cloud_files/cloud-migration.png"
inkscape:export-xdpi="61.548325"
inkscape:export-ydpi="61.548325">
<path
style="fill:url(#radialGradient7457);fill-opacity:1;stroke:none"
d="m 256.14524,59.11126 c 24.62625,2.347316 49.86777,32.49978 53.75856,51.16324 8.62329,-27.43498 50.34441,-17.171137 59.85333,-0.71968 6.65814,11.5193 48.45788,5.51236 28.44657,28.00035 24.27442,15.34513 20.8571,65.07012 -42.70377,65.95822 l -176.71875,0 c -42.76196,-1.07615 -51.32274,-8.1926 -57.875,-33.40625 -5.53769,-21.30947 22.49377,-78.5932 62.40625,-64.25 11.6223,-24.03732 44.1151,-49.483183 72.83281,-46.74588 z"
id="path6663"
inkscape:connector-curvature="0"
sodipodi:nodetypes="acscccsca" />
<path
sodipodi:nodetypes="acacccsca"
inkscape:connector-curvature="0"
id="path6665"
d="M 276.48862,56.4684 C 249.95136,55.91176 211.62085,77.96818 207.73006,96.63164 199.10677,69.19666 174.15148,70.8254 157.87673,77.91196 c -18.8365,8.20202 -43.45788,34.51236 -23.44657,57.00036 -24.27442,15.34513 -20.8571,65.07012 42.70377,65.95822 l 176.71875,0 c 42.76196,-1.07615 51.32274,-8.1926 57.875,-33.40625 5.53769,-21.30947 -22.49377,-78.59321 -62.40625,-64.25001 -11.6223,-24.03732 -43.99128,-46.1409 -72.83281,-46.74588 z"
style="fill:url(#radialGradient7459);fill-opacity:1;stroke:none" />
<path
style="fill:url(#radialGradient4111);fill-opacity:1;stroke:none"
d="m 255.98862,62.9684 c -26.53726,-0.55664 -64.86777,21.49978 -68.75856,40.16324 -8.62329,-27.43498 -33.57858,-25.80624 -49.85333,-18.71968 -18.8365,8.20202 -43.45788,34.51236 -23.44657,57.00036 -24.27442,15.34513 -20.8571,65.07012 42.70377,65.95822 l 176.71875,0 c 42.76196,-1.07615 51.32274,-8.1926 57.875,-33.40625 5.53769,-21.30947 -22.49377,-78.59321 -62.40625,-64.25001 -11.6223,-24.03732 -43.99128,-46.1409 -72.83281,-46.74588 z"
id="path6667"
inkscape:connector-curvature="0"
sodipodi:nodetypes="acacccsca" />
</g>
<g
transform="matrix(0.10449644,0,0,0.10449644,-9.9531247,2.8799027)"
id="g7143"
inkscape:export-filename="/home/maat/Munka/IK/cloud/miscellaneous/homepage/IK Cloud_files/cloud-migration.png"
inkscape:export-xdpi="61.548325"
inkscape:export-ydpi="61.548325">
<path
sodipodi:nodetypes="acscccsca"
inkscape:connector-curvature="0"
id="path7145"
d="m 256.14524,59.11126 c 24.62625,2.347316 49.86777,32.49978 53.75856,51.16324 8.62329,-27.43498 50.34441,-17.171137 59.85333,-0.71968 6.65814,11.5193 48.45788,5.51236 28.44657,28.00035 24.27442,15.34513 20.8571,65.07012 -42.70377,65.95822 l -176.71875,0 c -42.76196,-1.07615 -51.32274,-8.1926 -57.875,-33.40625 -5.53769,-21.30947 22.49377,-78.5932 62.40625,-64.25 11.6223,-24.03732 44.1151,-49.483183 72.83281,-46.74588 z"
style="fill:url(#radialGradient6745);fill-opacity:1;stroke:none" />
<path
style="fill:url(#radialGradient6747);fill-opacity:1;stroke:none"
d="M 276.48862,56.4684 C 249.95136,55.91176 211.62085,77.96818 207.73006,96.63164 199.10677,69.19666 174.15148,70.8254 157.87673,77.91196 c -18.8365,8.20202 -43.45788,34.51236 -23.44657,57.00036 -24.27442,15.34513 -20.8571,65.07012 42.70377,65.95822 l 176.71875,0 c 42.76196,-1.07615 51.32274,-8.1926 57.875,-33.40625 5.53769,-21.30947 -22.49377,-78.59321 -62.40625,-64.25001 -11.6223,-24.03732 -43.99128,-46.1409 -72.83281,-46.74588 z"
id="path7147"
inkscape:connector-curvature="0"
sodipodi:nodetypes="acacccsca" />
<path
sodipodi:nodetypes="acacccsca"
inkscape:connector-curvature="0"
id="path7149"
d="m 255.98862,62.9684 c -26.53726,-0.55664 -64.86777,21.49978 -68.75856,40.16324 -8.62329,-27.43498 -33.57858,-25.80624 -49.85333,-18.71968 -18.8365,8.20202 -43.45788,34.51236 -23.44657,57.00036 -24.27442,15.34513 -20.8571,65.07012 42.70377,65.95822 l 176.71875,0 c 42.76196,-1.07615 51.32274,-8.1926 57.875,-33.40625 5.53769,-21.30947 -22.49377,-78.59321 -62.40625,-64.25001 -11.6223,-24.03732 -43.99128,-46.1409 -72.83281,-46.74588 z"
style="fill:url(#radialGradient6749);fill-opacity:1;stroke:none" />
</g>
<path
style="color:#000000;fill:#023397;fill-opacity:1;fill-rule:nonzero;stroke:#013397;stroke-width:0.94207054;stroke-miterlimit:4;stroke-dasharray:none;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 1.5063263,16.860746 C 0.4156576,11.32735 5.5426162,6.5060803 9.4930905,12.794092 12.390583,10.362512 18.261384,5.4751042 21.924479,10.356943 c 4.63917,5.709372 8.828435,2.091553 9.150998,7.200829 1.718965,7.440276 -8.53632,6.237142 -13.058126,7.023742 -5.243812,-0.597269 -11.6068286,1.83668 -16.0931921,-1.584416 -2.83679016,-2.868664 0.4677062,-8.372045 -0.256227,-3.038949 1.6721659,5.015472 8.2408874,3.367343 12.1150121,3.959711 4.986922,-0.85089 11.314427,1.082767 15.334753,-2.286781 2.765266,-4.396332 1.928251,-6.112638 -6.005384,-8.869924 C 20.710434,8.941212 14.735657,9.414075 11.152431,12.552675 6.4967083,13.692321 4.221964,7.4719519 2.0955523,15.655441 l -0.2846878,0.607473 z"
id="path7850"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cccccccccccccc"
inkscape:export-filename="/home/maat/Munka/IK/cloud/miscellaneous/homepage/IK Cloud_files/cloud-migration.png"
inkscape:export-xdpi="61.548325"
inkscape:export-ydpi="61.548325" />
</g>
</svg>
#!/usr/bin/env python
import gtk
import webkit
import gobject
import base64
import os
import sys
import rdp
from multiprocessing import Process
import subprocess
import tempfile
class KeyGen:
"""Attributes:
private_key
public_key
"""
def __init__(self):
self.private_key, self.public_key = self.keygen(2048)
def keygen(self,length=1024):
"""Generate Keypair for SSH
(private_key, public_key)
"""
import os, base64
from datetime import date
from Crypto.PublicKey import RSA
key = RSA.generate(length, os.urandom)
try:
pub = key.exportKey('OpenSSH')
if not pub.startswith("ssh-"):
raise ValueError(pub)
except:
ssh_rsa = '00000007' + base64.b16encode('ssh-rsa')
exponent = '%x' % (key.e, )
if len(exponent) % 2:
exponent = '0' + exponent
ssh_rsa += '%08x' % (len(exponent) / 2, )
ssh_rsa += exponent
modulus = '%x' % (key.n, )
if len(modulus) % 2:
modulus = '0' + modulus
if modulus[0] in '89abcdef':
modulus = '00' + modulus
ssh_rsa += '%08x' % (len(modulus) / 2, )
ssh_rsa += modulus
pub = 'ssh-rsa %s' % (
base64.b64encode(base64.b16decode(ssh_rsa.upper())), )
return key.exportKey(), "%s %s" % (pub, "cloud-%s" % date.today())
class Browser:
version = "0.1"
mounted = False
neptun = ""
host = ""
private_key_file = ""
public_key_b64 = ""
params = {}
def __init__(self):
#Init window components
gobject.threads_init()
self.window = gtk.Window(type=gtk.WINDOW_TOPLEVEL)
#Register window events
self.window.connect("destroy", self.destroy)
#DEBUG
self.window.set_decorated(True)
self.window.set_title("IK CloudStore Login")
self.window.set_default_size(1024,600)
self.window.set_position(gtk.WIN_POS_CENTER)
#Init browser
self.webview = webkit.WebView()
self.webview.connect('onload-event', self.load_committed_cb)
self.webview.open("https://cloud.ik.bme.hu/store/gui/")
self.webview.connect("navigation-requested", self.on_navigation_requested)
settings = webkit.WebSettings()
settings.set_property('user-agent', settings.get_property('user-agent')+' cloud-gui '+self.version)
settings.set_property('enable-accelerated-compositing', True)
settings.set_property("enable-default-context-menu", False)
self.webview.set_settings(settings)
#Connect things
self.scrolledwindow = gtk.ScrolledWindow()
self.scrolledwindow.add(self.webview)
self.window.add(self.scrolledwindow)
self.window.maximize()
self.window.show_all()
def init_keypair(self):
keygen = KeyGen()
private_key = keygen.private_key
public_key = keygen.public_key
#Saver private_key to KEY_FILE
with tempfile.NamedTemporaryFile(mode='w', delete=False) as f:
f.write(private_key)
self.private_key_file = f.name
self.public_key_b64 = base64.b64encode(public_key)
def destroy(self, dummy):
try:
os.unlink(self.private_key_file)
except:
pass
try:
self.umount_sshfs_folder()
except:
pass
gtk.main_quit()
def on_navigation_requested(self, view, frame, req, data=None):
uri = req.get_uri()
if uri == "https://login.bme.hu/admin/":
gobject.threads_init()
window = gtk.Window(type=gtk.WINDOW_TOPLEVEL)
browser = webkit.WebView()
browser.open(uri)
window.add(browser)
window.show_all()
return True
elif uri == "https://cloud.ik.bme.hu/logout/":
self.umount_sshfs_folder()
try:
scheme, rest = uri.split(":", 1)
if scheme == "nx" or scheme == "rdp" or scheme == "sshterm":
subprocess.Popen(["/usr/local/bin/rdp",uri])
return True
elif scheme == "cloudfile":
file_path = os.path.normpath(rest)
subprocess.call(["xdg-open","file://"+self.folder+file_path])
return True
else:
return False
except:
False
def mount_sshfs_folder(self):
self.folder = os.path.expanduser("~/sshfs")
neptun = self.params["neptun"]
host = self.params["host"]
try:
os.makedirs(self.folder)
except:
pass
result = subprocess.call(['/usr/bin/sshfs', '-o', 'IdentityFile='+self.private_key_file+',StrictHostKeyChecking=no', neptun+"@"+host+":home", self.folder])
#print result
def umount_sshfs_folder(self):
try:
result = subprocess.call(['/bin/fusermount', '-u', self.folder])
except:
pass
def post_key(self,key = None):
if key != None:
js = '''
$.post("/store/gui/", { "KEY" : "%(key)s" },
function (respond) {
window.location = respond;
}
)
.error(function (respond) { alert(JSON.stringify(respond)); });
''' % { "key" : key }
else:
js = '''
$.post("/store/gui/", "",
function (respond) {
window.alert(respond);
}
)
.error(function (respond) { alert(JSON.stringify(respond)); });
'''
self.webview.execute_script(js)
def load_committed_cb(self,web_view, frame):
uri = frame.get_uri()
#print uri
try:
self.webview.execute_script('document.getElementsByTagName("a")[0].target="";')
except:
pass
### Send keys via JavaScript ###
if uri == "https://cloud.ik.bme.hu/store/gui/":
self.init_keypair()
### JS
self.post_key(self.public_key_b64)
### Parse values and do mounting ###
elif uri.startswith("https://cloud.ik.bme.hu/home/?"):
if self.mounted != True:
try:
uri, params = uri.split('?', 1)
values = params.split('&')
for p in values:
key, value = p.split('=',1)
self.params[key] = value
try:
self.mount_sshfs_folder()
except Exception as e:
print e
self.mounted = True
except:
pass
finally:
os.unlink(self.private_key_file)
return True
def main(self):
gtk.main()
if __name__ == "__main__":
browser = Browser()
browser.main()
#!/usr/bin/python
import sys
import random
import re
from xml.sax.saxutils import escape
class NXKeyGen:
numValidCharList = 85
dummyString = "{{{{"
def __init__(self, password):
self.password = password
def getEncrypted(self):
return self.scrambleString(self.password)
def getvalidCharList(self, pos):
validcharlist = [
"!", "#", "$", "%", "&", "(", ")", "*", "+", "-",
".", "0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", ":", ";", "<", ">", "?", "@", "A", "B", "C",
"D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
"X", "Y", "Z", "[", "]", "_", "a", "b", "c", "d",
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
"y", "z", "{", "|", "}"
]
return validcharlist[pos]
def encodePassword(self, p):
sPass = ":"
sTmp = ""
if not p:
return ""
for i in range(len(p)):
c = p[i:i+1]
a = ord(c)
sTmp = str( a + i + 1) + ":"
sPass += sTmp
sTmp = ""
return sPass
def findCharInList(self, c):
i = -1
for j in range(self.numValidCharList):
randchar = self.getvalidCharList(j);
if randchar == c:
i = j
return i
return i
def getRandomValidCharFromList(self):
return self.getvalidCharList(random.randint(0,60))
#return self.getvalidCharList(0)
def scrambleString(self, s):
sRet = ""
if not s:
return s
strp = self.encodePassword(s)
if len(strp) < 32:
sRet += self.dummyString
#print "Added dummy "+sRet
for iR in reversed(range(len(strp))):
sRet += strp[iR:iR+1]
#print "Reverse: "+sRet
if len(sRet) < 32:
sRet += self.dummyString
#print "Added dummy2 "+sRet
app = self.getRandomValidCharFromList()
#print "Random valid char: "+app
k = ord(app)
l = k + len(sRet) - 2
sRet = app + sRet
#print "Random "+sRet+"\n"
for i1 in range(1, len(sRet)):
app2 = sRet[i1 : i1 + 1]
#print "For cycle app2= "+str(app2)
j = self.findCharInList(app2)
#print "For cycle j= "+str(j)
if j == -1:
return sRet
i = (j + l * (i1 + 1)) % self.numValidCharList
#print "For cycle i= "+str(i)
car = self.getvalidCharList(i)
sRet = self.substr_replace(sRet,car,i1,1)
#print "For cycle sRet: "+sRet+"\n"
c = (ord(self.getRandomValidCharFromList())) + 2
c2 = chr(c)
sRet = sRet + c2
return escape(sRet)
def substr_replace(self,in_str,ch,pos,qt):
clist = list(in_str)
count = 0;
tmp_str = '';
for key in clist:
if count != pos:
tmp_str += key
else:
tmp_str += ch
count = count+1
return tmp_str
if __name__ == "__main__":
NXPass = NXKeyGen(sys.argv[1])
print NXPass.password
print NXPass.getEncrypted()
#!/usr/bin/python
import nxkey
import tempfile
import subprocess
import os
import sys
import gtk
import gobject
from multiprocessing import Manager, Process
import threading
import signal
import time
class RDP:
def __init__(self, uri):
gobject.threads_init()
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):
# Window = gtk.Window()
# Window.set_size_request(250, 100)
# Window.set_position(gtk.WIN_POS_CENTER)
# Window.connect("destroy", gtk.main_quit)
# window.set_title("Message dialogs")
md = gtk.MessageDialog(parent=None, type=gtk.MESSAGE_INFO, buttons=gtk.BUTTONS_CLOSE, message_format=text)
md.run()
print "After run"
md.destroy()
def connect(self):
#rdp:cloud:qYSv3eQJYY:152.66.243.62:23037
if self.scheme == "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)
#print "Join"
p.join()
elif self.scheme == "nx":
self.connect_nx()
elif self.scheme == "sshterm":
self.connect_sshterm()
else:
return False
def get_temporary_file(self):
tmpfile = tempfile.NamedTemporaryFile(mode='w', delete=False)
if not "_" in tmpfile.name:
return tmpfile
else:
tmpfile.close()
os.unlink(tmpfile.name)
return self.get_temporary_file()
def connect_sshterm(self):
try:
ssh_subcommand = 'sshpass -p "%(password)s" ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null %(username)s@%(host)s -p%(port)s' \
% {'username' : self.username, 'password' : self.password, 'host' : self.host, 'port' : self.port}
ssh_command = ["gnome-terminal", "-e", ssh_subcommand]
proc = subprocess.check_call(ssh_command, stdout = subprocess.PIPE)
except:
self.dialog_box("Unable to connect to host: "+self.host+" at port "+self.port)
def connect_rdp(self,global_vars):
rdp_command = ["rdesktop", "-khu", "-E", "-P", "-0", "-f", "-u", self.username, "-p", self.password, self.host+":"+self.port]
proc = subprocess.Popen(rdp_command, stdout = subprocess.PIPE)
global_vars.pid = proc.pid
proc.wait()
self.box.response(-5)
global_vars.pid = 0
def connect_nx(self):
#Generate temproary config
password_enc = nxkey.NXKeyGen(self.password).getEncrypted()
tmpfile = self.get_temporary_file()
nx_config = """
<!DOCTYPE NXClientSettings>
<NXClientSettings application="nxclient" version="1.3" >
<group name="Advanced" >
<option key="Cache size" value="16" />
<option key="Cache size on disk" value="64" />
<option key="Current keyboard" value="true" />
<option key="Custom keyboard layout" value="" />
<option key="Disable DirectDraw" value="false" />
<option key="Disable ZLIB stream compression" value="false" />
<option key="Disable deferred updates" value="false" />
<option key="Enable HTTP proxy" value="false" />
<option key="Enable SSL encryption" value="true" />
<option key="Enable response time optimisations" value="false" />
<option key="Grab keyboard" value="false" />
<option key="HTTP proxy host" value="" />
<option key="HTTP proxy port" value="8080" />
<option key="HTTP proxy username" value="" />
<option key="Remember HTTP proxy password" value="false" />
<option key="Restore cache" value="true" />
<option key="StreamCompression" value="" />
</group>
<group name="Environment" >
<option key="CUPSD path" value="/usr/sbin/cupsd" />
</group>
<group name="General" >
<option key="Automatic reconnect" value="true" />
<option key="Command line" value="" />
<option key="Custom Unix Desktop" value="console" />
<option key="Desktop" value="gnome" />
<option key="Disable SHM" value="false" />
<option key="Disable emulate shared pixmaps" value="false" />
<option key="Link speed" value="lan" />
<option key="Remember password" value="true" />
<option key="Resolution" value="fullscreen" />
<option key="Resolution height" value="600" />
<option key="Resolution width" value="800" />
<option key="Server host" value="%(host)s" />
<option key="Server port" value="%(port)s" />
<option key="Session" value="unix" />
<option key="Spread over monitors" value="false" />
<option key="Use default image encoding" value="0" />
<option key="Use render" value="true" />
<option key="Use taint" value="true" />
<option key="Virtual desktop" value="false" />
<option key="XAgent encoding" value="true" />
<option key="displaySaveOnExit" value="true" />
<option key="xdm broadcast port" value="177" />
<option key="xdm list host" value="localhost" />
<option key="xdm list port" value="177" />
<option key="xdm mode" value="server decide" />
<option key="xdm query host" value="localhost" />
<option key="xdm query port" value="177" />
</group>
<group name="Images" >
<option key="Disable JPEG Compression" value="0" />
<option key="Disable all image optimisations" value="false" />
<option key="Disable backingstore" value="false" />
<option key="Disable composite" value="false" />
<option key="Image Compression Type" value="3" />
<option key="Image Encoding Type" value="0" />
<option key="Image JPEG Encoding" value="false" />
<option key="JPEG Quality" value="6" />
<option key="RDP Image Encoding" value="3" />
<option key="RDP JPEG Quality" value="6" />
<option key="RDP optimization for low-bandwidth link" value="false" />
<option key="Reduce colors to" value="" />
<option key="Use PNG Compression" value="true" />
<option key="VNC JPEG Quality" value="6" />
<option key="VNC images compression" value="3" />
</group>
<group name="Login" >
<option key="Auth" value="%(password)s" />
<option key="Guest Mode" value="false" />
<option key="Guest password" value="" />
<option key="Guest username" value="" />
<option key="Login Method" value="nx" />
<option key="User" value="%(username)s" />
</group>
<group name="Services" >
<option key="Audio" value="false" />
<option key="IPPPort" value="631" />
<option key="IPPPrinting" value="false" />
<option key="Shares" value="false" />
</group>
<group name="VNC Session" >
<option key="Display" value="0" />
<option key="Remember" value="false" />
<option key="Server" value="" />
</group>
<group name="Windows Session" >
<option key="Application" value="" />
<option key="Authentication" value="2" />
<option key="Color Depth" value="8" />
<option key="Domain" value="" />
<option key="Image Cache" value="true" />
<option key="Password" value="EMPTY_PASSWORD" />
<option key="Remember" value="true" />
<option key="Run application" value="false" />
<option key="Server" value="" />
<option key="User" value="" />
</group>
<group name="share chosen" >
<option key="Share number" value="0" />
</group>
</NXClientSettings>
""" % {'username' : self.username, 'password' : password_enc, 'host' : self.host, 'port' : self.port}
tmpfile.write(nx_config)
tmpfile.close()
try:
subprocess.check_call(["/usr/NX/bin/nxclient", "--session", tmpfile.name])
except:
pass
os.unlink(tmpfile.name)
return
if __name__ == "__main__":
uri = sys.argv[1]
connection = RDP(uri)
connection.connect()
#!/usr/bin/python
import sys
import cloudgui
if __name__ == '__main__':
try:
uri = sys.argv[1]
except:
print "No URI presented!"
sys.exit()
rdp = cloudgui.rdp.RDP(uri)
rdp.connect()
from setuptools import setup, find_packages
setup(
name = "CloudGUI",
version = "0.3",
data_files = [('/usr/share/icons', ['cloud.svg']),
('/usr/share/applications', ['cloud.desktop'])],
include_package_data = True,
packages = ['cloudgui',],
scripts = ['cloud','rdp',],
)
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