summaryrefslogtreecommitdiff
path: root/asciifarm/client/main.py
diff options
context:
space:
mode:
authortroido <troido@protonmail.com>2020-03-06 11:26:59 +0100
committertroido <troido@protonmail.com>2020-03-06 11:26:59 +0100
commitdd07ff4d686f07cdc9736627dd0ef099ef5e4e4f (patch)
treef43310b3779a95efd74a40ba8139cf146ad49051 /asciifarm/client/main.py
parentc9366616079240cd7ee3d243c9f6897d40b4267d (diff)
new directory structure for the separate client repo
Diffstat (limited to 'asciifarm/client/main.py')
-rw-r--r--asciifarm/client/main.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/asciifarm/client/main.py b/asciifarm/client/main.py
deleted file mode 100644
index d720477..0000000
--- a/asciifarm/client/main.py
+++ /dev/null
@@ -1,65 +0,0 @@
-#! /usr/bin/python3
-
-import json
-
-import sys
-import termios
-import tty
-import signal
-#import os
-
-from .connection import Connection
-from .gameclient import Client
-from .display import Display
-from .parseargs import parse_args
-from ratuil.screen import Screen
-
-def main(argv=None):
-
- (name, socketType, address, keybindings, characters, colours, logfile) = parse_args(argv)
-
-
- connection = Connection(socketType)
- try:
- connection.connect(address)
- except ConnectionRefusedError:
- print("ERROR: Could not connect to server.\nAre you sure that the server is running and that you're connecting to the right address?", file=sys.stderr)
- return
-
- error = None
- closeMessage = None
-
- #os.environ.setdefault("ESCDELAY", "25")
-
- fd = sys.stdin.fileno()
- oldterm = termios.tcgetattr(fd)
-
- try:
-
- tty.setraw(sys.stdin)
- Screen.default.hide_cursor()
-
- display = Display(characters)
- client = Client(display, name, connection, keybindings, logfile)
- signal.signal(signal.SIGWINCH, client.onSigwinch)
- try:
- client.start()
- except KeyboardInterrupt:
- client.close("^C caught, goodbye")
- except Exception as e:
- # throw the execption outside ncurses
- # so the cleanup can happen first
- error = e
- closeMessage = client.closeMessage
- finally:
- ## Set everything back to normal
- termios.tcsetattr(fd, termios.TCSADRAIN, oldterm)
- Screen.default.finalize()
-
-
- if error is not None:
- raise error
-
- if closeMessage:
- print(closeMessage, file=sys.stderr)
-