summaryrefslogtreecommitdiff
path: root/playoff.py
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-02-22 17:10:06 +0100
committeremkael <emkael@tlen.pl>2017-02-22 17:10:06 +0100
commit4d7be8c8fb1d12bb87b5a29c8ad8ff9515080334 (patch)
tree91275ed0f0d1293b648c8e660d0be772c0982775 /playoff.py
parentf5b982e2aab612f3a8d7325f714792a670a348f6 (diff)
Goniec support
Diffstat (limited to 'playoff.py')
-rw-r--r--playoff.py26
1 files changed, 21 insertions, 5 deletions
diff --git a/playoff.py b/playoff.py
index c159402..ec0bb37 100644
--- a/playoff.py
+++ b/playoff.py
@@ -1,4 +1,4 @@
-import json, os, shutil, sys
+import json, os, shutil, socket, sys
import mysql.connector
from datetime import datetime
from urlparse import urljoin
@@ -205,8 +205,7 @@ grid_rows = max([len(phase['matches']) for phase in settings['phases']])
grid_height = grid_rows * (settings['page']['height'] + settings['page']['margin']) - settings['page']['margin']
grid_width = grid_columns * (settings['page']['width'] + settings['page']['margin']) - settings['page']['margin']
-output = open(settings['output'], 'w')
-output.write((
+content = (
p_temp.PAGE % (
p_temp.PAGE_HEAD % (
p_temp.PAGE_HEAD_REFRESH % (settings['page']['refresh']) if settings['page']['refresh'] > 0 else '',
@@ -219,7 +218,24 @@ output.write((
p_temp.PAGE_BODY_FOOTER.decode('utf8') % (datetime.now().strftime('%Y-%m-%d o %H:%M'))
)
)).encode('utf8')
-)
+
+output = open(settings['output'], 'w')
+output.write(content)
+output.close()
+
+output_path = os.path.dirname(settings['output'])
+script_output_path = os.path.join(output_path, 'sklady/playoff.js')
shutil.copy(unicode(os.path.join(os.path.dirname(__file__), 'playoff.js')),
- unicode(os.path.join(os.path.dirname(settings['output']), 'sklady/playoff.js')))
+ unicode(script_output_path))
+
+if settings['goniec']['enabled']:
+ try:
+ content_lines = [(output_path.strip('/') + '/').replace('/', '\\')] + [os.path.basename(settings['output']), 'sklady/playoff.js'] + ['bye', '']
+ print '\n'.join(content_lines)
+ goniec = socket.socket()
+ goniec.connect((settings['goniec']['host'], settings['goniec']['port']))
+ goniec.sendall('\n'.join(content_lines))
+ goniec.close()
+ except socket.error:
+ pass