various unicode fixes

Change-Id: Ia3a83b678a5084fd1d43b8cf513b296fdbde3d91
Reviewed-on: https://forge.frm2.tum.de/review/19198
Tested-by: JenkinsCodeReview <bjoern_pedersen@frm2.tum.de>
Reviewed-by: Enrico Faulhaber <enrico.faulhaber@frm2.tum.de>
This commit is contained in:
Enrico Faulhaber 2018-10-15 14:24:34 +02:00
parent 10f08f6dca
commit 9824b9216d
5 changed files with 23 additions and 14 deletions

View File

@ -36,16 +36,16 @@ import unicodedata
from os import path
repodir = path.abspath(path.join(path.dirname(__file__), '..', '..'))
repodir = path.abspath(path.join(path.dirname(__file__), u'..', u'..'))
CONFIG = {
'piddir': os.path.join(repodir, 'pid'),
'logdir': os.path.join(repodir, 'log'),
'confdir': os.path.join(repodir, 'etc'),
} if os.path.exists(os.path.join(repodir, '.git')) else {
'piddir': '/var/run/secop',
'logdir': '/var/log',
'confdir': '/etc/secop',
u'piddir': os.path.join(repodir, u'pid'),
u'logdir': os.path.join(repodir, u'log'),
u'confdir': os.path.join(repodir, u'etc'),
} if os.path.exists(os.path.join(repodir, u'.git')) else {
u'piddir': u'/var/run/secop',
u'logdir': u'/var/log',
u'confdir': u'/etc/secop',
}

View File

@ -180,7 +180,9 @@ class Module(object):
# (self.name, k, e))
# note: this will call write_* methods which will
# write to the hardware, if possible!
setattr(self, k, v)
if k != u'value':
setattr(self, k, v)
cfgdict.pop(k)
# Adopt units AFTER applying the cfgdict
for k, v in self.accessibles.items():

View File

@ -73,6 +73,7 @@ class Dispatcher(object):
# active (i.e. broadcast-receiving) connections
self._active_connections = set()
# map eventname -> list of subscribed connections
# eventname is <modulename> or <modulename>:<parametername>
self._subscriptions = {}
self._lock = threading.RLock()
@ -178,10 +179,9 @@ class Dispatcher(object):
mod_desc[propname] = prop
result[u'modules'].extend([modulename, mod_desc])
result[u'equipment_id'] = self.equipment_id
result[u'firmware'] = u'The SECoP playground'
result[u'version'] = u'2017.07'
result[u'firmware'] = u'FRAPPY - The Python Framework for SECoP'
result[u'version'] = u'2018.09'
result.update(self.nodeopts)
# XXX: what else?
return result
def _execute_command(self, modulename, command, arguments=None):

View File

@ -61,7 +61,7 @@ class Server(object):
name.endswith('.cfg'):
self._cfgfile = name
self._pidfile = os.path.join(cfg[u'piddir'],
name[:-4].replace(os.path.sep, '_') + u'.pid')
name[:-4].replace(os.path.sep, u'_') + u'.pid')
name = os.path.basename(name[:-4])
else:
self._cfgfile = os.path.join(cfg[u'confdir'], name + u'.cfg')

View File

@ -20,6 +20,13 @@
# *****************************************************************************
"""testing devices"""
try:
# py2
unicode
except NameError:
# py3
unicode = str # pylint: disable=redefined-builtin
import random
from secop.modules import Readable, Drivable, Communicator, Parameter
@ -89,4 +96,4 @@ class Temp(Drivable):
class Lower(Communicator):
"""Communicator returning a lowercase version of the request"""
def do_communicate(self, request):
return str(request).lower()
return unicode(request).lower()