Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
5e71ea82
Commit
5e71ea82
authored
9 years ago
by
Alex Buts
Browse files
Options
Downloads
Patches
Plain Diff
Re #14360 fixed issues with autoconfig
Though testing and running as user is still needed
parent
04348f6b
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
scripts/Inelastic/Direct/ISISDirecInelasticConfig.py
+21
-11
21 additions, 11 deletions
scripts/Inelastic/Direct/ISISDirecInelasticConfig.py
scripts/test/User_files_description_test.xml
+1
-1
1 addition, 1 deletion
scripts/test/User_files_description_test.xml
with
22 additions
and
12 deletions
scripts/Inelastic/Direct/ISISDirecInelasticConfig.py
+
21
−
11
View file @
5e71ea82
import
os
import
sys
import
platform
import
shutil
import
re
...
...
@@ -10,7 +11,7 @@ from xml.dom import minidom
# the list of instruments this configuration is applicable to
INELASTIC_INSTRUMENTS
=
[
'
MAPS
'
,
'
LET
'
,
'
MERLIN
'
,
'
MARI
'
,
'
HET
'
]
# the list of the parameters, which can be replaced if found in user files
USER_PROPERTIES
=
[
'
instrument
'
,
'
cycleID
'
,
'
start_date
'
,
'
rb_folder
'
]
USER_PROPERTIES
=
[
'
instrument
'
,
'
userID
'
,
'
cycleID
'
,
'
start_date
'
,
'
rb_folder
'
]
class
UserProperties
(
object
):
"""
Helper class to define & retrieve user properties
...
...
@@ -314,9 +315,9 @@ class MantidConfigDirectInelastic(object):
#Always replace sample file if it has not been touched
start_date
=
self
.
_user
.
start_date
# this time is set up to the file, copied from the repository
sample
_file_time
=
time
.
mktime
(
start_date
.
timetuple
())
unmodified
_file_time
=
time
.
mktime
(
start_date
.
timetuple
())
targ_file_time
=
os
.
path
.
getmtime
(
target_script_name
)
if
sample
_file_time
==
targ_file_time
:
if
unmodified
_file_time
==
targ_file_time
:
return
True
else
:
# somebody have modified the target file. Leave it alone
return
False
...
...
@@ -345,9 +346,9 @@ class MantidConfigDirectInelastic(object):
"""
if
users_file_description
is
None
:
users_file_description
=
self
.
_user_files_descr
files
_to_copy
=
self
.
_parse_user_files_description
(
users_file_description
)
for
files
in
files
_to_copy
:
self
.
_copy_user_file_job
(
files
[
0
],
files
[
1
],
files
[
2
])
info
_to_copy
=
self
.
_parse_user_files_description
(
users_file_description
)
for
info
in
info
_to_copy
:
self
.
_copy_user_file_job
(
info
[
0
],
info
[
1
],
info
[
2
])
def
_copy_and_parse_user_file
(
self
,
input_file
,
output_file
,
replacemets_list
):
...
...
@@ -690,6 +691,11 @@ class MantidConfigDirectInelastic(object):
os
.
system
(
'
chown -R {0}:{0} {1}
'
.
format
(
self
.
_fedid
,
config_file_name
))
if
__name__
==
"
__main__
"
:
if
len
(
sys
.
argv
)
<=
1
:
print
"
usage: Config instrument cycle_ID rb_number user_id start_date
"
exit
()
inp
=
{}
if
len
(
sys
.
argv
)
<
5
:
inp
[
"
inst_name
"
]
=
str
(
raw_input
(
'
Enter instrument name:
'
).
upper
())
inp
[
"
cycleID
"
]
=
int
(
raw_input
(
'
Enter cycle ID as 3 digit number (e.g. 153 for cycle 2015/3):
'
))
...
...
@@ -703,16 +709,19 @@ if __name__ == "__main__":
inp
[
"
userID
"
]
=
str
(
sys
.
argv
[
4
])
inp
[
"
startDate
"
]
=
str
(
sys
.
argv
[
5
])
# cast to int to test RB
inp
[
"
cycleID
"
]
=
"
CYCLE20{0}
"
.
format
(
inp
[
"
cycleID
"
])
if
platform
.
system
()
==
'
Windows
'
:
sys
.
path
.
insert
(
0
,
'
c:/Mantid/scripts/Inelastic/Direct
'
)
base
=
'
d:/Data/Mantid_Testing/config_script_test_folder
'
analysisDir
=
base
MantidDir
=
r
"
c:\Mantid\_builds\br_master\bin\Release
"
UserScriptRepoDir
=
os
.
path
.
join
(
analysisDir
,
"
UserScripts
"
)
MapMaskDir
=
os
.
path
.
join
(
analysisDir
,
"
InstrumentFiles
"
)
# windebug base folder
base
=
'
d:/Data/Mantid_Testing/config_script_test_folder
'
rootDir
=
os
.
path
.
join
(
base
,
'
users
'
)
analysisDir
=
base
else
:
sys
.
path
.
insert
(
0
,
'
/opt/Mantid/scripts/Inelastic/Direct/
'
)
#sys.path.insert(0,'/opt/mantidnightly/scripts/Inelastic/Direct/')
...
...
@@ -735,12 +744,13 @@ if __name__ == "__main__":
user
=
UserProperties
(
inp
[
"
userID
"
])
rb_user_folder
=
os
.
path
.
join
(
mcf
.
_home_path
,
inp
[
"
userID
"
],
str
(
inp
[
"
rbNum
"
]))
rb_user_folder
=
os
.
path
.
join
(
mcf
.
_home_path
,
inp
[
"
userID
"
],
'
RB
'
+
str
(
inp
[
"
rbNum
"
]))
# rb folder must be present!
current_
user
.
set_user_properties
(
inp
[
"
inst_name
"
],
inp
[
"
startDate
"
],
inp
[
"
cycleID
"
],
rb_user_folder
)
user
.
set_user_properties
(
inp
[
"
inst_name
"
],
inp
[
"
startDate
"
],
inp
[
"
cycleID
"
],
rb_user_folder
)
mcf
.
init_user
(
user
)
mcf
.
generate_config
()
print
"
Successfully Configured user:
"
,
inp
[
"
userID
"
],
"
for instrument:
"
,
inp
[
"
inst_name
"
]
This diff is collapsed.
Click to expand it.
scripts/test/User_files_description_test.xml
+
1
−
1
View file @
5e71ea82
...
...
@@ -18,7 +18,7 @@
<!--Advanced file copying
Variables have to be either strings or strings with variables, described above
-->
-->
<file_to_copy
file_name=
"Test_reduction_file.py"
copy_as=
"Test_reduction_file_$cycleID$.py"
>
<replace
var =
"Test_reduction_file"
by_var=
"$instrument$Test_reduction_file_$cycleID$"
/>
<replace
var =
"AAAA"
by_var=
"BBB"
/>
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment