Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CastorScript
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Jira
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
atlas-tdaq-software
CastorScript
Commits
52350a60
Commit
52350a60
authored
14 years ago
by
Wainer Vandelli
Browse files
Options
Downloads
Patches
Plain Diff
Merged file migration modules implementing the new naming convention
parent
d3f278a5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Script/MergedMigratedNew.py
+99
-0
99 additions, 0 deletions
Script/MergedMigratedNew.py
with
99 additions
and
0 deletions
Script/MergedMigratedNew.py
0 → 100644
+
99
−
0
View file @
52350a60
#!/bin/env python
__version__
=
'
$Revision:$
'
# $Source$
from
SFOFileNameParser
import
SFOFileNameParser
import
os.path
import
sys
from
subprocess
import
*
BASEDIR
=
'
/castor/cern.ch/grid/atlas/tzero/prod1/perm/
'
def
nsls
(
target
,
castorenv
,
opts
=
[]):
command
=
[
'
nsls
'
]
command
.
extend
(
opts
)
command
.
append
(
target
)
kwds
=
{}
if
castorenv
:
kwds
[
'
env
'
]
=
castorenv
nsls
=
Popen
(
command
,
stdout
=
PIPE
,
stderr
=
STDOUT
,
**
kwds
)
nslsOut
,
_
=
nsls
.
communicate
()
ret
=
nsls
.
wait
()
return
((
ret
==
0
),
nslsOut
)
def
MergedMigratedNew
(
castorfile
,
castorenv
):
"""
Destination directory:
/<basedir>/<projecttag>/<streamtype_streamname>/<runnr-7digit>/<dataset>/
basedir = /castor/cern.ch/grid/atlas/tzero/prod1/perm/
projecttag = data09_cos
dataset = data09_cos.00122050.physics_IDCosmic.merge.RAW
Merged file name is:
1) if all SFO files of a LB fit into a single file
<project>.<runnr>.<stream>.daq.RAW._lbXXXX._SFO-N._<fileseqnr>.data, N=4,5,9,10
--> <project>.<runnr>.<stream>.merge.RAW._lbXXXX._SFO-ALL._0001.<attemptnr>
2) if all SFO files of a LB don
'
t fit into a single file
<project>.<runnr>.<stream>.daq.RAW._lbXXXX._SFO-N._<fileseqnr>.data, N=4,5,9,10
--> <project>.<runnr>.<stream>.merge.RAW._lbXXXX._SFO-N._<fileseqnr>.<attemptnr>, N=4,5,9,10
"""
### Build the target directory name
parsed
=
SFOFileNameParser
(
os
.
path
.
basename
(
castorfile
))
dataset
=
'
%s.%s.%s_%s.merge.RAW
'
\
%
(
parsed
.
ProjectTag
(),
parsed
.
RunNr
(),
\
parsed
.
StreamType
(),
parsed
.
StreamName
())
path
=
os
.
path
.
join
(
BASEDIR
,
parsed
.
ProjectTag
(),
\
'
%s_%s
'
%
(
parsed
.
StreamType
(),
parsed
.
StreamName
()),
\
'
%07d
'
%
int
(
parsed
.
RunNr
()),
\
'
%s
'
%
dataset
)
### Look for files into the dataset dir
success
,
all_files
=
nsls
(
path
,
castorenv
)
### If fails, return false
if
not
success
:
return
False
### Create the two type of name we expect (neglecting attempt number)
notmerged
=
os
.
path
.
basename
(
castorfile
).
splitext
()[
0
]
merged
=
'
.
'
.
join
(
notmerged
.
split
(
'
.
'
,
6
)[:
-
1
]
+
[
'
_SFO-ALL._0001
'
])
### Find all the files with the correct name
files
=
[
f
for
f
in
all_files
.
split
(
'
\n
'
)
if
f
and
(
notmerged
in
f
or
merged
in
f
)]
if
not
files
:
return
False
### Take the file with the highest attempt number
file
=
sorted
([(
int
(
f
.
rsplit
(
'
.
'
,
1
)[
1
]),
f
)
for
f
in
files
])[
-
1
][
1
]
### Check the migration status for the file
success
,
out
=
nsls
(
os
.
path
.
join
(
path
,
file
),
\
castorenv
,
opts
=
[
'
-l
'
])
if
success
and
'
m
'
in
out
.
split
(
'
'
)[
0
]:
return
True
else
:
return
False
if
__name__
==
'
__main__
'
:
print
MergedMigrated
(
sys
.
argv
[
1
],
''
)
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