Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion BUILD.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ $ python ./setup.py --command-packages=stdeb.command bdist_deb


Building with Python 3
-------------_--------
----------------------

Building Debian Packages with Python 3 requires
the following Debian Packages to be installed:
Expand Down
9 changes: 8 additions & 1 deletion CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Changelog
0.1
---

- Initial release.
- Initial release.
[Michael Hierweck <michael.hierweck@hostsharing.net>, Hostsharing eG]


Expand All @@ -16,3 +16,10 @@ Changelog

- Add build instructions.
[Michael Hierweck <michael.hierweck@hostsharing.net>, Hostsharing eG]


0.3
---

- Update to recent CAS protocol version.
[Michael Hierweck <michael.hierweck@hostsharing.net>, Hostsharing eG]
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages
import os

version = '0.2'
version = '0.3'

long_description = (
open('README.txt').read())
Expand All @@ -28,6 +28,7 @@
install_requires=[
'setuptools',
'requests',
'pyyaml',
# -*- Extra requirements: -*-
],
entry_points="""
Expand Down
18 changes: 0 additions & 18 deletions src/hs/admin/api/exceptions.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/hs/admin/api/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def __init__(self, proxy, name, properties, methods):

self.methods = dict()
for method in methods:
self.methods[name] = Method(proxy, self, method)
setattr(self, method, self.methods[name])
self.methods[method] = Method(proxy, self, method)
setattr(self, method, self.methods[method])


def list_methods(self):
Expand Down
12 changes: 3 additions & 9 deletions src/hs/admin/api/proxy.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
""" This module provides a directly callable class that implements a remote method invokation.
"""
import xmlrpc.client

try:
from xmlrpclib import ServerProxy
Expand All @@ -8,9 +9,6 @@
from xmlrpc.client import ServerProxy
from xmlrpc.client import Fault

from .exceptions import ProxyError



class Proxy(object):
""" This directly callable class implements a remote method invokation.
Expand All @@ -20,13 +18,11 @@ def __init__(self, session, dispatcher):
self.session = session
self.dispatcher = dispatcher


def __call__(self, module, method, where=None, set=None):
backend = self.dispatcher.get_backend(module)
remote = getattr(ServerProxy(backend), module + '.' + method)
ticket = self.session.get_ticket()
user = self.session.get_user()

try:
if (where is None) and (set is None):
result = remote(user, ticket)
Expand All @@ -36,8 +32,6 @@ def __call__(self, module, method, where=None, set=None):
result = remote(user, ticket, where)
else:
result = remote(user, ticket, set, where)

except Fault as fault:
raise ProxyError(fault.faultString)

except xmlrpc.client.Fault as e:
raise Exception('HS Error' + e.faultString)
return result
17 changes: 6 additions & 11 deletions src/hs/admin/api/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
"""

from requests import delete, post

from .exceptions import LoginError, SessionError

from yaml import safe_load


class Session(object):
Expand All @@ -16,27 +14,24 @@ def __init__(self, provider, service, username, password):
'password': password}
result = post(provider, data=payload)
if result.status_code != 201:
raise LoginError('Acquisition of ticket granting ticket failed.')
raise Exception('Session Error: Acquisition of ticket granting ticket failed.')
self.service = service
self.tgt = result.headers['location']
self.user = username


def __exit__(self, exc_type, exc_value, traceback):
delete(self.tgt)


def get_ticket(self):
""" Returns an one-time ticket for a remote user action """
""" Returns a one-time ticket for a remote user action """

payload = {'service': self.service}
result = post(self.tgt, data=payload)
if result.status_code != 200:
raise SessionError('Acquisition of session ticket failed.')
return result.text

raise Exception('Session Error: Acquisition of session ticket failed.')
return safe_load(result.text)

def get_user(self):
""" Returns the user name """
""" Returns the name of the user """

return self.user