Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@rpc(String)
def msg(self, m):
print(m)
_type_info["Data"] = XmlData(String)
def __repr__(self):
"""For types we can't resolve only print the datum"""
return self.Data
# SOAP Header Elements
class ID(Tr069ComplexModel):
# Note: for some reason, XmlAttribute/XmlData pairs MUST be ordered, with
# XmlAttribute coming first. This appears to be a spyne bug (something to do
# with spyne.interface._base.add_class())
_type_info = odict()
_type_info["mustUnderstand"] = XmlAttribute(String, ns=SOAP_ENV)
_type_info["Data"] = XmlData(String)
class HoldRequests(Tr069ComplexModel):
_type_info = odict()
_type_info["mustUnderstand"] = XmlAttribute(String, ns=SOAP_ENV)
_type_info["Data"] = XmlData(Boolean)
# SOAP Fault Extensions
class SetParameterValuesFault(Tr069ComplexModel):
_type_info = odict()
_type_info["ParameterName"] = String
_type_info["FaultCode"] = UnsignedInteger
@rpc(String, UnsignedInteger, _returns=Iterable(String))
def say_hello(ctx, name, times):
def cb(ret):
for i in range(times):
ret.append('Hello, %s' % name)
return Iterable.Push(cb)
return dict.__getitem__(self, key)
except KeyError:
raise PublicKeyError(key)
class RequestHeader(ComplexModel):
__namespace__ = 'spyne.examples.authentication'
session_id = Mandatory.String
user_name = Mandatory.String
class Preferences(ComplexModel):
__namespace__ = 'spyne.examples.authentication'
language = String(max_len=2)
time_zone = String
user_db = {
'neo': bcrypt.hashpw('Wh1teR@bbit', bcrypt.gensalt()),
}
session_db = set()
preferences_db = SpyneDict({
'neo': Preferences(language='en', time_zone='Underground/Zion'),
'smith': Preferences(language='xx', time_zone='Matrix/Core'),
})
class AuthenticationService(Service):
@rpc(String, _returns=String)
def apply_snapshot(self, ver):
if ver == "base_version":
fname = "/etc/elbe_base.xml"
else:
fname = self.app.status.repo_dir + "/" + ver + "/new.xml"
try:
apply_update(fname, self.app.status)
# pylint: disable=broad-except
except Exception as err:
print("%s" % str(err))
self.app.status.set_finished('error')
return "apply snapshot %s failed" % ver
self.app.status.set_finished('OK')
return "snapshot %s applied" % ver
@rpc(String, UnsignedInteger, _returns=Iterable(String))
def say_hello(ctx, name, times):
def cb(ret):
for i in range(times):
ret.append('Hello, %s' % name)
return Iterable.Push(cb)
@srpc(String, String, String, _returns=String)
def name_function(bin_name, func_addr, new_name):
binaries[bin_name].functions()[func_addr].name = new_name
return "success"
@rpc(String, _is_callback=True)
def woke_up(ctx, message):
pass
faultcode='Client.UnauthenticatedError',
faultstring='This resource can only be accessed after authentication.'
)
class SpyneDict(dict):
def __getitem__(self, key):
try:
return dict.__getitem__(self, key)
except KeyError:
raise PublicKeyError(key)
class Preferences(ComplexModel):
__namespace__ = 'spyne.examples.authentication'
language = String(max_len=2)
time_zone = String
user_db = {
'neo': bcrypt.hashpw('Wh1teR@bbit', bcrypt.gensalt()),
}
session_db = set()
preferences_db = SpyneDict({
'neo': Preferences(language='en', time_zone='Underground/Zion'),
'smith': Preferences(language='xx', time_zone='Matrix/Core'),
})
class UserService(Service):
@srpc(String, String, _returns=String)
def load_binary(bin_name, filename):
if bin_name in binaries:
return "already loaded"
binaries[bin_name] = binary.Binary(filename)
return "success"