forked from shaba/openuds
adding more notes for mac os x
This commit is contained in:
parent
f173146d8f
commit
2480a79450
@ -5,7 +5,7 @@
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>udsclient</string>
|
||||
<string>UDSClient</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
@ -24,11 +24,11 @@
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>PythonApplet.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.openuds.udsclient</string>
|
||||
<string>org.openuds.UDSClient</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>udsclient</string>
|
||||
<string>UDSClient</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
|
6
client/notes/macosx/UDSResources.qrc
Normal file
6
client/notes/macosx/UDSResources.qrc
Normal file
@ -0,0 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="images">
|
||||
<file alias="logo-uds-small">images/logo-uds-small.png</file>
|
||||
<file alias="logo-uds-big">images/logo-uds.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
2471
client/notes/macosx/UDSResources_rc.py
Normal file
2471
client/notes/macosx/UDSResources_rc.py
Normal file
File diff suppressed because it is too large
Load Diff
105
client/notes/macosx/UDSWindow.py
Normal file
105
client/notes/macosx/UDSWindow.py
Normal file
@ -0,0 +1,105 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Form implementation generated from reading ui file 'UDSWindow.ui'
|
||||
#
|
||||
# Created: Mon Mar 30 08:55:29 2015
|
||||
# by: PyQt4 UI code generator 4.11.2
|
||||
#
|
||||
# WARNING! All changes made in this file will be lost!
|
||||
|
||||
from PyQt4 import QtCore, QtGui
|
||||
|
||||
try:
|
||||
_fromUtf8 = QtCore.QString.fromUtf8
|
||||
except AttributeError:
|
||||
def _fromUtf8(s):
|
||||
return s
|
||||
|
||||
try:
|
||||
_encoding = QtGui.QApplication.UnicodeUTF8
|
||||
def _translate(context, text, disambig):
|
||||
return QtGui.QApplication.translate(context, text, disambig, _encoding)
|
||||
except AttributeError:
|
||||
def _translate(context, text, disambig):
|
||||
return QtGui.QApplication.translate(context, text, disambig)
|
||||
|
||||
class Ui_MainWindow(object):
|
||||
def setupUi(self, MainWindow):
|
||||
MainWindow.setObjectName(_fromUtf8("MainWindow"))
|
||||
MainWindow.setWindowModality(QtCore.Qt.NonModal)
|
||||
MainWindow.resize(259, 185)
|
||||
MainWindow.setCursor(QtGui.QCursor(QtCore.Qt.BusyCursor))
|
||||
icon = QtGui.QIcon()
|
||||
icon.addPixmap(QtGui.QPixmap(_fromUtf8(":/images/logo-uds-small")), QtGui.QIcon.Normal, QtGui.QIcon.Off)
|
||||
MainWindow.setWindowIcon(icon)
|
||||
MainWindow.setWindowOpacity(1.0)
|
||||
self.centralwidget = QtGui.QWidget(MainWindow)
|
||||
self.centralwidget.setAutoFillBackground(True)
|
||||
self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
|
||||
self.verticalLayout_2 = QtGui.QVBoxLayout(self.centralwidget)
|
||||
self.verticalLayout_2.setSpacing(4)
|
||||
self.verticalLayout_2.setMargin(4)
|
||||
self.verticalLayout_2.setObjectName(_fromUtf8("verticalLayout_2"))
|
||||
self.frame = QtGui.QFrame(self.centralwidget)
|
||||
self.frame.setFrameShape(QtGui.QFrame.StyledPanel)
|
||||
self.frame.setFrameShadow(QtGui.QFrame.Raised)
|
||||
self.frame.setObjectName(_fromUtf8("frame"))
|
||||
self.verticalLayout_3 = QtGui.QVBoxLayout(self.frame)
|
||||
self.verticalLayout_3.setSpacing(4)
|
||||
self.verticalLayout_3.setMargin(4)
|
||||
self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
|
||||
self.verticalLayout = QtGui.QVBoxLayout()
|
||||
self.verticalLayout.setObjectName(_fromUtf8("verticalLayout"))
|
||||
self.image = QtGui.QLabel(self.frame)
|
||||
self.image.setMinimumSize(QtCore.QSize(0, 24))
|
||||
self.image.setAutoFillBackground(True)
|
||||
self.image.setText(_fromUtf8(""))
|
||||
self.image.setPixmap(QtGui.QPixmap(_fromUtf8(":/images/logo-uds-small")))
|
||||
self.image.setScaledContents(False)
|
||||
self.image.setAlignment(QtCore.Qt.AlignCenter)
|
||||
self.image.setObjectName(_fromUtf8("image"))
|
||||
self.verticalLayout.addWidget(self.image)
|
||||
self.info = QtGui.QLabel(self.frame)
|
||||
self.info.setMaximumSize(QtCore.QSize(16777215, 16))
|
||||
self.info.setObjectName(_fromUtf8("info"))
|
||||
self.verticalLayout.addWidget(self.info)
|
||||
self.progressBar = QtGui.QProgressBar(self.frame)
|
||||
self.progressBar.setProperty("value", 24)
|
||||
self.progressBar.setTextVisible(False)
|
||||
self.progressBar.setObjectName(_fromUtf8("progressBar"))
|
||||
self.verticalLayout.addWidget(self.progressBar)
|
||||
self.horizontalLayout = QtGui.QHBoxLayout()
|
||||
self.horizontalLayout.setObjectName(_fromUtf8("horizontalLayout"))
|
||||
spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.horizontalLayout.addItem(spacerItem)
|
||||
self.cancelButton = QtGui.QPushButton(self.frame)
|
||||
self.cancelButton.setDefault(True)
|
||||
self.cancelButton.setFlat(False)
|
||||
self.cancelButton.setObjectName(_fromUtf8("cancelButton"))
|
||||
self.horizontalLayout.addWidget(self.cancelButton)
|
||||
spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
|
||||
self.horizontalLayout.addItem(spacerItem1)
|
||||
self.verticalLayout.addLayout(self.horizontalLayout)
|
||||
self.verticalLayout_3.addLayout(self.verticalLayout)
|
||||
self.verticalLayout_2.addWidget(self.frame)
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
|
||||
self.retranslateUi(MainWindow)
|
||||
QtCore.QMetaObject.connectSlotsByName(MainWindow)
|
||||
|
||||
def retranslateUi(self, MainWindow):
|
||||
MainWindow.setWindowTitle(_translate("MainWindow", "UDS Connection", None))
|
||||
self.info.setText(_translate("MainWindow", "TextLabel", None))
|
||||
self.cancelButton.setText(_translate("MainWindow", "Cancel", None))
|
||||
|
||||
import UDSResources_rc
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
MainWindow = QtGui.QMainWindow()
|
||||
ui = Ui_MainWindow()
|
||||
ui.setupUi(MainWindow)
|
||||
MainWindow.show()
|
||||
sys.exit(app.exec_())
|
||||
|
160
client/notes/macosx/UDSWindow.ui
Normal file
160
client/notes/macosx/UDSWindow.ui
Normal file
@ -0,0 +1,160 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>MainWindow</class>
|
||||
<widget class="QMainWindow" name="MainWindow">
|
||||
<property name="windowModality">
|
||||
<enum>Qt::NonModal</enum>
|
||||
</property>
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>259</width>
|
||||
<height>185</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="cursor">
|
||||
<cursorShape>BusyCursor</cursorShape>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>UDS Connection</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="UDSResources.qrc">
|
||||
<normaloff>:/images/logo-uds-small</normaloff>:/images/logo-uds-small</iconset>
|
||||
</property>
|
||||
<property name="windowOpacity">
|
||||
<double>1.000000000000000</double>
|
||||
</property>
|
||||
<widget class="QWidget" name="centralwidget">
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QFrame" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="image">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>24</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="pixmap">
|
||||
<pixmap resource="UDSResources.qrc">:/images/logo-uds-small</pixmap>
|
||||
</property>
|
||||
<property name="scaledContents">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="info">
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16777215</width>
|
||||
<height>16</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="value">
|
||||
<number>24</number>
|
||||
</property>
|
||||
<property name="textVisible">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="cancelButton">
|
||||
<property name="text">
|
||||
<string>Cancel</string>
|
||||
</property>
|
||||
<property name="default">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="flat">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_2">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources>
|
||||
<include location="UDSResources.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
1
client/notes/macosx/addpass.txt
Normal file
1
client/notes/macosx/addpass.txt
Normal file
@ -0,0 +1 @@
|
||||
security add-generic-password -w temporal -U -a 172.27.0.208\test -s Remote Desktop Connection 2 Password for 172.27.0.208
|
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
|
||||
python setup.py py2app --optimize 2 --plist Info.plist
|
||||
rm udsclient.dmg
|
||||
hdiutil create -srcfolder dist/udsclient.app udsclient.dmg
|
||||
rm UDSClient.dmg
|
||||
hdiutil create -srcfolder dist/UDSClient.app UDSClient.dmg
|
||||
|
1
client/notes/macosx/command.txt
Normal file
1
client/notes/macosx/command.txt
Normal file
@ -0,0 +1 @@
|
||||
/Applications/Remote Desktop Connection.app/Contents/MacOS/Remote Desktop Connection /tmp/kk.rdp
|
BIN
client/notes/macosx/images/logo-uds-small.png
Normal file
BIN
client/notes/macosx/images/logo-uds-small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.2 KiB |
BIN
client/notes/macosx/images/logo-uds.png
Normal file
BIN
client/notes/macosx/images/logo-uds.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
@ -7,7 +7,7 @@ Usage:
|
||||
|
||||
from setuptools import setup
|
||||
|
||||
APP = ['udsclient.py']
|
||||
APP = ['UDSClient.py']
|
||||
DATA_FILES = []
|
||||
OPTIONS = {
|
||||
'argv_emulation': True,
|
||||
|
0
client/notes/macosx/uds/__init__.py
Normal file
0
client/notes/macosx/uds/__init__.py
Normal file
123
client/notes/macosx/uds/forward.py
Normal file
123
client/notes/macosx/uds/forward.py
Normal file
@ -0,0 +1,123 @@
|
||||
# Based on forward.py from paramiko
|
||||
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
|
||||
# https://github.com/paramiko/paramiko/blob/master/demos/forward.py
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import select
|
||||
import SocketServer
|
||||
|
||||
import sys
|
||||
|
||||
import paramiko
|
||||
import threading
|
||||
|
||||
g_verbose = True
|
||||
|
||||
|
||||
class ForwardServer (SocketServer.ThreadingTCPServer):
|
||||
daemon_threads = True
|
||||
allow_reuse_address = True
|
||||
|
||||
|
||||
class Handler (SocketServer.BaseRequestHandler):
|
||||
|
||||
def handle(self):
|
||||
try:
|
||||
chan = self.ssh_transport.open_channel('direct-tcpip',
|
||||
(self.chain_host, self.chain_port),
|
||||
self.request.getpeername())
|
||||
except Exception as e:
|
||||
verbose('Incoming request to %s:%d failed: %s' % (self.chain_host,
|
||||
self.chain_port,
|
||||
repr(e)))
|
||||
return
|
||||
if chan is None:
|
||||
verbose('Incoming request to %s:%d was rejected by the SSH server.' %
|
||||
(self.chain_host, self.chain_port))
|
||||
return
|
||||
|
||||
verbose('Connected! Tunnel open %r -> %r -> %r' % (self.request.getpeername(),
|
||||
chan.getpeername(), (self.chain_host, self.chain_port)))
|
||||
while self.event.is_set() is False:
|
||||
r, w, x = select.select([self.request, chan], [], [], 1)
|
||||
|
||||
if self.request in r:
|
||||
data = self.request.recv(1024)
|
||||
if len(data) == 0:
|
||||
break
|
||||
chan.send(data)
|
||||
if chan in r:
|
||||
data = chan.recv(1024)
|
||||
if len(data) == 0:
|
||||
break
|
||||
self.request.send(data)
|
||||
|
||||
peername = self.request.getpeername()
|
||||
chan.close()
|
||||
self.request.close()
|
||||
verbose('Tunnel closed from %r' % (peername,))
|
||||
|
||||
|
||||
def verbose(s):
|
||||
if g_verbose:
|
||||
print(s)
|
||||
|
||||
|
||||
class ForwardThread(threading.Thread):
|
||||
def __init__(self, server, port, username, password, localPort, redirectHost, redirectPort):
|
||||
threading.Thread.__init__(self)
|
||||
self.client = None
|
||||
self.fs = None
|
||||
|
||||
self.server = server
|
||||
self.port = int(port)
|
||||
self.username = username
|
||||
self.password = password
|
||||
|
||||
self.localPort = int(localPort)
|
||||
self.redirectHost = redirectHost
|
||||
self.redirectPort = redirectPort
|
||||
|
||||
self.stopEvent = threading.Event()
|
||||
|
||||
def run(self):
|
||||
self.client = paramiko.SSHClient()
|
||||
self.client.load_system_host_keys()
|
||||
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
|
||||
verbose('Connecting to ssh host %s:%d ...' % (self.server, self.port))
|
||||
|
||||
self.client.connect(self.server, self.port, username=self.username, password=self.password)
|
||||
|
||||
class SubHander (Handler):
|
||||
chain_host = self.redirectHost
|
||||
chain_port = self.redirectPort
|
||||
ssh_transport = self.client.get_transport()
|
||||
event = self.stopEvent
|
||||
|
||||
self.fs = ForwardServer(('', self.redirectPort), SubHander)
|
||||
self.fs.serve_forever()
|
||||
|
||||
def stop(self):
|
||||
try:
|
||||
self.stopEvent.set()
|
||||
self.fs.shutdown()
|
||||
|
||||
if self.client is not None:
|
||||
self.client.close()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def forward(server, port, username, password, localPort, redirectHost, redirectPort):
|
||||
port, redirectPort = int(port), int(redirectPort)
|
||||
|
||||
|
||||
verbose('Connected')
|
||||
|
||||
ft = ForwardThread(server, port, username, password, localPort, redirectHost, redirectPort)
|
||||
|
||||
ft.start()
|
||||
|
||||
return ft
|
49
client/notes/macosx/uds/osDetector.py
Normal file
49
client/notes/macosx/uds/osDetector.py
Normal file
@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import sys
|
||||
|
||||
|
||||
LINUX = 'Linux'
|
||||
WINDOWS = 'Windows'
|
||||
MAC_OS_X = 'Mac os x'
|
||||
|
||||
|
||||
def getOs():
|
||||
if sys.platform.startswith('linux'):
|
||||
return LINUX
|
||||
elif sys.platform.startswith('win'):
|
||||
return WINDOWS
|
||||
elif sys.platform.startswith('darwin'):
|
||||
return MAC_OS_X
|
108
client/notes/macosx/uds/rest.py
Normal file
108
client/notes/macosx/uds/rest.py
Normal file
@ -0,0 +1,108 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from PyQt4.QtCore import pyqtSignal, pyqtSlot
|
||||
from PyQt4.QtCore import QObject, QUrl, QSettings
|
||||
from PyQt4.QtCore import Qt
|
||||
from PyQt4.QtNetwork import QNetworkAccessManager, QNetworkRequest, QNetworkReply, QSslCertificate
|
||||
from PyQt4.QtGui import QMessageBox
|
||||
|
||||
import json
|
||||
import osDetector
|
||||
import six
|
||||
|
||||
|
||||
class RestRequest(QObject):
|
||||
|
||||
restApiUrl = '' #
|
||||
|
||||
done = pyqtSignal(dict, name='done')
|
||||
|
||||
def __init__(self, url, parentWindow, done): # parent not used
|
||||
super(RestRequest, self).__init__()
|
||||
# private
|
||||
self._manager = QNetworkAccessManager()
|
||||
self.url = QUrl(RestRequest.restApiUrl + url)
|
||||
|
||||
# connect asynchronous result, when a request finishes
|
||||
self._manager.finished.connect(self._finished)
|
||||
self._manager.sslErrors.connect(self._sslError)
|
||||
self._parentWindow = parentWindow
|
||||
|
||||
self.done.connect(done, Qt.QueuedConnection)
|
||||
|
||||
# private slot, no need to declare as slot
|
||||
@pyqtSlot(QNetworkReply)
|
||||
def _finished(self, reply):
|
||||
'''
|
||||
Handle signal 'finished'. A network request has finished.
|
||||
'''
|
||||
try:
|
||||
if reply.error() != QNetworkReply.NoError:
|
||||
raise Exception(reply.errorString())
|
||||
|
||||
data = json.loads(six.text_type(reply.readAll()))
|
||||
except Exception as e:
|
||||
data = {
|
||||
'result': None,
|
||||
'error': six.text_type(e)
|
||||
}
|
||||
|
||||
self.done.emit(data)
|
||||
|
||||
reply.deleteLater() # schedule for delete from main event loop
|
||||
|
||||
@pyqtSlot(QNetworkReply, list)
|
||||
def _sslError(self, reply, errors):
|
||||
settings = QSettings()
|
||||
cert = errors[0].certificate()
|
||||
digest = six.text_type(cert.digest().toHex())
|
||||
|
||||
approved = settings.value(digest, False).toBool()
|
||||
|
||||
errorString = '<p>The certificate for <b>{}</b> has the following errors:</p><ul>'.format(cert.subjectInfo(QSslCertificate.CommonName))
|
||||
|
||||
for err in errors:
|
||||
errorString += '<li>' + err.errorString() + '</li>'
|
||||
|
||||
errorString += '</ul>'
|
||||
|
||||
if approved or QMessageBox.warning(self._parentWindow, 'SSL Warning', errorString, QMessageBox.Yes | QMessageBox.No) == QMessageBox.Yes:
|
||||
settings.setValue(digest, True)
|
||||
reply.ignoreSslErrors()
|
||||
|
||||
def get(self):
|
||||
request = QNetworkRequest(self.url)
|
||||
request.setRawHeader('User-Agent', osDetector.getOs() + " - UDS Connector")
|
||||
self._manager.get(request)
|
63
client/notes/macosx/uds/tools.py
Normal file
63
client/notes/macosx/uds/tools.py
Normal file
@ -0,0 +1,63 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#
|
||||
# Copyright (c) 2015 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import tempfile
|
||||
import string
|
||||
import random
|
||||
import os
|
||||
|
||||
_unlinkFiles = []
|
||||
|
||||
|
||||
def saveTempFile(content, filename=None):
|
||||
if filename is None:
|
||||
filename = ''.join(random.choice(string.ascii_lowercase + string.digits) for _ in range(16))
|
||||
filename = filename + '.uds'
|
||||
filename = os.path.join(tempfile.gettempdir(), filename)
|
||||
with open(filename, 'w') as f:
|
||||
f.write(content)
|
||||
|
||||
return filename
|
||||
|
||||
|
||||
def addFileToUnlink(filename):
|
||||
_unlinkFiles.append(filename)
|
||||
|
||||
|
||||
def unlinkFiles():
|
||||
for f in _unlinkFiles:
|
||||
try:
|
||||
os.unlink(f)
|
||||
except Exception:
|
||||
pass
|
196
client/notes/macosx/udsclient.py
Executable file → Normal file
196
client/notes/macosx/udsclient.py
Executable file → Normal file
@ -1,8 +1,198 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (c) 2014 Virtual Cable S.L.
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without modification,
|
||||
# are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions and the following disclaimer in the documentation
|
||||
# and/or other materials provided with the distribution.
|
||||
# * Neither the name of Virtual Cable S.L. nor the names of its contributors
|
||||
# may be used to endorse or promote products derived from this software
|
||||
# without specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
import Tkinter
|
||||
'''
|
||||
@author: Adolfo Gómez, dkmaster at dkmon dot com
|
||||
'''
|
||||
from __future__ import unicode_literals
|
||||
|
||||
top = Tkinter.Tk()
|
||||
import sys
|
||||
from PyQt4 import QtCore, QtGui
|
||||
import six
|
||||
|
||||
top.mainloop()
|
||||
from uds.rest import RestRequest
|
||||
from uds.forward import forward
|
||||
from uds import tools
|
||||
|
||||
import webbrowser
|
||||
import time
|
||||
|
||||
from UDSWindow import Ui_MainWindow
|
||||
|
||||
# Client connector version
|
||||
VERSION = '1.9.5'
|
||||
|
||||
|
||||
class UDSClient(QtGui.QMainWindow):
|
||||
|
||||
ticket = None
|
||||
scrambler = None
|
||||
|
||||
def __init__(self):
|
||||
QtGui.QMainWindow.__init__(self)
|
||||
self.setWindowFlags(QtCore.Qt.FramelessWindowHint | QtCore.Qt.WindowStaysOnTopHint)
|
||||
|
||||
self.ui = Ui_MainWindow()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.ui.progressBar.setValue(0)
|
||||
self.ui.cancelButton.clicked.connect(self.cancelPushed)
|
||||
|
||||
self.ui.info.setText('Initializing...')
|
||||
|
||||
self.activateWindow()
|
||||
|
||||
def closeWindow(self):
|
||||
self.close()
|
||||
|
||||
def processError(self, data):
|
||||
if 'error' in data:
|
||||
raise Exception(data['error'])
|
||||
# QtGui.QMessageBox.critical(self, 'Request error', rest.data['error'], QtGui.QMessageBox.Ok)
|
||||
# self.closeWindow()
|
||||
# return
|
||||
|
||||
def showError(self, e):
|
||||
self.ui.progressBar.setValue(100)
|
||||
self.ui.info.setText('Error')
|
||||
QtGui.QMessageBox.critical(self, 'Error', six.text_type(e), QtGui.QMessageBox.Ok)
|
||||
self.closeWindow()
|
||||
|
||||
def cancelPushed(self):
|
||||
self.close()
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
def getVersion(self):
|
||||
self.req = RestRequest('', self, self.version)
|
||||
self.req.get()
|
||||
|
||||
@QtCore.pyqtSlot(dict)
|
||||
def version(self, data):
|
||||
try:
|
||||
self.ui.progressBar.setValue(10)
|
||||
|
||||
self.processError(data)
|
||||
|
||||
self.ui.info.setText('Processing...')
|
||||
|
||||
if data['result']['requiredVersion'] > VERSION:
|
||||
QtGui.QMessageBox.critical(self, 'Upgrade required', 'A newer connector version is required.\nA browser will be opened to download it.', QtGui.QMessageBox.Ok)
|
||||
webbrowser.open(data['result']['downloadUrl'])
|
||||
self.closeWindow()
|
||||
return
|
||||
|
||||
self.req = RestRequest('/{}/{}'.format(self.ticket, self.scrambler), self, self.transportDataReceived)
|
||||
self.req.get()
|
||||
|
||||
except Exception as e:
|
||||
self.showError(e)
|
||||
|
||||
@QtCore.pyqtSlot(dict)
|
||||
def transportDataReceived(self, data):
|
||||
try:
|
||||
self.ui.progressBar.setValue(20)
|
||||
self.processError(data)
|
||||
|
||||
script = data['result']
|
||||
print script
|
||||
|
||||
six.exec_(script, globals(), {'parent': self})
|
||||
|
||||
self.closeWindow()
|
||||
except Exception as e:
|
||||
self.showError(e)
|
||||
|
||||
def start(self):
|
||||
'''
|
||||
Starts proccess by requesting version info
|
||||
'''
|
||||
self.ui.info.setText('Initializing...')
|
||||
QtCore.QTimer.singleShot(100, self.getVersion)
|
||||
|
||||
|
||||
def done(data):
|
||||
QtGui.QMessageBox.critical(None, 'Notice', six.text_type(data.data), QtGui.QMessageBox.Ok)
|
||||
sys.exit(0)
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Initialize app
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
|
||||
# Set several info for settings
|
||||
QtCore.QCoreApplication.setOrganizationName('Virtual Cable S.L.U.')
|
||||
QtCore.QCoreApplication.setApplicationName('UDS Connector')
|
||||
|
||||
app.setStyle(QtGui.QStyleFactory.create('plastique'))
|
||||
|
||||
if six.PY3 is False:
|
||||
import threading
|
||||
threading._DummyThread._Thread__stop = lambda x: 42
|
||||
|
||||
# First parameter must be url
|
||||
try:
|
||||
uri = sys.argv[1]
|
||||
if uri[:6] != 'uds://' and uri[:7] != 'udss://':
|
||||
raise Exception()
|
||||
|
||||
ssl = uri[3] == 's'
|
||||
host, UDSClient.ticket, UDSClient.scrambler = uri.split('//')[1].split('/')
|
||||
|
||||
except Exception:
|
||||
QtGui.QMessageBox.critical(None, 'Notice', 'This program is designed to be used by UDS', QtGui.QMessageBox.Ok)
|
||||
sys.exit(1)
|
||||
|
||||
# Setup REST api endpoint
|
||||
# RestRequest.restApiUrl = '{}://{}/rest/client'.format(['http', 'https'][ssl], host)
|
||||
RestRequest.restApiUrl = 'https://172.27.0.1/rest/client'
|
||||
|
||||
try:
|
||||
win = UDSClient()
|
||||
win.show()
|
||||
win.start()
|
||||
|
||||
exitVal = app.exec_()
|
||||
|
||||
time.sleep(3)
|
||||
tools.unlinkFiles()
|
||||
|
||||
sys.exit(exitVal)
|
||||
except Exception as e:
|
||||
QtGui.QMessageBox.critical(None, 'Error', six.text_type(e), QtGui.QMessageBox.Ok)
|
||||
|
||||
sys.stdin.read()
|
||||
QtGui.QMessageBox.critical(None, 'Error', 'test', QtGui.QMessageBox.Ok)
|
||||
# Build base REST
|
||||
|
||||
# v = RestRequest('', done)
|
||||
# v.get()
|
||||
|
||||
# sys.exit(1)
|
||||
|
||||
# myapp = UDSConfigDialog(cfg)
|
||||
# myapp.show()
|
||||
|
15
client/notes/macosx/update.sh
Executable file
15
client/notes/macosx/update.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
function process {
|
||||
for a in *.ui; do
|
||||
pyuic4 $a -o `basename $a .ui`.py -x
|
||||
done
|
||||
}
|
||||
|
||||
pyrcc4 -py3 UDSResources.qrc -o UDSResources_rc.py
|
||||
|
||||
|
||||
# process current directory ui's
|
||||
process
|
||||
|
Loading…
x
Reference in New Issue
Block a user