changeset 66:a8bb3b4c208f

misc
author Henry S. Thompson <ht@inf.ed.ac.uk>
date Fri, 24 Apr 2020 20:01:35 +0100
parents e71aeb3355ff
children ecdbaa11b88e
files .hgignore .local/bin/chardetect .local/bin/hst
diffstat 3 files changed, 109 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore	Fri Apr 24 20:01:35 2020 +0100
@@ -0,0 +1,50 @@
+.cpan
+~$
+.cache
+.bash_history
+.local/bin/pip
+.local/lib/python
+.mozilla
+.ssh
+.parallel
+.python_history
+.dbus
+.gnupg/pubring.gpg .gnupg/secring.gpg .gnupg/trustdb.gpg
+lib/perl5
+src/usr/lib/python3.6
+src/apache*
+cld2
+home
+usr
+stat
+crawler-commons
+KEYS
+language-detection-cld2
+OpenJDK*
+.mg
+.m2
+bin/abut
+bin/anova
+bin/colex
+bin/contab
+bin/desc
+bin/dprime
+bin/dsort
+bin/features
+bin/fpack
+bin/linex
+bin/maketrix
+bin/oneway
+bin/pair
+bin/probdist
+bin/rankind
+bin/rankrel
+bin/ranksort
+bin/regress
+bin/repeat
+bin/reverse
+bin/series
+good
+bin/transpose
+bin/ts
+bin/validata
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.local/bin/chardetect	Fri Apr 24 20:01:35 2020 +0100
@@ -0,0 +1,8 @@
+#!/lustre/sw/miniconda3/bin/python
+# -*- coding: utf-8 -*-
+import re
+import sys
+from chardet.cli.chardetect import main
+if __name__ == '__main__':
+    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
+    sys.exit(main())
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/.local/bin/hst	Fri Apr 24 20:01:35 2020 +0100
@@ -0,0 +1,51 @@
+#!/bin/sh
+pipe=0
+
+for i in "$@"
+do
+case $i in
+    -p|--pipe-output)
+    pipe=1
+    ;;
+esac
+done
+
+
+f="/tmp/$$-command.hst"
+# we install via pip so the python we use is, resolve $SOURCE until the file is no longer a symlink
+# so one can symlink to /usr/local/bin etc...
+# stolen from https://github.com/facebook/PathPicker/blob/master/fpp
+SOURCE=$0
+# resolve $SOURCE until the file is no longer a symlink
+while [ -h "$SOURCE" ]; do
+  BASEDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
+  SOURCE="$(readlink "$SOURCE")"
+  # if $SOURCE was a relative symlink, we need to resolve it relative to
+  # the path where the symlink file was located
+  [[ $SOURCE != /* ]] && SOURCE="$BASEDIR/$SOURCE"
+done
+BASEDIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
+PYTHON=`which python`
+# hstpy="$($PYTHON -c 'from hst import hst; print hst.__file__.replace(".pyc", ".py")' 2>/dev/null)"
+# if [ $? -ne 0 ]; then
+#   # pass
+#   PYTHON="$BASEDIR/python"
+#   hstpy="$($PYTHON -c 'from hst import hst; print hst.__file__.replace(".pyc", ".py")' 2>/dev/null)"
+#   if [ $? -ne 0 ]; then
+#     PYTHON="/usr/bin/python"
+#     hstpy="$($PYTHON -c 'from hst import hst; print hst.__file__.replace(".pyc", ".py")' 2>/dev/null)"
+#   fi
+# fi
+
+
+$PYTHON -m hst.hst --out=$f "$@" 3>&1 1>&2
+
+if [[ $? != 0 ]]; then exit $?; fi
+if [ -f "$f" ]
+then
+    if [[ $pipe == "1" ]]; then
+      cat $f
+    else
+      $SHELL -i $f < /dev/tty
+    fi
+fi
\ No newline at end of file