From 5c243f1cac5cc489f3bbb821ab5064d9edf7d449 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Sat, 15 Aug 2015 13:22:34 +0200 Subject: basic connection --- voctogui/lib/config.py | 8 ++++++++ voctogui/lib/connection.py | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 voctogui/lib/connection.py (limited to 'voctogui/lib') diff --git a/voctogui/lib/config.py b/voctogui/lib/config.py index b06075c..b18acfb 100644 --- a/voctogui/lib/config.py +++ b/voctogui/lib/config.py @@ -1,14 +1,22 @@ #!/usr/bin/python3 +import logging import os.path from configparser import SafeConfigParser from lib.args import Args +import lib.connection as Connection __all__ = ['Config'] def getlist(self, section, option): return [x.strip() for x in self.get(section, option).split(',')] +def fetchRemoteConfig(self): + log = logging.getLogger('Config') + log.info("reading server-config %s", Connection) + Connection.ask('config') + SafeConfigParser.getlist = getlist +SafeConfigParser.fetchRemoteConfig = fetchRemoteConfig files = [ os.path.join(os.path.dirname(os.path.realpath(__file__)), '../default-config.ini'), diff --git a/voctogui/lib/connection.py b/voctogui/lib/connection.py new file mode 100644 index 0000000..37851f0 --- /dev/null +++ b/voctogui/lib/connection.py @@ -0,0 +1,15 @@ +#!/usr/bin/python3 +import logging +import socket + +log = logging.getLogger('Connection') +sock = None +port = 9999 + +def establish(host): + log.info('establishing Connection to %s', host) + sock = socket.create_connection( (host, port) ) + log.debug('Connection successful \o/') + +def ask(command): + print("would send command talk to server now and read back the response") -- cgit v1.2.3