From af00bb75623e931c4de1b05db337c71a368aab22 Mon Sep 17 00:00:00 2001 From: Sam Whited Date: Sat, 4 Jul 2015 13:28:52 -0500 Subject: [PATCH] Add Python 2 support Add requirements file for reproducible builds --- __init__.py | 1 + plugins/__init__.py | 1 + plugins/__init__.pyc | Bin 0 -> 145 bytes requirements.txt | 3 +++ server.py | 14 ++++++++++---- 5 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 __init__.py create mode 100644 plugins/__init__.pyc create mode 100644 requirements.txt diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..58a3fff --- /dev/null +++ b/__init__.py @@ -0,0 +1 @@ +# Make Python 2 happy diff --git a/plugins/__init__.py b/plugins/__init__.py index e69de29..58a3fff 100644 --- a/plugins/__init__.py +++ b/plugins/__init__.py @@ -0,0 +1 @@ +# Make Python 2 happy diff --git a/plugins/__init__.pyc b/plugins/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b0a19f373c5583a7a776f377d0160a6d59ee3851 GIT binary patch literal 145 zcmZSn%*(~7G9xsZ0SXv_v;z literal 0 HcmV?d00001 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7364b33 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +PyYAML==3.11 +sleekxmpp==1.3.1 +wheel==0.24.0 diff --git a/server.py b/server.py index b119dbd..50069aa 100644 --- a/server.py +++ b/server.py @@ -9,8 +9,14 @@ import random import os from threading import Thread from threading import Lock -from http.server import HTTPServer, BaseHTTPRequestHandler -from socketserver import ThreadingMixIn +try: + # Python 3 + from http.server import HTTPServer, BaseHTTPRequestHandler + from socketserver import ThreadingMixIn +except ImportError: + # Python 2 + from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler + from SocketServer import ThreadingMixIn import sleekxmpp from sleekxmpp.componentxmpp import ComponentXMPP @@ -142,12 +148,12 @@ class HttpHandler(BaseHTTPRequestHandler): class ThreadedHTTPServer(ThreadingMixIn, HTTPServer): """Handle requests in a separate thread.""" - + if __name__ == "__main__": global files global files_lock global config - + with open('config.yml','r') as ymlfile: config = yaml.load(ymlfile)