From d40fe8284cf59d6dffbcc67b49ce77e9ccd25286 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Thu, 28 Mar 2013 20:59:57 -0400 Subject: [PATCH 1/6] added basic python helper (http server, smtp server, py[co] cleaner and a django helper for the test runner --- django/django.load | 13 +++++++++++++ plugins/python/python.load | 39 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 django/django.load diff --git a/django/django.load b/django/django.load new file mode 100644 index 0000000..d131954 --- /dev/null +++ b/django/django.load @@ -0,0 +1,13 @@ +# time, cleanup pyc and running test, settings as first argument +# e.g. djtest settings_dev +function djtest + if test -n $argv + set SETTINGS = $argv[0] + else + set SETTINGS = false + end + + set VERBOSE --verbosity=1 + find . -name "*.pyc" -delete + time python manage.py test $VERBOSE --settings=$SETTINGS +end diff --git a/plugins/python/python.load b/plugins/python/python.load index 64159fa..9247b02 100644 --- a/plugins/python/python.load +++ b/plugins/python/python.load @@ -1,3 +1,42 @@ if test -d /usr/local/share/python set PATH /usr/local/share/python $PATH end + + +# clean current directory recursively from any .pyc and .pyo files +function pyclean + if test -n $argv + set path2CLEAN $argv + else + set path2CLEAN . + end + + find $path2CLEAN -name "*.pyc" -delete -o -name "*.pyo" -delete + end + +# start smtp debugging server, can pass an option port parameter. Default to 1025 +function pysmtp + if test -n "$argv" + set SMTPPORT $argv + else + set SMTPPORT 1025 + end + python -m smtpd -n -c DebuggingServer localhost:$SMTPPORT; +end + + +# beautify json string +# use : pybeautifyjson '{"foo": "lorem", "bar": "ipsum"}' +function pybeautifyjson + echo $argv | python -mjson.tool +end + +# start in-place a simple http server, take a optional parameter for the port number +function pyhttp + if test -n "$argv" + set HTTPPORT $argv + else + set HTTPPORT 1025 + end + python -m SimpleHTTPServer $HTTPPORT; +end From 02a8a6642468dfddf17397c0163606543e2d5d03 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 21 May 2013 17:42:17 -0400 Subject: [PATCH 2/6] split command in different files --- plugins/python/pybeautifyjson.fish | 6 +++++ plugins/python/pyclean.fish | 10 ++++++++ plugins/python/pyhttp.fish | 9 +++++++ plugins/python/pysmtp.fish | 10 ++++++++ plugins/python/python.load | 38 ------------------------------ 5 files changed, 35 insertions(+), 38 deletions(-) create mode 100644 plugins/python/pybeautifyjson.fish create mode 100644 plugins/python/pyclean.fish create mode 100644 plugins/python/pyhttp.fish create mode 100644 plugins/python/pysmtp.fish diff --git a/plugins/python/pybeautifyjson.fish b/plugins/python/pybeautifyjson.fish new file mode 100644 index 0000000..0bf6c9f --- /dev/null +++ b/plugins/python/pybeautifyjson.fish @@ -0,0 +1,6 @@ +# beautify json string +# use : pybeautifyjson '{"foo": "lorem", "bar": "ipsum"}' +function pybeautifyjson + echo $argv | python -mjson.tool +end + diff --git a/plugins/python/pyclean.fish b/plugins/python/pyclean.fish new file mode 100644 index 0000000..9d5e6cd --- /dev/null +++ b/plugins/python/pyclean.fish @@ -0,0 +1,10 @@ +# clean current directory recursively from any .pyc and .pyo files +function pyclean + if test -n $argv + set path2CLEAN $argv + else + set path2CLEAN . + end + + find $path2CLEAN -name "*.pyc" -delete -o -name "*.pyo" -delete + end \ No newline at end of file diff --git a/plugins/python/pyhttp.fish b/plugins/python/pyhttp.fish new file mode 100644 index 0000000..b95536e --- /dev/null +++ b/plugins/python/pyhttp.fish @@ -0,0 +1,9 @@ +# start in-place a simple http server, take a optional parameter for the port number +function pyhttp + if test -n "$argv" + set HTTPPORT $argv + else + set HTTPPORT 1025 + end + python -m SimpleHTTPServer $HTTPPORT; +end diff --git a/plugins/python/pysmtp.fish b/plugins/python/pysmtp.fish new file mode 100644 index 0000000..d248f86 --- /dev/null +++ b/plugins/python/pysmtp.fish @@ -0,0 +1,10 @@ +# start smtp debugging server, can pass an option port parameter. Default to 1025 +function pysmtp + if test -n "$argv" + set SMTPPORT $argv + else + set SMTPPORT 1025 + end + echo "smtp server started on port" $SMTPPORT; + python -m smtpd -n -c DebuggingServer localhost:$SMTPPORT; +end diff --git a/plugins/python/python.load b/plugins/python/python.load index 9247b02..7f2bbc2 100644 --- a/plugins/python/python.load +++ b/plugins/python/python.load @@ -2,41 +2,3 @@ if test -d /usr/local/share/python set PATH /usr/local/share/python $PATH end - -# clean current directory recursively from any .pyc and .pyo files -function pyclean - if test -n $argv - set path2CLEAN $argv - else - set path2CLEAN . - end - - find $path2CLEAN -name "*.pyc" -delete -o -name "*.pyo" -delete - end - -# start smtp debugging server, can pass an option port parameter. Default to 1025 -function pysmtp - if test -n "$argv" - set SMTPPORT $argv - else - set SMTPPORT 1025 - end - python -m smtpd -n -c DebuggingServer localhost:$SMTPPORT; -end - - -# beautify json string -# use : pybeautifyjson '{"foo": "lorem", "bar": "ipsum"}' -function pybeautifyjson - echo $argv | python -mjson.tool -end - -# start in-place a simple http server, take a optional parameter for the port number -function pyhttp - if test -n "$argv" - set HTTPPORT $argv - else - set HTTPPORT 1025 - end - python -m SimpleHTTPServer $HTTPPORT; -end From db0eda65bccd339379f4ed479e8dd4e34d40560b Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 21 May 2013 18:03:03 -0400 Subject: [PATCH 3/6] replaced 4 spaces tabs for 2 spaces tab --- plugins/python/pybeautifyjson.fish | 5 ++--- plugins/python/pyclean.fish | 14 +++++++------- plugins/python/pyhttp.fish | 12 ++++++------ plugins/python/pysmtp.fish | 14 +++++++------- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/plugins/python/pybeautifyjson.fish b/plugins/python/pybeautifyjson.fish index 0bf6c9f..ab2d9ca 100644 --- a/plugins/python/pybeautifyjson.fish +++ b/plugins/python/pybeautifyjson.fish @@ -1,6 +1,5 @@ # beautify json string # use : pybeautifyjson '{"foo": "lorem", "bar": "ipsum"}' function pybeautifyjson - echo $argv | python -mjson.tool -end - + echo $argv | python -mjson.tool +end \ No newline at end of file diff --git a/plugins/python/pyclean.fish b/plugins/python/pyclean.fish index 9d5e6cd..edceb0f 100644 --- a/plugins/python/pyclean.fish +++ b/plugins/python/pyclean.fish @@ -1,10 +1,10 @@ # clean current directory recursively from any .pyc and .pyo files function pyclean - if test -n $argv - set path2CLEAN $argv - else - set path2CLEAN . - end + if test -n $argv + set path2CLEAN $argv + else + set path2CLEAN . + end - find $path2CLEAN -name "*.pyc" -delete -o -name "*.pyo" -delete - end \ No newline at end of file + find $path2CLEAN -name "*.pyc" -delete -o -name "*.pyo" -delete +end \ No newline at end of file diff --git a/plugins/python/pyhttp.fish b/plugins/python/pyhttp.fish index b95536e..06c6c8b 100644 --- a/plugins/python/pyhttp.fish +++ b/plugins/python/pyhttp.fish @@ -1,9 +1,9 @@ # start in-place a simple http server, take a optional parameter for the port number function pyhttp - if test -n "$argv" - set HTTPPORT $argv - else - set HTTPPORT 1025 - end - python -m SimpleHTTPServer $HTTPPORT; + if test -n "$argv" + set HTTPPORT $argv + else + set HTTPPORT 1025 + end + python -m SimpleHTTPServer $HTTPPORT; end diff --git a/plugins/python/pysmtp.fish b/plugins/python/pysmtp.fish index d248f86..3872f48 100644 --- a/plugins/python/pysmtp.fish +++ b/plugins/python/pysmtp.fish @@ -1,10 +1,10 @@ # start smtp debugging server, can pass an option port parameter. Default to 1025 function pysmtp - if test -n "$argv" - set SMTPPORT $argv - else - set SMTPPORT 1025 - end - echo "smtp server started on port" $SMTPPORT; - python -m smtpd -n -c DebuggingServer localhost:$SMTPPORT; + if test -n "$argv" + set SMTPPORT $argv + else + set SMTPPORT 1025 + end + echo "smtp server started on port" $SMTPPORT; + python -m smtpd -n -c DebuggingServer localhost:$SMTPPORT; end From 089034b6c6c4aa1dead43af2c71d7611004e904d Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Tue, 21 May 2013 18:18:05 -0400 Subject: [PATCH 4/6] moved django into plugins, moved djtest into its own file --- django/django.load | 13 ------------- plugins/django/django.load | 0 plugins/django/djtest.fish | 13 +++++++++++++ 3 files changed, 13 insertions(+), 13 deletions(-) delete mode 100644 django/django.load create mode 100644 plugins/django/django.load create mode 100644 plugins/django/djtest.fish diff --git a/django/django.load b/django/django.load deleted file mode 100644 index d131954..0000000 --- a/django/django.load +++ /dev/null @@ -1,13 +0,0 @@ -# time, cleanup pyc and running test, settings as first argument -# e.g. djtest settings_dev -function djtest - if test -n $argv - set SETTINGS = $argv[0] - else - set SETTINGS = false - end - - set VERBOSE --verbosity=1 - find . -name "*.pyc" -delete - time python manage.py test $VERBOSE --settings=$SETTINGS -end diff --git a/plugins/django/django.load b/plugins/django/django.load new file mode 100644 index 0000000..e69de29 diff --git a/plugins/django/djtest.fish b/plugins/django/djtest.fish new file mode 100644 index 0000000..9726130 --- /dev/null +++ b/plugins/django/djtest.fish @@ -0,0 +1,13 @@ +# time, cleanup pyc and running test, settings as first argument +# e.g. djtest settings_dev +function djtest + set VERBOSE --verbosity=1 + find . -name "*.pyc" -delete + + if set -q argv + time python manage.py test $VERBOSE --settings=$argv + else + time python manage.py test $VERBOSE + end + +end From 1cf57f83f960462e27d35d59ae09dbb00b257612 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Wed, 22 May 2013 12:07:16 -0400 Subject: [PATCH 5/6] removed empty django.load file --- plugins/django/django.load | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 plugins/django/django.load diff --git a/plugins/django/django.load b/plugins/django/django.load deleted file mode 100644 index e69de29..0000000 From 2a7ff8c2557afd938c177a0f995ee873b3aaf526 Mon Sep 17 00:00:00 2001 From: Francis Lavoie Date: Wed, 22 May 2013 12:17:01 -0400 Subject: [PATCH 6/6] simplified pyclean command --- plugins/python/pyclean.fish | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/python/pyclean.fish b/plugins/python/pyclean.fish index edceb0f..3b5475a 100644 --- a/plugins/python/pyclean.fish +++ b/plugins/python/pyclean.fish @@ -6,5 +6,5 @@ function pyclean set path2CLEAN . end - find $path2CLEAN -name "*.pyc" -delete -o -name "*.pyo" -delete + find $path2CLEAN -name "*.py[co]" -type f -delete end \ No newline at end of file