diff options
Diffstat (limited to 'beinc_server.py')
| -rwxr-xr-x | beinc_server.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/beinc_server.py b/beinc_server.py index 113856f..3d9ff35 100755 --- a/beinc_server.py +++ b/beinc_server.py | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #!/usr/bin/env python3 | 1 | #!/usr/bin/env python |
| 2 | # -*- coding: utf-8 -*- | 2 | # -*- coding: utf-8 -*- |
| 3 | 3 | ||
| 4 | # Blackmore's Enhanced IRC-Notification Collection (BEINC) v3.0 | 4 | # Blackmore's Enhanced IRC-Notification Collection (BEINC) v3.0 |
| @@ -22,7 +22,6 @@ import argparse | |||
| 22 | import cgi | 22 | import cgi |
| 23 | import errno | 23 | import errno |
| 24 | import getpass | 24 | import getpass |
| 25 | import http.server | ||
| 26 | import json | 25 | import json |
| 27 | import logging | 26 | import logging |
| 28 | import os | 27 | import os |
| @@ -32,8 +31,19 @@ import sys | |||
| 32 | from functools import wraps | 31 | from functools import wraps |
| 33 | from logging.config import fileConfig | 32 | from logging.config import fileConfig |
| 34 | 33 | ||
| 34 | PY2 = sys.version_info[0] == 2 | ||
| 35 | PY3 = sys.version_info[0] == 3 | ||
| 36 | |||
| 37 | if PY3: | ||
| 38 | from http.server import BaseHTTPRequestHandler, HTTPServer | ||
| 39 | else: | ||
| 40 | from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer | ||
| 41 | |||
| 35 | try: | 42 | try: |
| 36 | import notify2 as pynotify | 43 | if PY3: |
| 44 | import notify2 as pynotify | ||
| 45 | else: | ||
| 46 | import pynotify | ||
| 37 | except ImportError as e: | 47 | except ImportError as e: |
| 38 | pynotify = None | 48 | pynotify = None |
| 39 | 49 | ||
| @@ -182,7 +192,7 @@ class BEINCInstance(object): | |||
| 182 | self.__message_queue.append({'title': title, 'message': message}) | 192 | self.__message_queue.append({'title': title, 'message': message}) |
| 183 | 193 | ||
| 184 | 194 | ||
| 185 | class BEINCCustomHandler(http.server.BaseHTTPRequestHandler): | 195 | class BEINCCustomHandler(BaseHTTPRequestHandler): |
| 186 | """ | 196 | """ |
| 187 | """ | 197 | """ |
| 188 | def do_POST(self): | 198 | def do_POST(self): |
| @@ -288,7 +298,7 @@ class BEINCCustomHandler(http.server.BaseHTTPRequestHandler): | |||
| 288 | indent=4).encode('utf-8')) | 298 | indent=4).encode('utf-8')) |
| 289 | 299 | ||
| 290 | 300 | ||
| 291 | class BEINCNotifyServer(http.server.HTTPServer): | 301 | class BEINCNotifyServer(HTTPServer): |
| 292 | """ | 302 | """ |
| 293 | """ | 303 | """ |
| 294 | def set_config(self, config): | 304 | def set_config(self, config): |
