From: Chris Porter Date: Sat, 31 Jan 2009 23:27:10 +0000 (+0000) Subject: Replace {compile,run}.{bat,sh} with {compile,run}.py. X-Git-Url: https://jfr.im/git/irc/quakenet/qwebirc.git/commitdiff_plain/8b8ebb7815316b0a71e6169f40f4acf3876bab98?ds=sidebyside;hp=85f01e3fae00ffbf96f810bf047ec051fe126d70 Replace {compile,run}.{bat,sh} with {compile,run}.py. --- diff --git a/compile.bat b/compile.bat deleted file mode 100644 index cb98e8c..0000000 --- a/compile.bat +++ /dev/null @@ -1,51 +0,0 @@ -@echo off - -pagegen.py -mkdir compiled -del /q compiled\*.js - -cd js -copy qwebirc.js + version.js + jslib.js + crypto.js + md5.js + irc\ircconnection.js + irc\irclib.js + irc\numerics.js + irc\baseircclient.js + irc\irctracker.js + irc\commandparser.js + irc\commands.js + irc\ircclient.js + ui\baseui.js + ui\baseuiwindow.js + ui\colour.js + ui\url.js + ui\theme.js + ui\panes\connect.js + ui\panes\embed.js + qwebircinterface.js + irc\commandhistory.js + ui\hilightcontroller.js + ui\menuitems.js + ui\tabcompleter.js + ui\panes\options.js + ui\panes\about.js + auth.js + sound.js + ui\panes\privacypolicy.js + ui\panes\feedback.js ..\compiled\qwebirc-concat.js /b -copy ui\frontends\swmui.js + ui\frontends\swmlayout.js ..\compiled\swmui-concat.js /b -cd ..\compiled - -java -jar ..\bin\yuicompressor-2.3.5.jar ..\static\js\mochaui\mocha.js > mocha-compressed.js -if not %errorlevel% == 0 goto error - -java -jar ..\bin\yuicompressor-2.3.5.jar qwebirc-concat.js > qwebirc-compiled.js -if not %errorlevel% == 0 goto error - -java -jar ..\bin\yuicompressor-2.3.5.jar ..\js\ui\frontends\uglyui.js > uglyui-compiled.js -if not %errorlevel% == 0 goto error - -java -jar ..\bin\yuicompressor-2.3.5.jar swmui-concat.js > swmui-compiled.js -if not %errorlevel% == 0 goto error - -java -jar ..\bin\yuicompressor-2.3.5.jar ..\js\ui\frontends\mochaui.js > mochaui-compiled.js -if not %errorlevel% == 0 goto error - -java -jar ..\bin\yuicompressor-2.3.5.jar ..\js\ui\frontends\qui.js > qui-compiled.js -if not %errorlevel% == 0 goto error - -goto ok -:error -cd .. -del /q compiled\*-compiled.js -pause -goto end - -:ok -cd .. -copy compiled\mocha-compressed.js /b static\js\mochaui\mocha-compressed.js - -copy js\copyright.js + compiled\qwebirc-compiled.js /b static\js\qwebirc.js -copy js\copyright.js + compiled\uglyui-compiled.js /b static\js\uglyui.js -copy js\copyright.js + compiled\swmui-compiled.js /b static\js\swmui.js -copy js\copyright.js + compiled\mochaui-compiled.js /b static\js\mochaui.js -copy js\copyright.js + compiled\qui-compiled.js /b static\js\qui.js -del /q compiled\*.js -rmdir compiled - -goto end - -:end diff --git a/compile.py b/compile.py new file mode 100644 index 0000000..8a61953 --- /dev/null +++ b/compile.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +import pagegen, os, subprocess + +def jarit(src): + return subprocess.Popen(["java", "-jar", "bin/yuicompressor-2.3.5.jar", src], stdout=subprocess.PIPE).communicate()[0] + +def jmerge_files(output, files, *args): + global copyright + output = output + ".js" + o = os.path.join("compiled", output) + merge_files(o, files, *args) + compiled = jarit(o) + os.unlink(o) + f = open(os.path.join("static", "js", output), "wb") + f.write(copyright) + f.write(compiled) + f.close() + +def merge_files(output, files, root_path=lambda x: x): + f = open(output, "wb") + + for x in files: + f2 = open(root_path(x), "rb") + f.write(f2.read()) + f2.close() + f.close() + +def compile(): + pagegen.main() + + try: + os.mkdir("compiled") + except: + pass + + copyright = open("js/copyright.js", "rb").read() + + jmerge_files("qwebirc", pagegen.DEBUG_BASE, lambda x: os.path.join("js", x + ".js")) + + for uiname, value in pagegen.UIs.items(): + jmerge_files(uiname, value["uifiles"], lambda x: os.path.join("js", "ui", "frontends", x + ".js")) + + os.rmdir("compiled") + +if __name__ == "__main__": + compile() + \ No newline at end of file diff --git a/compile.sh b/compile.sh deleted file mode 100755 index 934bb09..0000000 --- a/compile.sh +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -python pagegen.py - -mkdir -p compiled -rm -f compiled/*.js - -cd js -cat qwebirc.js version.js jslib.js crypto.js md5.js irc/ircconnection.js irc/irclib.js irc/numerics.js irc/baseircclient.js irc/irctracker.js irc/commandparser.js irc/commands.js irc/ircclient.js ui/baseui.js ui/baseuiwindow.js ui/colour.js ui/url.js ui/theme.js ui/panes/connect.js ui/panes/embed.js irc/commandhistory.js ui/hilightcontroller.js ui/menuitems.js ui/tabcompleter.js ui/panes/options.js ui/panes/about.js qwebircinterface.js auth.js sound.js ui/panes/privacypolicy.js ui/panes/feedback.js > ../compiled/qwebirc-concat.js -cat ui/frontends/swmui.js ui/frontends/swmlayout.js > ../compiled/swmui-concat.js - -error() { - cd .. - rm compiled/*-compiled.js - exit 1 -} - -catit() { - cat js/copyright.js compiled/$1-compiled.js > static/js/$1.js -} - -xjarit() { - local SRC=$1 - local DST=$2 - cd compiled - java -jar ../bin/yuicompressor-2.3.5.jar $SRC.js > $DST.js - if [ "$?" != 0 ]; then - error - fi - cd .. -} - -jarit() { - SRC=$1 - DST=$2 - - xjarit $SRC $DST-compiled - catit $DST - rm compiled/$DST-compiled.js -} - -cd .. -xjarit ../static/js/mochaui/mocha ../static/js/mochaui/mocha-compressed - -jarit qwebirc-concat qwebirc -jarit ../js/ui/frontends/uglyui uglyui -jarit swmui-concat swmui -jarit ../js/ui/frontends/mochaui mochaui -jarit ../js/ui/frontends/qui qui - -rm compiled/{swmui,qwebirc}-concat.js - -rmdir compiled diff --git a/pagegen.py b/pagegen.py index 0745c2e..ba90119 100644 --- a/pagegen.py +++ b/pagegen.py @@ -11,7 +11,6 @@ UIs = { "qui": { "class": "QUI", "uifiles": ["qui"], - "extra": ["mootools-1.2-more"], "doctype": "" }, @@ -40,7 +39,7 @@ UIs = { }, "swmui": { "class": "SWMUI", - "uifiles": ["swmui", "swmuilayout"], + "uifiles": ["swmui", "swmlayout"], "doctype": "" }, "uglyui": { @@ -57,8 +56,9 @@ def flatten(y): yield x else: yield x - -DEBUG = ["debug/%s" % x for x in flatten(DEBUG_BASE)] + +DEBUG_BASE = list(flatten(DEBUG_BASE)) +DEBUG = ["debug/%s" % x for x in DEBUG_BASE] def jslist(name, debug): ui = UIs[name] diff --git a/run.bat b/run.bat deleted file mode 100644 index 1a46eb0..0000000 --- a/run.bat +++ /dev/null @@ -1,3 +0,0 @@ -set PYTHONPATH=.;c:\python25\lib\site-packages -c:\python25\python.exe c:\python25\scripts\twistd.py qwebirc -n -pause diff --git a/run.py b/run.py new file mode 100644 index 0000000..4430324 --- /dev/null +++ b/run.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# this entire thing is a hack +DEFAULT_PORT = 9090 + +from twisted.scripts.twistd import run +from optparse import OptionParser +import sys, os + +def run_twistd(args1=None, args2=None): + args = [sys.argv[0]] + if args1 is not None: + args.extend(args1) + args.append("qwebirc") + if args2 is not None: + args.extend(args2) + sys.argv = args + run() + +def help_reactors(*args): + run_twistd(["--help-reactors"]) + sys.exit(1) + +DEFAULT_REACTOR = "select" if os.name == "nt" else "poll" + +parser = OptionParser() +parser.add_option("-n", "--no-daemon", help="Don't run in the background.", action="store_false", dest="daemonise", default=True) +parser.add_option("--help-reactors", help="Display a list of reactor names.", action="callback", callback=help_reactors) +parser.add_option("-b", "--debug", help="Run in the Python Debugger.", action="store_true", dest="debug", default=False) +parser.add_option("-r", "--reactor", help="Which reactor to use (see --help-reactors for a list).", dest="reactor", default=DEFAULT_REACTOR) +parser.add_option("-p", "--port", help="Port to start the server on.", type="int", dest="port", default=DEFAULT_PORT) +parser.add_option("-l", "--logfile", help="Path to twisted log file.", dest="logfile") +parser.add_option("-c", "--clf", help="Path to web CLF (Combined Log Format) log file.", dest="clogfile") +(options, args) = parser.parse_args() + +args1, args2 = [], [] + +if not options.daemonise: + args1.append("-n") +if options.debug: + args1.append("-b") +args1+=["--reactor", options.reactor] +if options.logfile: + args+=["--logfile", options.logfile] + +args2+=["--port", options.port] +if options.clogfile: + args2+=["--logfile", options.clogfile] + +run_twistd(args1, args2) diff --git a/run.sh b/run.sh deleted file mode 100755 index 2aac5b1..0000000 --- a/run.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -export PYTHONPATH=.:${PYTHONPATH} - -if [ -f "defargs.conf" ]; then - ARGS=$(cat defargs.conf) -else - ARGS= -fi - -PREARGS= -if [ "$1" = "-n" ]; then - PREARGS=$1 - shift -fi - -if [ "$1" = "-r" ]; then - PREARGS="$PREARGS $1 $2" - shift - shift -fi - -if [ "$1" != "" ]; then - if [ "$ARGS" != "" ]; then - echo "Not using default arguments: $ARGS" - fi - ARGS=$* -fi - -twistd $PREARGS qwebirc -n $ARGS