Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
remote_tree_to_local_tars
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
Gary Ruben
remote_tree_to_local_tars
Commits
26f112fa
Commit
26f112fa
authored
6 years ago
by
Gary Ruben
Browse files
Options
Downloads
Patches
Plain Diff
Changes to ignore empty nodes and tarring single files.
parent
711a751c
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#6908
failed
6 years ago
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
asci_to_vault.py
+31
-11
31 additions, 11 deletions
asci_to_vault.py
with
31 additions
and
11 deletions
asci_to_vault.py
+
31
−
11
View file @
26f112fa
...
...
@@ -51,18 +51,38 @@ def tar_and_send_directory(node):
e.g. /home/grub0002/bapcxi/vault/imbl2018
"""
if
node
.
src
==
SRC_PATH
:
filename
=
os
.
path
.
basename
(
node
.
src
)
# Check if there are any files in the node
with
Connection
(
REMOTE_LOGIN
)
as
c
:
files
=
c
.
run
(
f
'
cd
{
node
.
src
}
; find -type f -maxdepth 1
'
)
files
=
files
.
stdout
.
strip
()
count
=
files
.
count
(
'
/
'
)
if
count
==
0
:
# No files at this node, just return
return
elif
count
==
1
:
# Only one file. No need to tar. Just copy unchanged.
os
.
system
(
f
"
ssh
{
REMOTE_LOGIN
}
'
cd
{
node
.
src
}
;
"
f
"
find -type f -maxdepth 1 | cpio -o
'
|
"
f
"
cat >
{
node
.
dest
}
/
{
files
}
"
)
os
.
chmod
(
f
'
{
node
.
dest
}
/
{
files
}
'
,
0o550
)
print
(
f
'
transfer
{
node
.
src
}
->
{
node
.
dest
}
'
)
else
:
filename
=
node
.
src
.
replace
(
SRC_PATH
+
'
/
'
,
''
).
replace
(
'
/
'
,
'
_
'
)
os
.
system
(
f
"
ssh
{
REMOTE_LOGIN
}
'
cd
{
node
.
src
}
;
"
f
"
find -type f -maxdepth 1 -print0 | cpio -o -H ustar -0
'
|
"
f
"
cat >
{
node
.
dest
}
/
{
filename
}
.tar
"
)
os
.
chmod
(
f
'
{
node
.
dest
}
/
{
filename
}
.tar
'
,
0o550
)
print
(
f
'
transfer
{
node
.
src
}
->
{
node
.
dest
}
'
)
# More than one file. Transfer all files to a tarball.
if
node
.
src
==
SRC_PATH
:
filename
=
os
.
path
.
basename
(
node
.
src
)
else
:
filename
=
node
.
src
.
replace
(
SRC_PATH
+
'
/
'
,
''
).
replace
(
'
/
'
,
'
_
'
)
os
.
system
(
f
"
ssh
{
REMOTE_LOGIN
}
'
cd
{
node
.
src
}
;
"
f
"
find -type f -maxdepth 1 -print0 | cpio -o -H ustar -0
'
|
"
f
"
cat >
{
node
.
dest
}
/
{
filename
}
.tar
"
)
os
.
chmod
(
f
'
{
node
.
dest
}
/
{
filename
}
.tar
'
,
0o550
)
print
(
f
'
transfer
{
node
.
src
}
->
{
node
.
dest
}
'
)
if
__name__
==
"
__main__
"
:
...
...
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