The script ~/.ipython/profile_spockdoor/startup/00-start.py
is
executed at startup of each spock session. This is an example:
#!/usr/bin/env python # # file name ~/.ipython/profile_spockdoor/startup/00-start.py # import os, time, atexit, sys import HasyUtils import HasyUtils.pooltools import PyTango # # make sure that ipython_log.py is in PWD and /online_dir # def _spockExitHandler(): if os.path.exists( '/online_dir/ipython_log.py'): os.system( 'vrsn -nolog -s /online_dir/ipython_log.py') # if os.path.exists( "%s/ipython_log.py" % os.environ['PWD']): os.system( "vrsn -nolog -s %s/ipython_log.py" % os.environ['PWD']) os.system( "/bin/rm %s/ipython_log.py" % os.environ['PWD']) # # register exit handler # atexit.register( _spockExitHandler) HasyUtils.pooltools.refreshDiffractometers() # # get the ipython shell # ip = get_ipython() # ip.run_line_magic( 'logstart', '-o -r -t') # # -o log include output # -r raw log 'wm exp_dmy01' instead of get_ipython().magic(u'wm exp_dmy01') # -t with timestamp # # # store the current motor attributes in a new version of /online_dir/MotorLogs/motorLog.lis # os.system('MotorLogger3.py -x -q -c spock') os.system( "ln -sf %s/ipython_log.py /online_dir/ipython_log.py" % os.environ['PWD']) # # -x execute # -q quiet # -c the name of the calling program is written to the log file # # # door = PyTango.DeviceProxy( HasyUtils.getDoorNames()[0]) for cmd in [ "setvo ShowDial False", "setvo ShowCtrlAxis True", "gh_disable", "gc_disable", "gc_disable", ]: door.RunMacro( cmd.split()) count = 0 print( "00-start.py, executing: %s" % cmd) while str( door.state()) == "RUNNING": time.sleep(0.1) count += 1 if count > 10: print( "00-start: DOOR stays RUNNING for command %s " % cmd) break # # # write some text to the log file # # ip.logger.log_write( unicode( "# some text \n")) # # prepare aliases for SardanaMonitor and SardanaMessageWindow # ip.run_line_magic( 'alias', 'sm ! pyspMonitor3.py &') print( "use 'sm' to launch the pyspMonitor") ip.run_line_magic( 'alias', 'smm ! SardanaMotorMonitor3.py &') print( "use 'smm' to launch the SardanaMotorMonitor")