From 7b0ddb47d5c5c6d98b3f3b95b469c2159e3927b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Diemer?= Date: Fri, 24 May 2019 15:59:53 +0200 Subject: [PATCH] Use command line argument for configuration in examples --- examples/fake_mediacoder.py | 6 ++++-- examples/recorder_controller.py | 4 +++- examples/screen_controller.py | 4 +++- examples/send_message.py | 4 +++- examples/wol_relay.py | 4 +++- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/examples/fake_mediacoder.py b/examples/fake_mediacoder.py index c96b6ec..ac5b9e6 100644 --- a/examples/fake_mediacoder.py +++ b/examples/fake_mediacoder.py @@ -3,9 +3,10 @@ ''' Fake MediaCoder client for tests. ''' -import os import json import logging +import os +import sys from mm_client.client import MirisManagerClient logger = logging.getLogger('fake_mediacoder') @@ -40,7 +41,8 @@ def handle_action(self, action, params): if __name__ == '__main__': - client = FakeMediaCoder() + local_conf = sys.argv[1] if len(sys.argv) > 1 else None + client = FakeMediaCoder(local_conf) client.update_capabilities() client.set_status(status='ready', status_message='Ready to record', remaining_space='auto') try: diff --git a/examples/recorder_controller.py b/examples/recorder_controller.py index e383b16..47b196d 100644 --- a/examples/recorder_controller.py +++ b/examples/recorder_controller.py @@ -6,6 +6,7 @@ ''' import json import logging +import sys from mm_client.client import MirisManagerClient logger = logging.getLogger('recorder_controller') @@ -45,7 +46,8 @@ def handle_action(self, action, params): if __name__ == '__main__': - client = RecorderController() + local_conf = sys.argv[1] if len(sys.argv) > 1 else None + client = RecorderController(local_conf) try: client.long_polling_loop() except KeyboardInterrupt: diff --git a/examples/screen_controller.py b/examples/screen_controller.py index 0308657..342361a 100644 --- a/examples/screen_controller.py +++ b/examples/screen_controller.py @@ -6,6 +6,7 @@ ''' import logging import os +import sys from mm_client.client import MirisManagerClient logger = logging.getLogger('screen_controller') @@ -43,7 +44,8 @@ def handle_action(self, action, params): if __name__ == '__main__': - client = ScreenController() + local_conf = sys.argv[1] if len(sys.argv) > 1 else None + client = ScreenController(local_conf) client.update_capabilities() try: client.long_polling_loop() diff --git a/examples/send_message.py b/examples/send_message.py index ff9923d..9fd41e8 100644 --- a/examples/send_message.py +++ b/examples/send_message.py @@ -4,11 +4,13 @@ Script to send a message ''' import datetime +import sys from mm_client.client import MirisManagerClient if __name__ == '__main__': - client = MirisManagerClient() + local_conf = sys.argv[1] if len(sys.argv) > 1 else None + client = MirisManagerClient(local_conf) client.api_request('ADD_MESSAGE', data=dict( content='%s\nTest message' % datetime.datetime.now(), content_debug='Debug content with some special characters:\n\tđ€¶←←ħ¶ŧħ<< "\' fF5ef', diff --git a/examples/wol_relay.py b/examples/wol_relay.py index b98f56f..506ba7e 100644 --- a/examples/wol_relay.py +++ b/examples/wol_relay.py @@ -7,6 +7,7 @@ import logging import os import re +import sys from mm_client.client import MirisManagerClient logger = logging.getLogger('wol_relay') @@ -55,7 +56,8 @@ def send_wake_on_lan(self, params): if __name__ == '__main__': - client = WOLRelay() + local_conf = sys.argv[1] if len(sys.argv) > 1 else None + client = WOLRelay(local_conf) client.update_capabilities() try: client.long_polling_loop()