aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-03-25 18:38:33 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2012-03-25 18:38:33 -0700
commitfa346cec3b307c6013a252475bac532ed0698dbb (patch)
tree1904b69cf1fd92412fe5aa15d20a8a34f27e3ae8
parent0bdf7a598ac49f3cf01e4d003c4fad5984fa66bf (diff)
Moved some Python scripts into new share/tools/ directory.
Added fish_config function to launch web config
-rw-r--r--Makefile.in15
-rw-r--r--share/functions/fish_config.fish3
-rwxr-xr-xshare/tools/create_manpage_completions.py (renamed from create_manpage_completions.py)0
-rwxr-xr-xshare/tools/import_bash_settings.py (renamed from import_bash_settings.py)0
-rw-r--r--share/tools/web_config/index.html (renamed from web_config/index.html)0
-rw-r--r--share/tools/web_config/jquery.js (renamed from web_config/jquery.js)0
-rwxr-xr-xshare/tools/web_config/webconfig.py (renamed from web_config/webconfig.py)32
7 files changed, 43 insertions, 7 deletions
diff --git a/Makefile.in b/Makefile.in
index 640e8c3c..ce88be33 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -599,6 +599,8 @@ install-force: all install-translations
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/completions
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/functions
$(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/man
+ $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools
+ $(INSTALL) -m 755 -d $(DESTDIR)$(datadir)/fish/tools/web_config
$(INSTALL) -m 644 etc/config.fish $(DESTDIR)$(sysconfdir)/fish/
$(INSTALL) -m 644 share/config.fish $(DESTDIR)$(datadir)/fish/
for i in $(COMPLETIONS_DIR_FILES); do \
@@ -613,6 +615,19 @@ install-force: all install-translations
$(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/man/; \
true; \
done;
+ for i in share/tools/*.py; do\
+ $(INSTALL) -m 755 $$i $(DESTDIR)$(datadir)/fish/tools/; \
+ true; \
+ done;
+ for i in share/tools/web_config/*; do\
+ $(INSTALL) -m 644 $$i $(DESTDIR)$(datadir)/fish/tools/web_config/; \
+ true; \
+ done;
+ for i in share/tools/web_config/*.py; do\
+ $(INSTALL) -m 755 $$i $(DESTDIR)$(datadir)/fish/tools/web_config/; \
+ true; \
+ done;
+
$(INSTALL) -m 755 -d $(DESTDIR)$(docdir)
for i in user_doc/html/* ChangeLog; do \
if test -f $$i; then \
diff --git a/share/functions/fish_config.fish b/share/functions/fish_config.fish
new file mode 100644
index 00000000..de59d834
--- /dev/null
+++ b/share/functions/fish_config.fish
@@ -0,0 +1,3 @@
+function fish_config --description "Launch fish's web based configuration"
+ eval $__fish_datadir/tools/web_config/webconfig.py
+end
diff --git a/create_manpage_completions.py b/share/tools/create_manpage_completions.py
index e019ea4d..e019ea4d 100755
--- a/create_manpage_completions.py
+++ b/share/tools/create_manpage_completions.py
diff --git a/import_bash_settings.py b/share/tools/import_bash_settings.py
index 4c587254..4c587254 100755
--- a/import_bash_settings.py
+++ b/share/tools/import_bash_settings.py
diff --git a/web_config/index.html b/share/tools/web_config/index.html
index 4ab8a03c..4ab8a03c 100644
--- a/web_config/index.html
+++ b/share/tools/web_config/index.html
diff --git a/web_config/jquery.js b/share/tools/web_config/jquery.js
index 8ccd0ea7..8ccd0ea7 100644
--- a/web_config/jquery.js
+++ b/share/tools/web_config/jquery.js
diff --git a/web_config/webconfig.py b/share/tools/web_config/webconfig.py
index 59a05da6..c0f1aaf7 100755
--- a/web_config/webconfig.py
+++ b/share/tools/web_config/webconfig.py
@@ -4,7 +4,7 @@ import SimpleHTTPServer
import SocketServer
import webbrowser
import subprocess
-import re, json, socket, sys, cgi
+import re, json, socket, os, sys, cgi, select
def run_fish_cmd(text):
from subprocess import PIPE
@@ -93,7 +93,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
for match in re.finditer(r"^fish_color_(\S+) ?(.*)", line):
color_name, color_value = match.group(1, 2)
result.append([color_name.strip(), parse_color(color_value)])
- print result
return result
def do_get_functions(self):
@@ -200,7 +199,6 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
background_color = postvars.get('background_color')
bold = postvars.get('bold')
underline = postvars.get('underline')
- print "underline: ", underline
if what:
# Not sure why we get lists here?
output = self.do_set_color_for_variable(what[0], color[0], background_color[0], parse_bool(bold[0]), parse_bool(underline[0]))
@@ -220,7 +218,16 @@ class FishConfigHTTPRequestHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
# Output JSON
json.dump(output, self.wfile)
+ def log_request(self, code='-', size='-'):
+ """ Disable request logging """
+ pass
+# Make sure that the working directory is the one that contains the script server file,
+# because the document root is the working directory
+where = os.path.dirname(sys.argv[0])
+os.chdir(where)
+
+# Try to find a suitable port
PORT = 8000
while PORT <= 9000:
try:
@@ -235,11 +242,22 @@ while PORT <= 9000:
PORT += 1
if PORT > 9000:
- print "Unable to start a web server"
+ # Nobody say it
+ print "Unable to find an open port between 8000 and 9000"
sys.exit(-1)
-webbrowser.open("http://localhost:%d" % PORT)
+url = 'http://localhost:%d' % PORT
+
+print "Web config started at '%s'. Hit enter to stop." % url
+webbrowser.open(url)
-print "serving at port", PORT
-httpd.serve_forever()
+# Select on stdin and httpd
+stdin_no = sys.stdin.fileno()
+while True:
+ ready_read, _, _ = select.select([sys.stdin.fileno(), httpd.fileno()], [], [])
+ if stdin_no in ready_read:
+ print "Shutting down."
+ break
+ else:
+ httpd.handle_request()