From 728f35b52cfc22894ab3ae78856cc9e247bd615c Mon Sep 17 00:00:00 2001 From: Benjamin Dweck Date: Mon, 1 Feb 2021 16:50:03 +0200 Subject: [PATCH] added output flush --- syncthing_monitor/__main__.py | 4 ++-- syncthing_monitor/etcd_client.py | 4 ++-- syncthing_monitor/syncthing_client.py | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/syncthing_monitor/__main__.py b/syncthing_monitor/__main__.py index 52d3269..1a47c30 100644 --- a/syncthing_monitor/__main__.py +++ b/syncthing_monitor/__main__.py @@ -48,7 +48,7 @@ class SyncthingMonitor: api_key = xml.parse_api_key(self.syncthing_config_xml_path) print("Found API Key: {0}".format(api_key)) - print("Configuring Syncthing to listen on 0.0.0.0...") + print("Configuring Syncthing to listen on 0.0.0.0...", flush=True) xml.set_listen_ip_to_any(self.syncthing_config_xml_path, self.syncthing_config_xml_path, self.syncthing_gui_port) @@ -60,7 +60,7 @@ class SyncthingMonitor: self.initialize_syncthing() self.my_device_id = self.syncthing.get_my_device_id() - print("Found My Device ID: {0}".format(self.my_device_id)) + print("Found My Device ID: {0}".format(self.my_device_id), flush=True) self.syncthing.disable_announce_discovery_and_relay() self.syncthing.create_shared_folder(SHARED_FOLDER_ID, SHARED_FOLDER_LABEL, self.syncthing_data_path, diff --git a/syncthing_monitor/etcd_client.py b/syncthing_monitor/etcd_client.py index 600236f..6ef809f 100644 --- a/syncthing_monitor/etcd_client.py +++ b/syncthing_monitor/etcd_client.py @@ -33,13 +33,13 @@ class EtcdClient: cluster_info['devices'].append(new_device) - print("Updating etcd value for '{0}': {1}".format(self.key, json.dumps(cluster_info))) + print("Updating etcd value for '{0}': {1}".format(self.key, json.dumps(cluster_info)), flush=True) self.etcd.put(self.key, json.dumps(cluster_info)) @retry def get_device_list(self): device_list = self.load_cluster_info()['devices'] - print("Obtained device_list devices from etcd: {0}".format(json.dumps(device_list))) + print("Obtained device_list devices from etcd: {0}".format(json.dumps(device_list)), flush=True) return device_list def register_device_update_handler(self, device_update_handler): diff --git a/syncthing_monitor/syncthing_client.py b/syncthing_monitor/syncthing_client.py index a1633e4..011df82 100644 --- a/syncthing_monitor/syncthing_client.py +++ b/syncthing_monitor/syncthing_client.py @@ -50,7 +50,7 @@ class SyncthingClient: "maxRequestKiB": 0 } response = self.post("/rest/config/devices", json.dumps(post_data)) - print("Attempt to add device {0} to syncthing: {1}".format(device, response.content)) + print("Attempt to add device {0} to syncthing: {1}".format(device, response.content), flush=True) def create_shared_folder(self, folder_id, label, path, devices): post_data = { @@ -100,18 +100,18 @@ class SyncthingClient: post_data['devices'].append(folder_device) response = self.post("/rest/config/folders", json.dumps(post_data)) - print("Attempt to add shared folder to syncthing: {0}".format(response.content)) + print("Attempt to add shared folder to syncthing: {0}".format(response.content), flush=True) @retry def print_config(self): response = self.get("/rest/config/devices") - print("/rest/config/devices: {0}".format(response.content)) + print("/rest/config/devices: {0}".format(response.content), flush=True) response = self.get("/rest/config/folders") - print("/rest/config/folders: {0}".format(response.content)) + print("/rest/config/folders: {0}".format(response.content), flush=True) response = self.get("/rest/config/options") - print("/rest/config/options: {0}".format(response.content)) + print("/rest/config/options: {0}".format(response.content), flush=True) @retry def config_is_in_sync(self): @@ -121,7 +121,7 @@ class SyncthingClient: @retry def restart(self): response = self.post("/rest/system/restart", '') - print("System reset: {0}".format(response.content)) + print("System reset: {0}".format(response.content), flush=True) def sync_config(self): if not self.config_is_in_sync(): @@ -135,7 +135,7 @@ class SyncthingClient: "announceLANAddresses": False, } response = self.patch("/rest/config/options", json.dumps(config_patch)) - print("Patched syncthing configuration: {0}".format(response.content)) + print("Patched syncthing configuration: {0}".format(response.content), flush=True) def make_url(self, endpoint): return "http://{0}:{1}{2}".format(self.host, self.port, endpoint)