Skip to content
Closed

Mock #183

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
20 changes: 20 additions & 0 deletions qcodes/instrument/mock.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,16 +135,36 @@ def __init__(self, name='Model-{:.7s}'):
# this will primarily be called via the attached instruments.
super().__init__(name, server_class=None)

def get_attribute(self, name):
''' Get an attribute from the model (server side) '''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Trailing whitespace

return self.ask('_magicget:%s' % (name, ))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Trailing whitespace


def call_function(self, name, *args):
''' Call a function from the model (server side) '''

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Trailing whitespace

return self.ask('_magiccall:%s' % (name, ), *args)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Trailing whitespace


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codacy Issue found: Trailing whitespace

def _run_server(self):
while True:
try:
# make sure no matter what there is a query for error handling
query = None
query = self._query_queue.get()
query_args = query[1:]
query = query[0].split(':')

instrument = query[0]

if instrument == '_magicget':
name = query[1]
value = getattr(self, name)
self._response_queue.put(value)
continue
if instrument == '_magiccall':
name = query[1]
func = getattr(self, name)
self._response_queue.put( func(*query_args) )
continue

if instrument == 'halt':
self._response_queue.put(True)
break
Expand Down