-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy path_common_imports.py
67 lines (54 loc) · 2.29 KB
/
_common_imports.py
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
###
# Copyright 2008-2011 Diamond Light Source Ltd.
# This file is part of Diffcalc.
#
# Diffcalc is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Diffcalc 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Diffcalc. If not, see <http://www.gnu.org/licenses/>.
###
from __future__ import absolute_import
import os, sys
from diffcalc.hardware import ScannableHardwareAdapter
import diffcalc.hkl.you.geometry
from diffcalc.ub.persistence import UBCalculationJSONPersister
from diffcalc.hkl.you.persistence import YouStateEncoder
from diffcalc import settings
import diffcalc.util
try:
__IPYTHON__ # @UndefinedVariable
IPYTHON = True
except NameError:
IPYTHON = False
try:
from gda.device.scannable.scannablegroup import ScannableGroup
from gdascripts.scannable.dummy import SingleInputDummy as Dummy
from diffcmd.diffcmd_utils import alias_commands
GDA = True
except ImportError:
# Not running in gda environment so fall back to minigda emulation
from diffcalc.gdasupport.minigda.scannable import ScannableGroup
from diffcalc.gdasupport.minigda.scannable import SingleFieldDummyScannable as Dummy
GDA = False
HELP_STRING = \
"""Quick: https://github.com/DiamondLightSource/diffcalc/blob/master/README.rst
Manual: http://diffcalc.readthedocs.io/en/latest/youmanual.html
Type: > help ub
> help hkl"""
if GDA:
from gda.configuration.properties import LocalProperties # @UnresolvedImport
var_folder = LocalProperties.get("gda.var")
diffcalc_persistance_path = os.path.join(var_folder, 'diffcalc')
if not os.path.exists(diffcalc_persistance_path):
print "Making diffcalc var folder:'%s'" % diffcalc_persistance_path
os.makedirs(diffcalc_persistance_path)
settings.ubcalc_persister = UBCalculationJSONPersister(diffcalc_persistance_path, YouStateEncoder)
# else: should have been set if outside GDA