a2p2 0.2.14__py3-none-any.whl → 0.7.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. a2p2/__main__.py +40 -1
  2. a2p2/chara/facility.py +54 -4
  3. a2p2/chara/gui.py +31 -5
  4. a2p2/client.py +158 -31
  5. a2p2/facility.py +14 -1
  6. a2p2/gui.py +46 -12
  7. a2p2/instrument.py +3 -0
  8. a2p2/jmmc/__init__.py +7 -0
  9. a2p2/jmmc/catalogs.py +129 -0
  10. a2p2/jmmc/generated_models.py +191 -0
  11. a2p2/jmmc/models.py +104 -0
  12. a2p2/jmmc/services.py +16 -0
  13. a2p2/jmmc/utils.py +130 -0
  14. a2p2/jmmc/webservices.py +48 -0
  15. a2p2/ob.py +98 -9
  16. a2p2/samp.py +20 -0
  17. a2p2/version.py +210 -131
  18. a2p2/vlti/conf/GRAVITY_ditTable.json +21 -19
  19. a2p2/vlti/conf/GRAVITY_rangeTable.json +200 -28
  20. a2p2/vlti/conf/MATISSE_rangeTable.json +58 -22
  21. a2p2/vlti/conf/PIONIER_ditTable.json +1 -1
  22. a2p2/vlti/conf/PIONIER_rangeTable.json +16 -18
  23. a2p2/vlti/facility.py +160 -43
  24. a2p2/vlti/gravity.py +243 -311
  25. a2p2/vlti/gui.py +165 -39
  26. a2p2/vlti/instrument.py +266 -49
  27. a2p2/vlti/matisse.py +61 -147
  28. a2p2/vlti/pionier.py +34 -157
  29. {a2p2-0.2.14.dist-info → a2p2-0.7.4.dist-info}/METADATA +34 -20
  30. a2p2-0.7.4.dist-info/RECORD +39 -0
  31. {a2p2-0.2.14.dist-info → a2p2-0.7.4.dist-info}/WHEEL +1 -1
  32. {a2p2-0.2.14.dist-info → a2p2-0.7.4.dist-info}/entry_points.txt +0 -1
  33. a2p2/vlti/confP104/GRAVITY_ditTable.json +0 -122
  34. a2p2/vlti/confP104/GRAVITY_rangeTable.json +0 -202
  35. a2p2/vlti/confP104/MATISSE_ditTable.json +0 -2
  36. a2p2/vlti/confP104/MATISSE_rangeTable.json +0 -202
  37. a2p2/vlti/confP104/PIONIER_ditTable.json +0 -77
  38. a2p2/vlti/confP104/PIONIER_rangeTable.json +0 -118
  39. a2p2/vlti/confP105/GRAVITY_ditTable.json +0 -37
  40. a2p2/vlti/confP105/GRAVITY_rangeTable.json +0 -42
  41. a2p2/vlti/confP105/MATISSE_ditTable.json +0 -2
  42. a2p2/vlti/confP105/MATISSE_rangeTable.json +0 -44
  43. a2p2/vlti/confP105/PIONIER_ditTable.json +0 -25
  44. a2p2/vlti/confP105/PIONIER_rangeTable.json +0 -38
  45. a2p2-0.2.14.dist-info/RECORD +0 -44
  46. {a2p2-0.2.14.dist-info → a2p2-0.7.4.dist-info}/LICENSE +0 -0
  47. {a2p2-0.2.14.dist-info → a2p2-0.7.4.dist-info}/top_level.txt +0 -0
a2p2/vlti/gui.py CHANGED
@@ -3,25 +3,26 @@
3
3
  __all__ = []
4
4
 
5
5
  import sys
6
+ import logging
7
+ from turtle import bgcolor
6
8
 
7
9
  from a2p2.gui import FacilityUI
8
10
 
9
- if sys.version_info[0] == 2:
10
- from Tkinter import *
11
- from tkMessageBox import *
12
- import ttk
13
- else:
14
- from tkinter import *
15
- from tkinter.messagebox import *
16
- import tkinter.ttk as ttk
11
+ from tkinter import ttk
12
+ from tkinter import *
13
+ from tkinter.ttk import *
14
+
15
+ logger = logging.getLogger(__name__)
17
16
 
18
17
 
19
18
  class VltiUI(FacilityUI):
20
19
 
21
20
  def __init__(self, a2p2client):
21
+ logger.info("init VltiUI")
22
22
  FacilityUI.__init__(self, a2p2client)
23
23
 
24
- self.container = Frame(self, bd=3, relief=SUNKEN)
24
+ #self.container = Frame(self, bd=3, relief=SUNKEN)
25
+ self.container = Frame(self, relief=SUNKEN)
25
26
  self.container.grid_rowconfigure(0, weight=1)
26
27
  self.container.grid_columnconfigure(0, weight=1)
27
28
 
@@ -36,24 +37,32 @@ class VltiUI(FacilityUI):
36
37
  self.treeItemToRuns = {}
37
38
  self.treeItemToP2Items = {}
38
39
 
39
- self.ob=None
40
+ self.ob = None
40
41
 
41
42
  def showLoginFrame(self, ob):
42
43
  self.ob = ob
43
44
  self.addToLog(
44
- "Sorry, your %s OB can't be submitted, please log in first, select container and send OB again from Aspro2." %
45
+ "Sorry, your %s OB can't be submitted, please log in first, select container and press submit button." %
45
46
  (ob.instrumentConfiguration.name))
46
47
  self.loginFrame.tkraise()
47
48
 
49
+ def isBusy(self):
50
+ self.tree.configure(selectmode='none')
51
+
52
+ def isIdle(self):
53
+ self.tree.configure(selectmode='browse')
54
+
48
55
  def showTreeFrame(self, ob=None):
49
56
  if ob:
50
57
  instrum = ob.instrumentConfiguration.name
51
58
  else:
52
59
  instrum = "incoming"
53
- self.addToLog("Please select a runId in ESO P2 database to process %s OB" % instrum )
60
+ self.addToLog(
61
+ "Please select a runId in ESO P2 database to process %s OB" % instrum)
54
62
  self.treeFrame.tkraise()
55
63
 
56
64
  def fillTree(self, runs):
65
+ logger.debug(f"Start filling tree with {len(runs)} runs")
57
66
  if len(runs) == 0:
58
67
  self.ShowErrorMessage(
59
68
  "No Runs defined, impossible to program ESO's P2 interface.")
@@ -70,24 +79,31 @@ class VltiUI(FacilityUI):
70
79
  if self.facility.hasSupportedInsname(run['instrument']):
71
80
  cid = run['containerId']
72
81
  self._insertInTree('', run['progId'], cid, run, run)
73
- # if folders, add them recursively
74
- folders = getFolders(self.facility.api, cid)
75
- if len(folders) > 0:
76
- try:
77
- self.folder_explore(folders, cid, run)
78
- except:
79
- pass
80
-
81
- def folder_explore(self, folders, contid, run):
82
- for folder in folders:
83
- self._insertInTree(
84
- contid, folder['name'], folder['containerId'], run, folder)
85
- folders2 = getFolders(self.facility.api, folder['containerId'])
86
- if len(folders2) > 0:
87
- try:
88
- self.folder_explore(folders2, folder['containerId'], run)
89
- except:
90
- pass
82
+
83
+ def updateTree(self, run, containerId):
84
+ logger.debug(
85
+ f"updateTree with run : {run}\n and containerId: {containerId}")
86
+ items, _ = self.facility.api.getItems(containerId)
87
+ logger.debug(f"sub items are {items}")
88
+ logger.debug(f"item keys in tree: {self.treeItemToP2Items.keys()}")
89
+ for item in items:
90
+ if item['itemType'] in ['Folder', 'Concatenation', 'Group']:
91
+ if str(item['containerId']) in self.treeItemToP2Items.keys():
92
+ logger.debug(f"Item {item['containerId']} already in tree")
93
+ else:
94
+ logger.debug(f"adding in tree : {item}")
95
+ self._insertInTree(
96
+ containerId, item['name'], item['containerId'], run, item)
97
+ else:
98
+ logger.debug(f"not inserted in tree : {item}")
99
+ # TODO get children of our tree and remove part non present in items
100
+
101
+ def selectTreeItem(self, containerId):
102
+ item = str(containerId)
103
+ self.tree.selection_set(item)
104
+ self.tree.see(item)
105
+ self.facility.containerInfo.store(
106
+ self.treeItemToRuns[item], self.treeItemToP2Items[item])
91
107
 
92
108
  def _insertInTree(self, parentContainerID, name, containerID, run, item):
93
109
  instrument = run['instrument']
@@ -106,18 +122,47 @@ class VltiUI(FacilityUI):
106
122
  self.treeItemToRuns[e] = run
107
123
  self.treeItemToP2Items[e] = item
108
124
 
125
+ # add a dummy child so we can show to the user he has to walk into the tree
126
+ if run['itemCount'] > 0:
127
+ self.tree.insert(containerID, 'end',
128
+ f"{containerID}_fillme", values=[])
129
+ # return new tree item
130
+ return e
131
+
109
132
  def on_tree_selection_changed(self, selection):
133
+ logger.debug(f"tree selection change: {selection}")
110
134
  curItem = self.tree.focus()
111
135
  ret = self.tree.item(curItem)
112
136
  if len(ret['values']) > 0:
113
137
  self.facility.containerInfo.store(
114
138
  self.treeItemToRuns[curItem], self.treeItemToP2Items[curItem])
139
+ self.facility.tryLastOB()
115
140
 
116
- def isBusy(self):
117
- self.tree.configure(selectmode='none')
141
+ def on_tree_open(self, selection):
142
+ logger.debug(f"tree open: {selection}")
143
+ curItem = self.tree.focus()
144
+ curChildren = self.tree.get_children(curItem)
145
+ firstChild = curChildren[0]
146
+ if not firstChild in self.treeItemToRuns.keys():
147
+ self.tree.delete(firstChild)
148
+
149
+ parentRun = self.treeItemToRuns[curItem]
150
+ parentContainer = self.treeItemToP2Items[curItem]
151
+ parentContainerID = parentContainer['containerId']
152
+ self.updateTree(parentRun, parentContainerID)
153
+
154
+ def showOBConfirmationButtons(self, ob=None, showAcqButtons=False):
155
+ if not (ob):
156
+ self.treeFrame.enable_buttons(False, showAcqButtons)
157
+ return
158
+ else:
159
+ self.treeFrame.enable_buttons(True, showAcqButtons)
118
160
 
119
- def isIdle(self):
120
- self.tree.configure(selectmode='browse')
161
+ def getIssVltitypeVars(self):
162
+ return self.treeFrame.issVltiTypeCheckboxesVars
163
+
164
+ def getAcquisitionType(self):
165
+ return self.treeFrame.acquisitionType.get()
121
166
 
122
167
 
123
168
  class TreeFrame(Frame):
@@ -125,22 +170,24 @@ class TreeFrame(Frame):
125
170
  def __init__(self, vltiUI):
126
171
  Frame.__init__(self, vltiUI.container)
127
172
  self.vltiUI = vltiUI
128
-
129
173
  subframe = Frame(self)
130
174
 
175
+ treeframe = Frame(subframe)
131
176
  self.tree = ttk.Treeview(
132
- subframe, columns=('Project ID')) # , 'instrument'))#, 'folder ID'))
177
+ treeframe, columns=('Project ID'), selectmode='browse') # , 'instrument'))#, 'folder ID'))
133
178
  ysb = ttk.Scrollbar(
134
- subframe, orient='vertical', command=self.tree.yview)
179
+ treeframe, orient='vertical', command=self.tree.yview)
135
180
  xsb = ttk.Scrollbar(
136
- subframe, orient='horizontal', command=self.tree.xview)
181
+ treeframe, orient='horizontal', command=self.tree.xview)
137
182
 
138
183
  self.tree.configure(yscroll=ysb.set, xscroll=xsb.set)
139
184
  self.tree.heading('#0', text='Project ID', anchor='w')
140
185
  self.tree.heading('#1', text='Instrument', anchor='w')
141
186
  self.tree.heading('#2', text='Container type', anchor='w')
142
187
  self.tree.bind(
143
- '<ButtonRelease-1>', self.vltiUI.on_tree_selection_changed)
188
+ '<<TreeviewOpen>>', self.vltiUI.on_tree_open)
189
+ self.tree.bind(
190
+ '<<TreeviewSelect>>', self.vltiUI.on_tree_selection_changed)
144
191
 
145
192
  # grid layout does not expand and fill all area then move to pack
146
193
  # self.tree.grid(row=0, column=0, sticky='nsew')
@@ -150,9 +197,88 @@ class TreeFrame(Frame):
150
197
  ysb.pack(side=RIGHT, fill="y")
151
198
  # xsb.pack(side=BOTTOM, fill="y") # will probably require to add
152
199
  # another 2 frames
200
+ treeframe.pack(side=TOP, fill=BOTH, expand=True)
201
+
202
+ # Control button Panel to abort /submit or provide more information to the current OB
203
+ buttonframe = Frame(subframe)
204
+
205
+ cindex = 0
206
+
207
+
208
+ acquisitionFrame = Frame(buttonframe)
209
+
210
+ self.acquisitionType = StringVar()
211
+ self.acquisitionType.set("onaxis") # initialiser
212
+ self.r1 = Radiobutton(acquisitionFrame, text="onaxis", variable=self.acquisitionType, value="onaxis")
213
+ self.r2 = Radiobutton(acquisitionFrame, text="offaxis", variable=self.acquisitionType, value="offaxis")
214
+ self.r3 = Radiobutton(acquisitionFrame, text="wide", variable=self.acquisitionType, value="wide")
215
+
216
+ acquisitionFrame.grid(row=0, column=cindex)
217
+ cindex += 1
218
+
219
+
220
+ label = Label(buttonframe, text="|")
221
+ label.grid(row=0, column=cindex)
222
+ cindex += 1
223
+
224
+ psection = "p2.iss.vltitype"
225
+ pvltitypes = self.vltiUI.facility.a2p2client.preferences.getConfigKeys(
226
+ psection)
227
+
228
+ self.issVltiTypeCheckboxesVars = {}
229
+ for isvt in self.vltiUI.facility.getIssVltiTypes():
230
+ boolv = BooleanVar()
231
+ self.issVltiTypeCheckboxesVars[isvt]=boolv
232
+ boolv.set( not pvltitypes or len(pvltitypes)==0 or isvt in pvltitypes )
233
+ logger.debug(f"Set preference value for {isvt} : {boolv.get()}")
234
+ cb = Checkbutton(buttonframe, text=isvt, variable=boolv, onvalue=True, offvalue=False)
235
+ cb.grid(row=0, column=cindex)
236
+ cindex += 1
237
+
238
+ self.abortButton = Button(buttonframe, text="Abort this OB",
239
+ command=self.on_abortbutton_clicked, state=DISABLED)
240
+ style = ttk.Style()
241
+ sButtonStyle="Custom.TButton"
242
+ ttk.Style().configure(sButtonStyle, background="green")
243
+ self.submitButton = Button(
244
+ buttonframe, text="Submit", command=self.on_submitbutton_clicked, state=DISABLED,
245
+ style=sButtonStyle)
246
+ self.abortButton.grid(row=0, column=cindex)
247
+ cindex += 1
248
+ self.submitButton.grid(row=0, column=cindex)
249
+ buttonframe.pack(side=RIGHT)
153
250
 
154
251
  subframe.pack(side=TOP, fill=BOTH, expand=True)
155
252
 
253
+ def enable_buttons(self, enableActions, showAcqButtons=False):
254
+ if showAcqButtons and enableActions:
255
+ self.r1.pack(side=LEFT)
256
+ self.r2.pack(side=LEFT)
257
+ self.r3.pack(side=LEFT)
258
+ else:
259
+ self.r1.pack_forget()
260
+ self.r2.pack_forget()
261
+ self.r3.pack_forget()
262
+
263
+ if enableActions:
264
+ flag = NORMAL
265
+ else:
266
+ flag = DISABLED
267
+ self.submitButton["state"] = flag
268
+ self.abortButton["state"] = flag
269
+
270
+ # leave abort button always active to let user remove in case of error
271
+ if self.vltiUI.facility.hasOB():
272
+ self.abortButton["state"] = NORMAL
273
+
274
+ def on_submitbutton_clicked(self):
275
+ self.vltiUI.facility.popOB()
276
+ self.enable_buttons(False)
277
+
278
+ def on_abortbutton_clicked(self):
279
+ self.vltiUI.facility.popOB(ignore=True)
280
+ self.enable_buttons(False)
281
+
156
282
 
157
283
  class LoginFrame(Frame):
158
284