Store history in tmpfile at startup when retrieving profile directory location
[oscopy.git] / ioscopy_app.sh
blob204b55d225a1c90c65002a546047da2f54a5fff8
1 #!/bin/sh
2 #-*-Shell-*-
4 IPYTHON=ipython
5 IOSCOPY=ioscopy
6 PYTHON=python
7 IOCFG=--IOscopyConfig
8 REPS="'-b': '$IOCFG.b=True $IOCFG.f=',\
9 '-i': '$IOCFG.i=True',\
10 '-h': '$IOCFG.h=True',\
11 '-H': '-h',\
12 '-q': '--no-banner --IOscopyConfig.quiet=True'"
14 getprofd () {
15 tmpf=tmpfile
16 profd=`$IPYTHON --quick --profile=$IOSCOPY --no-banner --quiet --no-confirm-exit --classic --HistoryManager.hist_file=$tmpf<< EOF| grep /
17 ip=get_ipython()
18 print "\n" + ip.profile_dir.location + "\n"
19 EOF`;
20 rm $tmpf
23 $IPYTHON profile list --log-level=40 | grep $IOSCOPY > /dev/null
24 if [ $? -ne 0 ]; then
25 echo IPython $IOSCOPY profile not found, creating it.
26 $IPYTHON profile create $IOSCOPY
27 getprofd
28 cp @datarootdir@/oscopy/ipython_config.py $profd
29 else
30 getprofd
31 if [ ! -f "$profd/ipython_config.py" ]; then
32 echo IPython $IOSCOPY profile file not found, copying it.
33 cp @datarootdir@/oscopy/ipython_config.py $profd
34 elif [ "$profd/ipython_config.py" -ot "@datarootdir@/oscopy/ipython_config.py" ]; then
35 echo
36 upd=0
37 read -p "IPython $IOSCOPY profile file is outdated, update [N/y] ? " upd
38 echo
39 if [ "$upd" = "Y" -o "$upd" = "y" ] ; then
40 echo Updating IPython $IOSCOPY profile.
41 echo
42 cp @datarootdir@/oscopy/ipython_config.py $profd
43 else
44 echo "skipping profile update."
45 echo
50 # Replace short args with their equivalent, and delete space between = and
51 # file name when needed
52 args=`$PYTHON <<EOF
53 reps={$REPS}
54 argout=[reps.get(s, s) for s in "$*".split()]
55 print " ".join(argout).replace(".f= ", ".f=")
56 EOF`
57 #echo ///// $args +++++++++++++++++++++++
58 $IPYTHON --profile=$IOSCOPY $args