[X2Go-Commits] x2gobroker.git - statusflag (branch) updated: 0.0.1.0-8-gb24fe4e

X2Go dev team git-admin at x2go.org
Tue Jun 4 21:10:00 CEST 2013


The branch, statusflag has been updated
       via  b24fe4ed32dc3f3066f20b4f93f1df5bbbdaa778 (commit)
      from  b440438bdbdcdd248957f6e2e0cfe4deaab895b5 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
-----------------------------------------------------------------------

Summary of changes:
 x2gobroker/uccsjson.py |  241 ++++++++++++++++++++++++++++++++++++++++++++++++
 x2gobroker/web/uccs.py |   83 +----------------
 2 files changed, 244 insertions(+), 80 deletions(-)
 create mode 100644 x2gobroker/uccsjson.py

The diff of changes is:
diff --git a/x2gobroker/uccsjson.py b/x2gobroker/uccsjson.py
new file mode 100644
index 0000000..779e2ba
--- /dev/null
+++ b/x2gobroker/uccsjson.py
@@ -0,0 +1,241 @@
+# Copyright (C) 2012 by Mike Gabriel <mike.gabriel at das-netzwerkteam.de>
+# Copyright (C) 2012 by Oleksandr Shneyder <oleksandr.shneyder at obviously-nice.de>
+# Copyright (C) 2012 by Heinz-Markus Graesing <heinz-m.graesing at obviously-nice.de>
+#
+# X2Go Session Broker is free software; you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# X2Go Session Broker is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program; if not, write to the
+# Free Software Foundation, Inc.,
+# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
+
+import json
+
+def convert_to_builtin_type(obj):
+    """\
+    Helper function for converting Python objects to dictionaries.
+    Used for doing JSON dumps.
+
+    """
+    d = { }
+    d.update(obj.__dict__)
+    return d
+
+class ManagementServer():
+    """\
+    Base class for generating UCCS compatible JSON object.
+
+    """
+    def __init__(self, url, name):
+        """\
+        Initializ instance.
+
+        @param url: URL of the UCCS broker server
+        @type url: C{unicode}
+        @param name: human-readable, descriptive server name
+        @type name: C{unicode}
+
+        """
+        self.RemoteDesktopServers = []
+        self.AdditionalManagementServers = []
+        self.URL = url
+        self.Name = name
+
+    def set_default(self, ts_name):
+        """\
+        Define the default (terminal) server instance.
+
+        @param ts_name: name of the terminal server that is to be set as default
+        @type ts_name: C{unicode}
+
+        """
+        if isinstance(tsName, str):
+            self.DefaultServer = tsName
+        else:
+            raise TypeError("set_default expects a string argument")
+
+    def add_terminal_server(self, server):
+        """\
+        Add a terminal server to this management server object.
+
+        @param server: instance of class L{RDPServer} or L{X2GoServer}.
+        @type server: C{obj}
+
+        """
+        self.RemoteDesktopServers.append(server)
+
+    # NOT USED!!!
+    #def add_additional_management_server(self, amserver):
+    #    if isinstance(amserver, AdditionalManagementServer):
+    #        self.AdditionalManagementServers.append(amserver)
+    #    else:
+    #        raise TypeError("add_additional_management_server expects a "\
+    #            "AdditionalManagementServer argument")
+
+    def toJson(self):
+        """\
+        Dump this instance as JSON object.
+
+        """
+        return json.dumps(self, default=convert_to_builtin_type)
+
+
+# NOT USED!!!
+#class AdditionalManagementServer():
+#    def __init__(self, url, name):
+#        self.URL = url
+#        self.Name = name
+
+
+class RDPServer():
+    """\
+    Instantiate a UCCS compatible RDP server session profile object.
+
+    """
+    def __init__(self, host, name, username=None, password=None):
+        """\
+        @param host: hostname of RDP server host
+        @type host: C{unicode}
+        @param name: session profile name
+        @type name: C{unicode}
+        @param username: username to be used for login
+        @type username: C{unicode}
+        @param password: password to be used for login
+        @type password: C{unicode}
+
+        """
+        self.URL = unicode(host)
+        self.Name = unicode(name)
+        self.Protocol = u'freerdp'
+        self.DomainRequired = unicode(True)
+        self.Username = unicode(username)
+        self.Password = unicode(password)
+
+    def set_domain(self, domain):
+        """\
+        Set the domain for this RDP server.
+
+        @param domain: the domain name to be set
+        @type domain: C{unicode}
+
+        @raise TypeError: domain has to be C{str} or C{unicode}
+
+        """
+        if isinstance(domainName, str):
+            self.WindowsDomain = unicode(domain)
+        elif isinstance(domainName, unicode):
+            self.WindowsDomain = domain
+        else:
+            raise TypeError("set_domain() expects a string or unicode argument")
+
+    def toJson(self):
+        """\
+        Dump this instance as JSON object.
+
+        """
+        return json.dumps(self, default=convert_to_builtin_type)
+
+
+class ICAServer():
+    """\
+    Instantiate a UCCS compatible ICA server session profile object.
+
+    """
+    def __init__(self, host, name, username=None, password=None):
+        """\
+        @param host: hostname of ICA server host
+        @type host: C{unicode}
+        @param name: session profile name
+        @type name: C{unicode}
+        @param username: username to be used for login
+        @type username: C{unicode}
+        @param password: password to be used for login
+        @type password: C{unicode}
+
+        """
+        self.URL = unicode(host)
+        self.Name = unicode(name)
+        self.Protocol = u'ica'
+        self.DomainRequired = unicode(True)
+        self.Username = unicode(username)
+        self.Password = unicode(password)
+
+    def set_domain(self, domain):
+        """\
+        Set the domain for this ICA server.
+
+        @param domain: the domain name to be set
+        @type domain: C{unicode}
+
+        @raise TypeError: domain has to be C{str} or C{unicode}
+
+        """
+        if isinstance(domainName, str):
+            self.WindowsDomain = unicode(domain)
+        elif isinstance(domainName, unicode):
+            self.WindowsDomain = domain
+        else:
+            raise TypeError("set_domain() expects a string or unicode argument")
+
+    def toJson(self):
+        """\
+        Dump this instance as JSON object.
+
+        """
+        return json.dumps(self, default=convert_to_builtin_type)
+
+
+class X2GoServer():
+    """\
+    Instantiate a UCCS compatible X2Go Server session profile object.
+
+    """
+    def __init__(self, host, name, username=None, password=None):
+        """\
+        @param host: hostname of X2Go Server host
+        @type host: C{unicode}
+        @param name: session profile name
+        @type name: C{unicode}
+        @param username: username to be used for login
+        @type username: C{unicode}
+        @param password: password to be used for login
+        @type password: C{unicode}
+
+        """
+        self.URL = host
+        self.Name = name
+        self.Protocol = 'x2go'
+        self.SessionTypeRequired = True
+        self.Username = username
+        self.Password = password
+
+    def set_session_type(self, session_type):
+        """\
+        Set the session type to be used with this X2Go Server.
+
+        @param session_type: the session type to be set
+        @type session_type: C{unicode}
+
+        @raise TypeError: session_type has to be C{str} or C{unicode}
+
+        """
+        if isinstance(domainName, str):
+            self.SessionType = sessiontypeName
+        else:
+            raise TypeError("set_session_type() expects a string or unicode argument")
+
+    def toJson(self):
+        """\
+        Dump this instance as JSON object.
+
+        """
+        return json.dumps(self, default=convert_to_builtin_type)
+
diff --git a/x2gobroker/web/uccs.py b/x2gobroker/web/uccs.py
index be63096..b75effa 100644
--- a/x2gobroker/web/uccs.py
+++ b/x2gobroker/web/uccs.py
@@ -29,84 +29,7 @@ from tornado.escape import native_str, parse_qs_bytes
 import x2gobroker.defaults
 
 from x2gobroker.loggers import logger_broker, logger_error
-
-
-def convert_to_builtin_type(obj):
-    d = { }
-    d.update(obj.__dict__)
-    return d
-
-
-class ManagementServer():
-    def __init__(self, url, name):
-        self.RemoteDesktopServers = []
-        self.AdditionalManagementServers = []
-        self.URL = url
-        self.Name = name
-
-    def set_default(self, tsName):
-        if isinstance(tsName, str):
-            self.DefaultServer = tsName
-        else:
-            raise TypeError("set_default expects a string argument")
-
-    def add_terminal_server(self, server):
-        self.RemoteDesktopServers.append(server)
-
-    def add_additional_management_server(self, amserver):
-        if isinstance(amserver, AdditionalManagementServer):
-            self.AdditionalManagementServers.append(amserver)
-        else:
-            raise TypeError("add_additional_management_server expects a "\
-                "AdditionalManagementServer argument")
-
-    def toJson(self):
-        return json.dumps(self, default=convert_to_builtin_type)
-
-
-class AdditionalManagementServer():
-    def __init__(self, url, name):
-        self.URL = url
-        self.Name = name
-
-
-class RDPServer():
-    def __init__(self, url, name, username=None, password=None):
-        self.URL = url
-        self.Name = name
-        self.Protocol = 'freerdp'
-        self.DomainRequired = True
-        self.Username = username
-        self.Password = password
-
-    def add_domain(self, domainName):
-        if isinstance(domainName, str):
-            self.WindowsDomain = domainName
-        else:
-            raise TypeError("add_domain expects a string argument")
-
-    def toJson(self):
-        return json.dumps(self, default=convert_to_builtin_type)
-
-
-class X2GoServer():
-    def __init__(self, url, name, username=None, password=None):
-        self.URL = url
-        self.Name = name
-        self.Protocol = 'x2go'
-        self.SessionTypeRequired = True
-        self.Username = username
-        self.Password = password
-
-    def add_sessiontype(self, sessiontypeName):
-        if isinstance(domainName, str):
-            self.SessionType = sessiontypeName
-        else:
-            raise TypeError("add_sessiontype expects a string argument")
-
-    def toJson(self):
-        return json.dumps(self, default=convert_to_builtin_type)
-
+import x2gobroker.uccsjson
 
 class X2GoBrokerWeb(tornado.web.RequestHandler):
 
@@ -179,7 +102,7 @@ class X2GoBrokerWeb(tornado.web.RequestHandler):
 
         profiles = broker_backend.list_profiles(username)
         if profiles:
-            ms = ManagementServer('http://localhost:8080/uccs/{backend}'.format(backend=backend), 'X2Go Session Broker')
+            ms = x2gobroker.uccsjson.ManagementServer('http://localhost:8080/uccs/{backend}'.format(backend=backend), 'X2Go Session Broker')
 
             profile_ids = profiles.keys()
             profile_ids.sort()
@@ -189,7 +112,7 @@ class X2GoBrokerWeb(tornado.web.RequestHandler):
                 if profiles[profile_id]['directrdp']:
                     pass
                 else:
-                    ts = X2GoServer(
+                    ts = x2gobroker.uccsjson.X2GoServer(
                             url='{hostname}:{port}'.format(hostname=profiles[profile_id]['host'], port=profiles[profile_id]['sshport'])
                             name=profiles[profile_id]['name']
                             username=profiles[profile_id]['user']


hooks/post-receive
-- 
x2gobroker.git (HTTP(S) Session broker for X2Go)

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "x2gobroker.git" (HTTP(S) Session broker for X2Go).




More information about the x2go-commits mailing list