]> jfr.im git - irc/quakenet/qwebirc.git/commitdiff
Replace {compile,run}.{bat,sh} with {compile,run}.py.
authorChris Porter <redacted>
Sat, 31 Jan 2009 23:27:10 +0000 (23:27 +0000)
committerChris Porter <redacted>
Sat, 31 Jan 2009 23:27:10 +0000 (23:27 +0000)
compile.bat [deleted file]
compile.py [new file with mode: 0644]
compile.sh [deleted file]
pagegen.py
run.bat [deleted file]
run.py [new file with mode: 0644]
run.sh [deleted file]

diff --git a/compile.bat b/compile.bat
deleted file mode 100644 (file)
index cb98e8c..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-@echo off\r
-\r
-pagegen.py\r
-mkdir compiled\r
-del /q compiled\*.js\r
-\r
-cd js\r
-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\r
-copy ui\frontends\swmui.js + ui\frontends\swmlayout.js ..\compiled\swmui-concat.js /b\r
-cd ..\compiled\r
-\r
-java -jar ..\bin\yuicompressor-2.3.5.jar ..\static\js\mochaui\mocha.js > mocha-compressed.js\r
-if not %errorlevel% == 0 goto error\r
-\r
-java -jar ..\bin\yuicompressor-2.3.5.jar qwebirc-concat.js > qwebirc-compiled.js\r
-if not %errorlevel% == 0 goto error\r
-\r
-java -jar ..\bin\yuicompressor-2.3.5.jar ..\js\ui\frontends\uglyui.js > uglyui-compiled.js\r
-if not %errorlevel% == 0 goto error\r
-\r
-java -jar ..\bin\yuicompressor-2.3.5.jar swmui-concat.js > swmui-compiled.js\r
-if not %errorlevel% == 0 goto error\r
-\r
-java -jar ..\bin\yuicompressor-2.3.5.jar ..\js\ui\frontends\mochaui.js > mochaui-compiled.js\r
-if not %errorlevel% == 0 goto error\r
-\r
-java -jar ..\bin\yuicompressor-2.3.5.jar ..\js\ui\frontends\qui.js > qui-compiled.js\r
-if not %errorlevel% == 0 goto error\r
-\r
-goto ok\r
-:error\r
-cd ..\r
-del /q compiled\*-compiled.js\r
-pause\r
-goto end\r
-\r
-:ok\r
-cd ..\r
-copy compiled\mocha-compressed.js /b static\js\mochaui\mocha-compressed.js\r
-\r
-copy js\copyright.js + compiled\qwebirc-compiled.js /b static\js\qwebirc.js\r
-copy js\copyright.js + compiled\uglyui-compiled.js /b static\js\uglyui.js\r
-copy js\copyright.js + compiled\swmui-compiled.js /b static\js\swmui.js\r
-copy js\copyright.js + compiled\mochaui-compiled.js /b static\js\mochaui.js\r
-copy js\copyright.js + compiled\qui-compiled.js /b static\js\qui.js\r
-del /q compiled\*.js\r
-rmdir compiled\r
-\r
-goto end\r
-\r
-:end\r
diff --git a/compile.py b/compile.py
new file mode 100644 (file)
index 0000000..8a61953
--- /dev/null
@@ -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 (executable)
index 934bb09..0000000
+++ /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
index 0745c2ebe16074064f728c1561972601822d1c84..ba901191643aa32e53a8d27a9f59b91c640c9346 100644 (file)
@@ -11,7 +11,6 @@ UIs = {
   "qui": {
     "class": "QUI",
     "uifiles": ["qui"],
-    "extra": ["mootools-1.2-more"],
     "doctype": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"" + "\n" \
       "  \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">"
   },
@@ -40,7 +39,7 @@ UIs = {
   },
   "swmui": {
     "class": "SWMUI",
-    "uifiles": ["swmui", "swmuilayout"],
+    "uifiles": ["swmui", "swmlayout"],
     "doctype": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">"
   },
   "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 (file)
index 1a46eb0..0000000
--- a/run.bat
+++ /dev/null
@@ -1,3 +0,0 @@
-set PYTHONPATH=.;c:\python25\lib\site-packages\r
-c:\python25\python.exe c:\python25\scripts\twistd.py qwebirc -n\r
-pause\r
diff --git a/run.py b/run.py
new file mode 100644 (file)
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 (executable)
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