/usr/share/pyshared/PyTango/ipython/ipython_00_10/ipy_install.py is in python-pytango 7.2.2-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | #!/usr/bin/env python
################################################################################
##
## This file is part of PyTango, a python binding for Tango
##
## http://www.tango-controls.org/static/PyTango/latest/doc/html/index.html
##
## Copyright 2011 CELLS / ALBA Synchrotron, Bellaterra, Spain
##
## PyTango is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## PyTango is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with PyTango. If not, see <http://www.gnu.org/licenses/>.
##
################################################################################
import sys
import os
import StringIO
import IPython.genutils
import PyTango
__PROFILE = """\
#!/usr/bin/env ipython
\"\"\"An automaticaly generated IPython profile designed to provide a user
friendly interface to Tango.
Created with PyTango {pytangover} for IPython {ipyver}\"\"\"
import IPython
import PyTango.ipython
ip = IPython.ipapi.get()
PyTango.ipython.init_ipython(ip)
"""
def install(ipydir=None,verbose=True):
install_dir = ipydir or IPython.genutils.get_ipython_dir()
f_name = os.path.join(install_dir, 'ipy_profile_spock.py')
if verbose:
out = sys.stdout
else:
out = StringIO.StringIO()
if ipydir is None and os.path.isfile(f_name):
print "Warning: The file '%s' already exists." % f_name
r = ''
while r.lower() not in ('y', 'n'):
r = raw_input("Do you wish to override it [Y/n]?")
r = r or 'y'
if r.lower() == 'n':
return
profile = __PROFILE.format(pytangover=PyTango.Release.version, ipyver=IPython.Release.version)
out.write("Installing spock extension to ipython... ")
out.flush()
try:
f = file(f_name, "w")
f.write(profile)
f.close()
out.write("[DONE]\n\n")
except Exception, e:
out.write("[FAILED]\n\n")
raise e
ipy_user_config = os.path.join(IPython.genutils.get_ipython_dir(), 'ipy_user_conf.py')
out.write("""\
To start spock simply type on the command line:
%% ipython -p spock
If you want spock extension to be automaticaly active when you start ipython,
edit your %s and add the line:
import ipy_profile_spock
Next time, just start ipython on the command line:
%% ipython
and your spock extension should be loaded automaticaly. Note that if you are also
loading other extensions that, for example, overwrite the prompt, the prompt
that will appear is the one from the last extension to be imported.
For more information goto: http://www.tango-controls.org/static/PyTango/latest/doc/html/index.html
Have fun with spock!
The PyTango team
""" % (ipy_user_config,))
def main():
d = None
if len(sys.argv) > 1:
d = sys.argv[1]
install(d)
if __name__ == "__main__":
main()
|