summaryrefslogtreecommitdiff
path: root/jfr_playoff/filemanager.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2018-02-25 11:17:24 +0100
committeremkael <emkael@tlen.pl>2018-02-25 11:17:24 +0100
commita8aa671f49152dc7975de9bd62b929aab0ff309b (patch)
tree642dca7069a98644e54d526d8255a2ac7364cbff /jfr_playoff/filemanager.py
parent70a74524095166ee349603e2d48f2cf7c6c5f118 (diff)
parent8c500a75a6eafd65b332d0f8346d9059d5293cbb (diff)
Merge branch 'verbose_logging' into devel
Diffstat (limited to 'jfr_playoff/filemanager.py')
-rw-r--r--jfr_playoff/filemanager.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/jfr_playoff/filemanager.py b/jfr_playoff/filemanager.py
index 97f9cb8..515845e 100644
--- a/jfr_playoff/filemanager.py
+++ b/jfr_playoff/filemanager.py
@@ -2,6 +2,8 @@ import os
import shutil
import socket
+from jfr_playoff.logger import PlayoffLogger
+
import __main__
@@ -9,12 +11,15 @@ class PlayoffFileManager(object):
def __init__(self, settings):
self.goniec = settings.get('goniec') if settings.has_section('goniec') else None
+ PlayoffLogger.get('filemanager').info('goniec settings: %s', self.goniec)
self.output_file = settings.get('output')
+ PlayoffLogger.get('filemanager').info('output file: %s', self.output_file)
self.output_path = os.path.dirname(
self.output_file
).strip(os.sep)
if len(self.output_path) > 0:
self.output_path += os.sep
+ PlayoffLogger.get('filemanager').info('output path: %s', self.output_path)
self.files = set()
def reset(self):
@@ -22,14 +27,24 @@ class PlayoffFileManager(object):
def register_file(self, path):
if path.startswith(self.output_path):
+ PlayoffLogger.get('filemanager').info('registering file: %s', path)
self.files.add(path.replace(self.output_path, ''))
+ else:
+ PlayoffLogger.get('filemanager').info(
+ 'file: %s outside of %s, not registering', path, self.output_path)
def write_content(self, content):
output_dir = os.path.dirname(self.output_file)
if len(output_dir) > 0:
if not os.path.exists(output_dir):
+ PlayoffLogger.get('filemanager').info(
+ 'output directory %s does not exist, creating',
+ output_dir)
os.makedirs(output_dir)
output = open(self.output_file, 'w')
+ PlayoffLogger.get('filemanager').info(
+ 'writing %d bytes into file %s',
+ len(content), self.output_file)
output.write(content.encode('utf8'))
output.close()
self.register_file(self.output_file)
@@ -40,7 +55,12 @@ class PlayoffFileManager(object):
script_output_dir = os.path.dirname(script_output_path)
if len(script_output_dir) > 0:
if not os.path.exists(script_output_dir):
+ PlayoffLogger.get('filemanager').info(
+ 'output directory %s does not exist, creating',
+ script_output_dir)
os.makedirs(script_output_dir)
+ PlayoffLogger.get('filemanager').info(
+ 'copying JS to %s', script_output_path)
shutil.copy(
unicode(os.path.join(
os.path.dirname(__main__.__file__), 'playoff.js')),
@@ -58,7 +78,8 @@ class PlayoffFileManager(object):
content_lines = [self.output_path] + \
list(self.files) + \
['bye', '']
- print '\n'.join(content_lines)
+ PlayoffLogger.get('goniec').info(
+ '\n'.join(content_lines))
goniec = socket.socket()
goniec.connect((self.goniec['host'], self.goniec['port']))
goniec.sendall('\n'.join(content_lines))