Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.apo.nmsu.edu/Telescopes/TCC/html/show_block_8py_source.html
Дата изменения: Tue Sep 15 02:25:37 2015
Дата индексирования: Sun Apr 10 01:50:16 2016
Кодировка:
lsst.tcc: python/tcc/cmd/showBlock.py Source File
lsst.tcc  1.2.2-3-g89ecb63
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
showBlock.py
Go to the documentation of this file.
1 from __future__ import division, absolute_import
2 """
3 Displays information in the global database. By default, it displays to the screen,
4 but you may send output to a file using /Output
5 """
6 import StringIO
7 from RO.StringUtil import quoteStr
8 
9 __all__ = ["showBlock"]
10 
11 blocks = ("AxeLim", "Earth",
12  "Inst", "Obj", "TelMod", "Tune", "Weath")
13 attrs = ("axeLim", "earth", "inst", "obj", "telMod", "tune", "weath")
14 blockAttrDict = dict(zip(blocks, attrs))
15 
16 def showBlock(tccActor, userCmd):
17  """ @param[in,out] tccActor tcc actor
18  @param[in,out] userCmd mirror command
19  """
20  gotBlock = userCmd.parsedCmd.paramDict["blockname"].valueList[0].keyword
21  currBlock = getattr(tccActor, blockAttrDict[gotBlock])
22 
23  if userCmd.parsedCmd.qualDict['output'].boolValue:
24  filePath = userCmd.parsedCmd.qualDict['output'].valueList[0]
25  with open(filePath, 'w') as f:
26  currBlock.dump(f)
27  else:
28  # dump from block into a StringIO object as a temporary file
29  f = StringIO.StringIO()
30  currBlock.dump(f)
31  listOfLines = f.getvalue().split("\n")
32  for line in listOfLines:
33  if not line:
34  continue
35  kwForm = 'Text=' + quoteStr(line)
36  tccActor.writeToOneUser('i', kwForm, cmd=userCmd)
37  userCmd.setState(userCmd.Done)