mxcubecore 1.368.0__py3-none-any.whl → 1.370.0__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.
Potentially problematic release.
This version of mxcubecore might be problematic. Click here for more details.
- mxcubecore/HardwareObjects/MAXIV/MicroMAX/beamline.py +51 -0
- mxcubecore/HardwareObjects/MAXIV/beamline.py +28 -0
- mxcubecore/HardwareObjects/MAXIV/session.py +158 -0
- {mxcubecore-1.368.0.dist-info → mxcubecore-1.370.0.dist-info}/METADATA +1 -1
- {mxcubecore-1.368.0.dist-info → mxcubecore-1.370.0.dist-info}/RECORD +8 -6
- mxcubecore/HardwareObjects/MAXIV/MaxIVSession.py +0 -231
- {mxcubecore-1.368.0.dist-info → mxcubecore-1.370.0.dist-info}/COPYING +0 -0
- {mxcubecore-1.368.0.dist-info → mxcubecore-1.370.0.dist-info}/COPYING.LESSER +0 -0
- {mxcubecore-1.368.0.dist-info → mxcubecore-1.370.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"""Custom MicroMAX Beamline object.
|
|
2
|
+
|
|
3
|
+
Adds support for `sample_delivery` configurable, which
|
|
4
|
+
specifies the sample delivery mode for MXCuBE.
|
|
5
|
+
|
|
6
|
+
Following sample delivery modes are supported:
|
|
7
|
+
|
|
8
|
+
* osc - Oscillation sample delivery
|
|
9
|
+
* hve - HVE (injector) sample delivery
|
|
10
|
+
|
|
11
|
+
Example of `sample_delivery` configuration::
|
|
12
|
+
|
|
13
|
+
configuration:
|
|
14
|
+
sample_delivery: osc
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
from enum import Enum
|
|
18
|
+
|
|
19
|
+
import mxcubecore.HardwareObjects.MAXIV.beamline
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class SampleDelivery(Enum):
|
|
23
|
+
osc = "osc"
|
|
24
|
+
hve = "hve"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Beamline(mxcubecore.HardwareObjects.MAXIV.beamline.Beamline):
|
|
28
|
+
def __init__(self, name):
|
|
29
|
+
super().__init__(name)
|
|
30
|
+
|
|
31
|
+
# 'cached' Sample Delivery mode config
|
|
32
|
+
self._sample_delivery = None
|
|
33
|
+
|
|
34
|
+
#
|
|
35
|
+
# 'sample_delivery' config
|
|
36
|
+
#
|
|
37
|
+
|
|
38
|
+
def _load_sample_delivery(self):
|
|
39
|
+
val = self.get_property("sample_delivery", SampleDelivery.osc.value)
|
|
40
|
+
self._sample_delivery = SampleDelivery(val)
|
|
41
|
+
|
|
42
|
+
@property
|
|
43
|
+
def sample_delivery(self) -> SampleDelivery:
|
|
44
|
+
if self._sample_delivery is None:
|
|
45
|
+
self._load_sample_delivery()
|
|
46
|
+
|
|
47
|
+
return self._sample_delivery
|
|
48
|
+
|
|
49
|
+
def is_hve_sample_delivery(self) -> bool:
|
|
50
|
+
"""True when HVE sample delivery mode is configured."""
|
|
51
|
+
return self.sample_delivery == SampleDelivery.hve
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""Custom MAXIV Beamline object.
|
|
2
|
+
|
|
3
|
+
Adds support for ``emulate`` configurable, which allows to specify
|
|
4
|
+
features to be emulated at the beamline.
|
|
5
|
+
|
|
6
|
+
Emulation of following features are supported:
|
|
7
|
+
|
|
8
|
+
* safety_shutter - emulate safety shutter opening
|
|
9
|
+
* detector_cover - emulate detector cover opening
|
|
10
|
+
* detector_motion - emulate detector distance moves
|
|
11
|
+
|
|
12
|
+
Example of ``emulate`` configuration::
|
|
13
|
+
|
|
14
|
+
configuration:
|
|
15
|
+
emulate:
|
|
16
|
+
safety_shutter: true
|
|
17
|
+
detector_cover: true
|
|
18
|
+
detector_motion: true
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
import mxcubecore.HardwareObjects.Beamline
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Beamline(mxcubecore.HardwareObjects.Beamline.Beamline):
|
|
25
|
+
def emulate(self, feature: str) -> bool:
|
|
26
|
+
"""Check if some feature should be emulated."""
|
|
27
|
+
emulate = self.get_property("emulate", {})
|
|
28
|
+
return emulate.get(feature, False)
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"""MAXIV Session hardware object."""
|
|
2
|
+
|
|
3
|
+
import time
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
from sdm import storage
|
|
7
|
+
|
|
8
|
+
import mxcubecore.HardwareObjects.Session
|
|
9
|
+
from mxcubecore.model.queue_model_objects import PathTemplate
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class Session(mxcubecore.HardwareObjects.Session.Session):
|
|
13
|
+
def init(self):
|
|
14
|
+
super().init()
|
|
15
|
+
self.is_commissioning = False
|
|
16
|
+
|
|
17
|
+
# We initialize with an empty archive_folder,
|
|
18
|
+
# to be set once proposal is selected.
|
|
19
|
+
PathTemplate.set_archive_path(self.base_archive_directory, "")
|
|
20
|
+
|
|
21
|
+
def set_in_commissioning(self, proposal_info):
|
|
22
|
+
self.proposal_code = proposal_info["Proposal"]["code"]
|
|
23
|
+
self.proposal_number = proposal_info["Proposal"]["number"]
|
|
24
|
+
self.is_commissioning = True
|
|
25
|
+
|
|
26
|
+
def get_proposal(self) -> str:
|
|
27
|
+
"""
|
|
28
|
+
Returns:
|
|
29
|
+
The proposal, 'local-user' if no proposal is available
|
|
30
|
+
"""
|
|
31
|
+
proposal = "local-user"
|
|
32
|
+
|
|
33
|
+
if self.proposal_code and self.proposal_number:
|
|
34
|
+
if self.proposal_code == "ifx":
|
|
35
|
+
self.proposal_code = "fx"
|
|
36
|
+
|
|
37
|
+
proposal = str(self.proposal_number)
|
|
38
|
+
|
|
39
|
+
return proposal
|
|
40
|
+
|
|
41
|
+
def get_base_data_directory(self) -> str:
|
|
42
|
+
"""Get base data directory.
|
|
43
|
+
|
|
44
|
+
Figure out the base data directory taking the 'contextual'
|
|
45
|
+
information into account, such as if the current user
|
|
46
|
+
is in-house.
|
|
47
|
+
|
|
48
|
+
Returns:
|
|
49
|
+
The base data path.
|
|
50
|
+
"""
|
|
51
|
+
# /data/(user-type)/(beamline)/(proposal)/(visit)/raw
|
|
52
|
+
if self.session_start_date:
|
|
53
|
+
start_time = self.session_start_date.split(" ")[0].replace("-", "")
|
|
54
|
+
else:
|
|
55
|
+
start_time = time.strftime("%Y%m%d")
|
|
56
|
+
_proposal = self.get_proposal()
|
|
57
|
+
|
|
58
|
+
if not self.is_commissioning:
|
|
59
|
+
if self.is_proprietary():
|
|
60
|
+
directory = Path(
|
|
61
|
+
self.base_directory,
|
|
62
|
+
"proprietary",
|
|
63
|
+
self.beamline_name.lower(),
|
|
64
|
+
_proposal,
|
|
65
|
+
start_time,
|
|
66
|
+
)
|
|
67
|
+
else:
|
|
68
|
+
directory = Path(
|
|
69
|
+
self.base_directory,
|
|
70
|
+
"visitors",
|
|
71
|
+
self.beamline_name.lower(),
|
|
72
|
+
_proposal,
|
|
73
|
+
start_time,
|
|
74
|
+
)
|
|
75
|
+
else:
|
|
76
|
+
# /data/staff/biomax/commissioning/date
|
|
77
|
+
directory = Path(
|
|
78
|
+
self.base_directory,
|
|
79
|
+
"staff",
|
|
80
|
+
self.beamline_name.lower(),
|
|
81
|
+
"commissioning",
|
|
82
|
+
time.strftime("%Y%m%d"),
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
self.log.info(
|
|
86
|
+
"Data directory for proposal %s: %s",
|
|
87
|
+
self.get_proposal(),
|
|
88
|
+
directory,
|
|
89
|
+
)
|
|
90
|
+
|
|
91
|
+
return str(directory)
|
|
92
|
+
|
|
93
|
+
def prepare_directories(self, session):
|
|
94
|
+
self.log.info("Preparing Data directory for session: %s", session)
|
|
95
|
+
start_date = session.start_datetime.date().isoformat().replace("-", "")
|
|
96
|
+
self.set_session_start_date(start_date)
|
|
97
|
+
|
|
98
|
+
self.log.info("Preparing Data directory for proposal %s", self.get_proposal())
|
|
99
|
+
if self.is_commissioning:
|
|
100
|
+
category = "staff"
|
|
101
|
+
elif self.is_proprietary():
|
|
102
|
+
category = "proprietary"
|
|
103
|
+
else:
|
|
104
|
+
category = "visitors"
|
|
105
|
+
|
|
106
|
+
try:
|
|
107
|
+
self.storage = storage.Storage(
|
|
108
|
+
user_type=category, beamline=self.endstation_name
|
|
109
|
+
)
|
|
110
|
+
except Exception:
|
|
111
|
+
self.log.exception("error setting up SDM")
|
|
112
|
+
|
|
113
|
+
# This creates the path for the data and ensures proper permissions
|
|
114
|
+
# e.g. /data/visitors/biomax/<proposal>/<visit>/{raw, process}
|
|
115
|
+
if self.is_commissioning:
|
|
116
|
+
group = self.beamline_name.lower()
|
|
117
|
+
else:
|
|
118
|
+
group = self.storage.get_proposal_group(session.number)
|
|
119
|
+
try:
|
|
120
|
+
_raw_path = self.storage.create_path(
|
|
121
|
+
session.number, group, self.get_session_start_date()
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
self.log.info("SDM Data directory created: %s", _raw_path)
|
|
125
|
+
except Exception as exc: # noqa: BLE001
|
|
126
|
+
self.log.warning("SDM Data directory creation failed. %s", exc)
|
|
127
|
+
self.log.info("SDM Data directory trying to create again after failure")
|
|
128
|
+
time.sleep(0.1)
|
|
129
|
+
try:
|
|
130
|
+
_raw_path = self.storage.create_path(
|
|
131
|
+
session.number, group, self.get_session_start_date()
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
self.log.info("SDM Data directory created: %s", _raw_path)
|
|
135
|
+
except Exception:
|
|
136
|
+
self.log.exception("SDM Data directory creation failed.")
|
|
137
|
+
raise
|
|
138
|
+
|
|
139
|
+
if self.base_archive_directory:
|
|
140
|
+
archive_folder = "{}/{}".format(category, self.beamline_name.lower())
|
|
141
|
+
PathTemplate.set_archive_path(self.base_archive_directory, archive_folder)
|
|
142
|
+
_archive_path = Path(self.base_archive_directory, archive_folder)
|
|
143
|
+
self.log.info("Archive directory configured: %s", _archive_path)
|
|
144
|
+
|
|
145
|
+
def is_proprietary(self) -> bool:
|
|
146
|
+
"""Determines if current proposal is considered to be proprietary.
|
|
147
|
+
|
|
148
|
+
Returns:
|
|
149
|
+
True if the proposal is proprietary, otherwise False.
|
|
150
|
+
"""
|
|
151
|
+
return self.proposal_code == "IN"
|
|
152
|
+
|
|
153
|
+
def clear_session(self):
|
|
154
|
+
self.session_id = None
|
|
155
|
+
self.proposal_code = None
|
|
156
|
+
self.proposal_number = None
|
|
157
|
+
self.proposal_id = None
|
|
158
|
+
self.is_commissioning = False
|
|
@@ -224,10 +224,12 @@ mxcubecore/HardwareObjects/LimaPilatusDetector.py,sha256=yUcUi7OXdoy4TU2aZN21kc6
|
|
|
224
224
|
mxcubecore/HardwareObjects/MAXIV/ISPyBLims.py,sha256=iKgpb0NVGIN-iRgjIpV2eh12PJoAZvo3NFyKwo-458Q,7565
|
|
225
225
|
mxcubecore/HardwareObjects/MAXIV/MAXIVAutoProcessing.py,sha256=kgTSnOLoumPtOUazJeg6N_no1WOScPeLwus3iR1xMPw,9201
|
|
226
226
|
mxcubecore/HardwareObjects/MAXIV/MachInfo.py,sha256=Wkj5JHP_8tOgRGNXiKPfImTsX-O67_CrWH3wP14AsSI,2983
|
|
227
|
-
mxcubecore/HardwareObjects/MAXIV/MaxIVSession.py,sha256=DR9jnTSX_i2Ljs2iBIBeyZkcf7P284fJd_mUtU4bPi0,7732
|
|
228
227
|
mxcubecore/HardwareObjects/MAXIV/MicroMAX/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
228
|
+
mxcubecore/HardwareObjects/MAXIV/MicroMAX/beamline.py,sha256=QfNp5ecE4l54cU2U8Km7sK4lgenSnZeBmkxTyRCiaLE,1272
|
|
229
229
|
mxcubecore/HardwareObjects/MAXIV/MicroMAX/beamline_actions.py,sha256=mQUoWJD8NU8N_dyGLGTAD4MJ9sD6B6CYw5EuDZQFhkQ,2085
|
|
230
230
|
mxcubecore/HardwareObjects/MAXIV/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
231
|
+
mxcubecore/HardwareObjects/MAXIV/beamline.py,sha256=Np98l0aThwHZvgHbkvkWXz7RIIkWzY_ArDmddoyfIus,803
|
|
232
|
+
mxcubecore/HardwareObjects/MAXIV/session.py,sha256=mqsolRmXkOkmItr8jH48G3NdJ6GzVJ_a85SF4VaiLkA,5431
|
|
231
233
|
mxcubecore/HardwareObjects/MD2Motor.py,sha256=N5d6iOgqw5k9e27lTKUOrpSbEMeNdTgWhNUgYzR0w5k,5639
|
|
232
234
|
mxcubecore/HardwareObjects/MD3UP.py,sha256=zC-TmPruj2HRO6cMGDBDS9s8bXor19jhvb_oux1Ihh8,14528
|
|
233
235
|
mxcubecore/HardwareObjects/MachCurrent.py,sha256=4pxVm7PaSylwPs7Ak0Fgo36NW2ipYCrPbp83KKl78z8,3502
|
|
@@ -467,8 +469,8 @@ mxcubecore/utils/conversion.py,sha256=G1bk2Mi2ZwGbZa5pEeiFaKWxhSVXVGqu1L9_SioyUO
|
|
|
467
469
|
mxcubecore/utils/qt_import.py,sha256=0lPmqok_oYQZ059kJCq7RWdg490T8YKyRvoZGyWDy4M,14486
|
|
468
470
|
mxcubecore/utils/tango.py,sha256=lAl7Su_GgyXFEEKZ1yu_2gU18wXHVaBbGR8RYcIOVYk,2100
|
|
469
471
|
mxcubecore/utils/units.py,sha256=Gh7ovTUN00XBMUoyDG5W7akCx1pROL-M6pK2z1ouemg,1361
|
|
470
|
-
mxcubecore-1.
|
|
471
|
-
mxcubecore-1.
|
|
472
|
-
mxcubecore-1.
|
|
473
|
-
mxcubecore-1.
|
|
474
|
-
mxcubecore-1.
|
|
472
|
+
mxcubecore-1.370.0.dist-info/COPYING,sha256=u-Mc8zCecwyo4YoP8UulmzCiZZ_MmCLROd_NBtOcRj0,35148
|
|
473
|
+
mxcubecore-1.370.0.dist-info/COPYING.LESSER,sha256=46mU2C5kSwOnkqkw9XQAJlhBL2JAf1_uCD8lVcXyMRg,7652
|
|
474
|
+
mxcubecore-1.370.0.dist-info/METADATA,sha256=LpkHXXmiDnrsb-M1oPqAe-BdTH5uqJh0GGbC0yPbNQ0,4259
|
|
475
|
+
mxcubecore-1.370.0.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
|
476
|
+
mxcubecore-1.370.0.dist-info/RECORD,,
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
MAXIV Session hardware object.
|
|
3
|
-
|
|
4
|
-
Adapting from original Session.py to adapt the names of data directories
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
import logging
|
|
8
|
-
import os
|
|
9
|
-
import socket
|
|
10
|
-
import time
|
|
11
|
-
|
|
12
|
-
try:
|
|
13
|
-
from sdm import (
|
|
14
|
-
storage,
|
|
15
|
-
)
|
|
16
|
-
except Exception:
|
|
17
|
-
raise Exception("Cannot import SDM library.")
|
|
18
|
-
|
|
19
|
-
from mxcubecore.HardwareObjects.Session import Session
|
|
20
|
-
from mxcubecore.model import queue_model_objects
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
class MaxIVSession(Session):
|
|
24
|
-
def __init__(self, name):
|
|
25
|
-
Session.__init__(self, name)
|
|
26
|
-
|
|
27
|
-
# Framework-2 method, inherited from HardwareObject and called
|
|
28
|
-
# by the framework after the object has been initialized.
|
|
29
|
-
def init(self):
|
|
30
|
-
self.default_precision = 4
|
|
31
|
-
self.login = ""
|
|
32
|
-
self.is_commissioning = False
|
|
33
|
-
self.synchrotron_name = self.get_property("synchrotron_name")
|
|
34
|
-
self.endstation_name = self.get_property("endstation_name").lower()
|
|
35
|
-
self.suffix = self["file_info"].get_property("file_suffix")
|
|
36
|
-
self.base_directory = self["file_info"].get_property("base_directory")
|
|
37
|
-
self.base_process_directory = self["file_info"].get_property(
|
|
38
|
-
"processed_data_base_directory"
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
self.raw_data_folder_name = self["file_info"].get_property(
|
|
42
|
-
"raw_data_folder_name"
|
|
43
|
-
)
|
|
44
|
-
|
|
45
|
-
self.processed_data_folder_name = self["file_info"].get_property(
|
|
46
|
-
"processed_data_folder_name"
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
try:
|
|
50
|
-
self.in_house_users = self.get_property("inhouse_users").split(",")
|
|
51
|
-
except Exception:
|
|
52
|
-
self.in_house_users = []
|
|
53
|
-
|
|
54
|
-
try:
|
|
55
|
-
domain = socket.getfqdn().split(".")
|
|
56
|
-
self.email_extension = ".".join((domain[-2], domain[-1]))
|
|
57
|
-
except (TypeError, IndexError):
|
|
58
|
-
pass
|
|
59
|
-
|
|
60
|
-
archive_base_directory = self["file_info"].get_property(
|
|
61
|
-
"archive_base_directory"
|
|
62
|
-
)
|
|
63
|
-
if archive_base_directory:
|
|
64
|
-
queue_model_objects.PathTemplate.set_archive_path(
|
|
65
|
-
archive_base_directory, self["file_info"].get_property("archive_folder")
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
queue_model_objects.PathTemplate.set_path_template_style(self.synchrotron_name)
|
|
69
|
-
queue_model_objects.PathTemplate.set_data_base_path(self.base_directory)
|
|
70
|
-
|
|
71
|
-
self.commissioning_fake_proposal = {
|
|
72
|
-
"Laboratory": {
|
|
73
|
-
"address": None,
|
|
74
|
-
"city": "Lund",
|
|
75
|
-
"laboratoryId": 312171,
|
|
76
|
-
"name": "Lund University",
|
|
77
|
-
},
|
|
78
|
-
"Person": {
|
|
79
|
-
"familyName": "commissioning",
|
|
80
|
-
"givenName": "",
|
|
81
|
-
"laboratoryId": 312171,
|
|
82
|
-
"login": "",
|
|
83
|
-
"personId": 0,
|
|
84
|
-
},
|
|
85
|
-
"Proposal": {
|
|
86
|
-
"code": "MX",
|
|
87
|
-
"number": time.strftime("%Y"),
|
|
88
|
-
"proposalId": "0",
|
|
89
|
-
"timeStamp": time.strftime("%Y%m%d"),
|
|
90
|
-
"title": "Commissioning Proposal",
|
|
91
|
-
"type": "MX",
|
|
92
|
-
},
|
|
93
|
-
"Session": [
|
|
94
|
-
{
|
|
95
|
-
"is_inhouse": True,
|
|
96
|
-
"beamlineName": "BioMAX",
|
|
97
|
-
"comments": "Fake session for commissioning",
|
|
98
|
-
"endDate": "2027-12-31 23:59:59",
|
|
99
|
-
"nbShifts": 100,
|
|
100
|
-
"proposalId": "0",
|
|
101
|
-
"scheduled": 0,
|
|
102
|
-
"sessionId": 0,
|
|
103
|
-
"startDate": "2016-01-01 00:00:00",
|
|
104
|
-
}
|
|
105
|
-
],
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
def set_in_commissioning(self, proposal_info):
|
|
109
|
-
self.proposal_code = proposal_info["Proposal"]["code"]
|
|
110
|
-
self.proposal_number = proposal_info["Proposal"]["number"]
|
|
111
|
-
self.is_commissioning = True
|
|
112
|
-
|
|
113
|
-
def get_proposal(self):
|
|
114
|
-
"""
|
|
115
|
-
:returns: The proposal, 'local-user' if no proposal is
|
|
116
|
-
available
|
|
117
|
-
:rtype: str
|
|
118
|
-
"""
|
|
119
|
-
proposal = "local-user"
|
|
120
|
-
|
|
121
|
-
if self.proposal_code and self.proposal_number:
|
|
122
|
-
if self.proposal_code == "ifx":
|
|
123
|
-
self.proposal_code = "fx"
|
|
124
|
-
|
|
125
|
-
proposal = str(self.proposal_number)
|
|
126
|
-
|
|
127
|
-
return proposal
|
|
128
|
-
|
|
129
|
-
def get_base_data_directory(self):
|
|
130
|
-
"""
|
|
131
|
-
Returns the base data directory taking the 'contextual'
|
|
132
|
-
information into account, such as if the current user
|
|
133
|
-
is inhouse.
|
|
134
|
-
|
|
135
|
-
:returns: The base data path.
|
|
136
|
-
:rtype: str
|
|
137
|
-
"""
|
|
138
|
-
if self.session_start_date:
|
|
139
|
-
start_time = self.session_start_date.split(" ")[0].replace("-", "")
|
|
140
|
-
else:
|
|
141
|
-
start_time = time.strftime("%Y%m%d")
|
|
142
|
-
|
|
143
|
-
if not self.is_commissioning:
|
|
144
|
-
# /data/visitors/biomax/prop/visit/
|
|
145
|
-
# /data/(user-type)/(beamline)/(proposal)/(visit)/raw
|
|
146
|
-
directory = os.path.join(
|
|
147
|
-
self.base_directory,
|
|
148
|
-
"visitors", # self.get_user_category(self.login),
|
|
149
|
-
self.beamline_name.lower(),
|
|
150
|
-
self.get_proposal(),
|
|
151
|
-
start_time,
|
|
152
|
-
)
|
|
153
|
-
else:
|
|
154
|
-
# /data/staff/biomax/commissioning/date
|
|
155
|
-
directory = os.path.join(
|
|
156
|
-
self.base_directory,
|
|
157
|
-
"staff",
|
|
158
|
-
self.beamline_name.lower(),
|
|
159
|
-
"commissioning",
|
|
160
|
-
time.strftime("%Y%m%d"),
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
logging.getLogger("HWR").info(
|
|
164
|
-
"[MAX IV Session] Data directory for proposal %s: %s"
|
|
165
|
-
% (self.get_proposal(), directory)
|
|
166
|
-
)
|
|
167
|
-
return directory
|
|
168
|
-
|
|
169
|
-
def prepare_directories(self, proposal_info):
|
|
170
|
-
self.login = proposal_info["Person"]["login"]
|
|
171
|
-
start_time = proposal_info.get("Session")[0].get("startDate")
|
|
172
|
-
|
|
173
|
-
logging.getLogger("HWR").info(
|
|
174
|
-
"[MAX IV Session] Preparing Data directory for proposal %s" % proposal_info
|
|
175
|
-
)
|
|
176
|
-
if start_time:
|
|
177
|
-
start_date = start_time.split(" ")[0].replace("-", "")
|
|
178
|
-
else:
|
|
179
|
-
start_date = time.strftime("%Y%m%d")
|
|
180
|
-
|
|
181
|
-
self.set_session_start_date(start_date)
|
|
182
|
-
|
|
183
|
-
try:
|
|
184
|
-
self.storage = storage.Storage(
|
|
185
|
-
self.get_user_category(self.login), self.endstation_name
|
|
186
|
-
)
|
|
187
|
-
except Exception as ex:
|
|
188
|
-
print(ex)
|
|
189
|
-
# this creates the path for the data and ensures proper permissions.
|
|
190
|
-
# e.g. /data/visitors/biomax/<proposal>/<visit>/{raw, process}
|
|
191
|
-
if self.is_commissioning:
|
|
192
|
-
group = self.beamline_name.lower()
|
|
193
|
-
else:
|
|
194
|
-
group = self.storage.get_proposal_group(self.proposal_number)
|
|
195
|
-
try:
|
|
196
|
-
self.storage.create_path(
|
|
197
|
-
self.proposal_number, group, self.get_session_start_date()
|
|
198
|
-
)
|
|
199
|
-
|
|
200
|
-
proposal_path = "{0}/{1}".format(
|
|
201
|
-
self.storage.beamline_path, self.proposal_number
|
|
202
|
-
)
|
|
203
|
-
logging.getLogger("HWR").info(
|
|
204
|
-
"[MAX IV Session] SDM Data directory created: %s" % proposal_path
|
|
205
|
-
)
|
|
206
|
-
except Exception as ex:
|
|
207
|
-
msg = "[MAX IV Session] SDM Data directory creation failed. %s" % ex
|
|
208
|
-
logging.getLogger("HWR").error(msg)
|
|
209
|
-
raise Exception(msg)
|
|
210
|
-
|
|
211
|
-
def is_inhouse(self, user, code=None):
|
|
212
|
-
"""
|
|
213
|
-
Determines if a given user is considered to be inhouse.
|
|
214
|
-
:param login: username
|
|
215
|
-
:type login: str
|
|
216
|
-
:returns: True if the user is inhouse, otherwise False.
|
|
217
|
-
:rtype: bool
|
|
218
|
-
"""
|
|
219
|
-
if user in self.in_house_users:
|
|
220
|
-
return True
|
|
221
|
-
else:
|
|
222
|
-
return False
|
|
223
|
-
|
|
224
|
-
def get_user_category(self, user):
|
|
225
|
-
# 'staff','visitors', 'proprietary'
|
|
226
|
-
# missing industrial users
|
|
227
|
-
if self.is_inhouse(user):
|
|
228
|
-
user_category = "staff"
|
|
229
|
-
else:
|
|
230
|
-
user_category = "visitors"
|
|
231
|
-
return user_category
|
|
File without changes
|
|
File without changes
|
|
File without changes
|