1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-03-08 16:58:31 +03:00

* Advancing on "thin plugin" for UDS

This commit is contained in:
Adolfo Gómez García 2017-08-02 15:53:18 +02:00
parent 79a591180d
commit 2b9cd5508d
4 changed files with 21 additions and 16 deletions

View File

@ -74,14 +74,13 @@ def approveHost(host):
except Exception:
logger.warn('Got exception writing to {}'.format(hostsFile))
return approved
def getWithRetry(rest, url):
def getWithRetry(rest, url, params=None):
while True:
try:
res = rest.get(url)
res = rest.get(url, params)
return res
except RetryException as e:
if ui.question('Service not available', '{}\nPlease, wait a minute and press "OK" to retry, or CANCEL to abort') is True:
@ -125,16 +124,20 @@ if __name__ == "__main__":
try:
res = getWithRetry(rest, '')
logger.debug('Got information {}'.format(res))
if res['requiredVersion'] > VERSION:
ui.message("New UDS Client available", "A new uds version is needed in order to access this version of UDS. A browser will be openend for this download.")
ui.message("New UDS Client available", "A new uds version is needed in order to access this version of UDS. A browser will be opened for this download.")
webbrowser.open(res['downloadUrl'])
sys.exit(1)
# Now get ticket
res = getWithRetry(rest, '/{}/{}'.format(ticket, scrambler), params={'hostname': tools.getHostName(), 'version': VERSION})
logger.debug('Got ticket {}'.format(res))
except Exception as e:
error = 'ERROR: {}'.format(e)
logger.error(error)
ui.message('Error', error)
sys.exit(2)

View File

@ -37,7 +37,7 @@ from . import VERSION
import json
import six
import urllib
import osDetector
from .log import logger
@ -55,16 +55,17 @@ class RestRequest(object):
self.host = host
self.ssl = ssl
self.restApiUrl = RestRequest('{}://{}/rest/client'.format(['http', 'https'][ssl], host))
self.restApiUrl = '{}://{}/rest/client'.format(['http', 'https'][ssl], host)
def get(self, url, params=None):
url = self.restApiUrl + url
if params is not None:
url += '?' + '&'.join('{}={}'.format(k, urllib.quote(six.text_type(v).encode('utf8'))) for k, v in params.iteritems())
url += '?' + '&'.join('{}={}'.format(k, six.moves.urllib.parse.quote(six.text_type(v).encode('utf8'))) for k, v in params.iteritems()) # @UndefinedVariable
logger.debug('Requesting {}'.format(url))
try:
r = requests.get(url, headers={'Content-type': 'application/json'})
r = requests.get(url, headers={'Content-type': 'application/json', 'User-Agent': osDetector.getOs() + " - UDS Connector " + VERSION })
except requests.exceptions.ConnectionError as e:
raise Exception('Error connecting to UDS Server at {}'.format(self.restApiUrl[0:-11]))

View File

@ -34,7 +34,7 @@ from __future__ import unicode_literals
try:
import gtkui as theUI
except Exception:
import consoleui as theUI
import consoleui as theUI # @Reimport
def message(title, message):
theUI.message(title, message)

View File

@ -1,10 +1,11 @@
Steps:
1.- Copy the folder "udsclient" to /build/packages inside the thinstation build environment
2.- enter the chroot of thinstation
3.- go to the udsclient folder (/build/packages/udsclient)
4.- Execute "build.sh"
5.- Edit the file /build/build.conf, and add this line:
1.- If building from repository, full copy (recursive) the "src" folder of "udsclient/thin" inside the "udsclient" folder. If building from the .tar.gz, simply ignor4e this step
2.- Copy the folder "udsclient" to /build/packages inside the thinstation build environment
3.- enter the chroot of thinstation
4.- go to the udsclient folder (/build/packages/udsclient)
5.- Execute "build.sh"
6.- Edit the file /build/build.conf, and add this line:
package udsclient
6.- Execute the build process
7.- Execute the build process
Ready!!!