From 624212d7a112ce4b18860e83669dca15eb24437e Mon Sep 17 00:00:00 2001 From: Falaina Date: Fri, 20 Jul 2012 20:42:51 -0400 Subject: [PATCH 1/2] Switch to relative import of settings in modules in naoko.lib. make main function in main (though naoko.main.main() is kind of silly. make a launcher external to the naoko package --- .gitignore | 1 + naoko/lib/apiclient.py | 2 +- naoko/lib/ircclient.py | 2 +- naoko/lib/sioclient.py | 2 +- naoko/main.py | 6 ++++-- 5 files changed, 8 insertions(+), 5 deletions(-) mode change 100644 => 100755 naoko/lib/apiclient.py mode change 100644 => 100755 naoko/lib/sioclient.py diff --git a/.gitignore b/.gitignore index c902cc0..3d2793d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ *.swp cbclient.py persistentsettings +build \ No newline at end of file diff --git a/naoko/lib/apiclient.py b/naoko/lib/apiclient.py old mode 100644 new mode 100755 index ff72ffa..de2790d --- a/naoko/lib/apiclient.py +++ b/naoko/lib/apiclient.py @@ -7,7 +7,7 @@ from urllib import urlencode from httplib import HTTPConnection, HTTPSConnection -from settings import * +from ..settings import * # A client for all the various APIs used by Naoko diff --git a/naoko/lib/ircclient.py b/naoko/lib/ircclient.py index 4125548..82da994 100755 --- a/naoko/lib/ircclient.py +++ b/naoko/lib/ircclient.py @@ -4,7 +4,7 @@ import socket import re -from settings import * +from ..settings import * #Basic IRC client #Built upon the instructions provided by http://wiki.shellium.org/w/Writing_an_IRC_bot_in_Python diff --git a/naoko/lib/sioclient.py b/naoko/lib/sioclient.py old mode 100644 new mode 100755 index 2050907..348cb47 --- a/naoko/lib/sioclient.py +++ b/naoko/lib/sioclient.py @@ -10,7 +10,7 @@ import threading from urllib import urlopen, urlencode -from settings import * +from ..settings import * # Implementation of WebSocket client as per draft-ietf-hybi-thewebsocketprotocol-00 # http://tools.ietf.org/html/draft-ietf-hybi-thewebsocketprotocol-00 diff --git a/naoko/main.py b/naoko/main.py index 3408a17..61608c2 100755 --- a/naoko/main.py +++ b/naoko/main.py @@ -61,10 +61,12 @@ def run(script): print "Received exception ", str(e) finally: child.terminate() - -if __name__ == '__main__': +def main(): try: while True: run(Naoko) except KeyboardInterrupt: print "\n Shutting Down" + +if __name__ == '__main__': + main() From 7b83bf8f754066ce533f4fcbfd0f3aa5713a895f Mon Sep 17 00:00:00 2001 From: Falaina Date: Fri, 20 Jul 2012 20:44:32 -0400 Subject: [PATCH 2/2] Add setup.py and support building executables --- naoko.py | 6 ++++++ setup.py | 20 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 naoko.py create mode 100644 setup.py diff --git a/naoko.py b/naoko.py new file mode 100644 index 0000000..b493baa --- /dev/null +++ b/naoko.py @@ -0,0 +1,6 @@ +import multiprocessing +import naoko.main + +if __name__ == '__main__': + multiprocessing.freeze_support() + naoko.main.main() diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..293168e --- /dev/null +++ b/setup.py @@ -0,0 +1,20 @@ +# This is only for building Windows binaries, really. If you're on OSX/Linux +# you should probably just run "python naoko.py" + +import sys, traceback +try: + from cx_Freeze import setup, Executable +except: + traceback.print_exc() + sys.stderr.write("\nBuilding a windows executable requires cx_Freeze\n") + exit(-1) + +build_exe_options = {"includes": ["hashlib", "naoko"], "packages": ["naoko", "naoko.lib"], "include_files": ["naoko.conf", "naoko.sql"]} + +setup( + name = "naoko", + version = "1.0", + description = "A Synchtube bot", + options = {"build_exe": build_exe_options}, + executables = [Executable("naoko.py", path="naoko")] +)