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
153e18de
Commit
153e18de
authored
6 years ago
by
Gary Ruben
Browse files
Options
Downloads
Patches
Plain Diff
Replaced os.system with subprocess.run and added node.processed flag
parent
26f112fa
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
asci_to_vault.py
+18
-5
18 additions, 5 deletions
asci_to_vault.py
with
18 additions
and
5 deletions
asci_to_vault.py
+
18
−
5
View file @
153e18de
...
@@ -10,6 +10,7 @@ import os
...
@@ -10,6 +10,7 @@ import os
import
warnings
import
warnings
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
import
pathlib
import
pathlib
import
subprocess
# This isn't suppressing the warnings that fabric is generating; we need to
# This isn't suppressing the warnings that fabric is generating; we need to
# investigate further
# investigate further
...
@@ -26,6 +27,7 @@ KERNEL_CHECKSUM=$(cpio --to-stdout -i kernel.fat16 < archive.cpio | sha256sum |
...
@@ -26,6 +27,7 @@ KERNEL_CHECKSUM=$(cpio --to-stdout -i kernel.fat16 < archive.cpio | sha256sum |
"""
"""
REMOTE_LOGIN
=
"
gary.ruben@monash.edu@sftp.synchrotron.org.au
"
REMOTE_LOGIN
=
"
gary.ruben@monash.edu@sftp.synchrotron.org.au
"
# SRC_PATH = "/data/13660a/asci/input"
SRC_PATH
=
"
/data/13660a/asci/output/tar_test
"
SRC_PATH
=
"
/data/13660a/asci/output/tar_test
"
DEST_PATH
=
"
/home/grub0002/bapcxi/vault/rubbish
"
DEST_PATH
=
"
/home/grub0002/bapcxi/vault/rubbish
"
...
@@ -34,6 +36,7 @@ DEST_PATH = "/home/grub0002/bapcxi/vault/rubbish"
...
@@ -34,6 +36,7 @@ DEST_PATH = "/home/grub0002/bapcxi/vault/rubbish"
class
Node
:
class
Node
:
src
:
str
src
:
str
dest
:
str
dest
:
str
processed
:
bool
=
False
def
tar_and_send_directory
(
node
):
def
tar_and_send_directory
(
node
):
...
@@ -57,16 +60,21 @@ def tar_and_send_directory(node):
...
@@ -57,16 +60,21 @@ def tar_and_send_directory(node):
files
=
files
.
stdout
.
strip
()
files
=
files
.
stdout
.
strip
()
count
=
files
.
count
(
'
/
'
)
count
=
files
.
count
(
'
/
'
)
print
(
f
'
Node:
{
node
.
src
}
, file count:
{
count
}
'
)
if
count
==
0
:
if
count
==
0
:
# No files at this node, just return
# No files at this node, just return
return
pass
elif
count
==
1
:
elif
count
==
1
:
# Only one file. No need to tar. Just copy unchanged.
# Only one file. No need to tar. Just copy unchanged.
o
s
.
system
(
o
utput
=
subprocess
.
run
(
f
"
ssh
{
REMOTE_LOGIN
}
'
cd
{
node
.
src
}
;
"
f
"
ssh
{
REMOTE_LOGIN
}
'
cd
{
node
.
src
}
;
"
f
"
find -type f -maxdepth 1 | cpio -o
'
|
"
f
"
find -type f -maxdepth 1 | cpio -o
'
|
"
f
"
cat >
{
node
.
dest
}
/
{
files
}
"
f
"
cat >
{
node
.
dest
}
/
{
files
}
"
,
shell
=
True
,
check
=
True
)
)
print
(
'
stdout:
'
,
output
.
stdout
)
print
(
'
stderr:
'
,
output
.
stderr
)
os
.
chmod
(
f
'
{
node
.
dest
}
/
{
files
}
'
,
0o550
)
os
.
chmod
(
f
'
{
node
.
dest
}
/
{
files
}
'
,
0o550
)
print
(
f
'
transfer
{
node
.
src
}
->
{
node
.
dest
}
'
)
print
(
f
'
transfer
{
node
.
src
}
->
{
node
.
dest
}
'
)
else
:
else
:
...
@@ -76,14 +84,19 @@ def tar_and_send_directory(node):
...
@@ -76,14 +84,19 @@ def tar_and_send_directory(node):
else
:
else
:
filename
=
node
.
src
.
replace
(
SRC_PATH
+
'
/
'
,
''
).
replace
(
'
/
'
,
'
_
'
)
filename
=
node
.
src
.
replace
(
SRC_PATH
+
'
/
'
,
''
).
replace
(
'
/
'
,
'
_
'
)
o
s
.
system
(
o
utput
=
subprocess
.
run
(
f
"
ssh
{
REMOTE_LOGIN
}
'
cd
{
node
.
src
}
;
"
f
"
ssh
{
REMOTE_LOGIN
}
'
cd
{
node
.
src
}
;
"
f
"
find -type f -maxdepth 1 -print0 | cpio -o -H ustar -0
'
|
"
f
"
find -type f -maxdepth 1 -print0 | cpio -o -H ustar -0
'
|
"
f
"
cat >
{
node
.
dest
}
/
{
filename
}
.tar
"
f
"
cat >
{
node
.
dest
}
/
{
filename
}
.tar
"
,
shell
=
True
,
check
=
True
)
)
print
(
'
stdout:
'
,
output
.
stdout
)
print
(
'
stderr:
'
,
output
.
stderr
)
os
.
chmod
(
f
'
{
node
.
dest
}
/
{
filename
}
.tar
'
,
0o550
)
os
.
chmod
(
f
'
{
node
.
dest
}
/
{
filename
}
.tar
'
,
0o550
)
print
(
f
'
transfer
{
node
.
src
}
->
{
node
.
dest
}
'
)
print
(
f
'
transfer
{
node
.
src
}
->
{
node
.
dest
}
'
)
node
.
processed
=
True
if
__name__
==
"
__main__
"
:
if
__name__
==
"
__main__
"
:
# Get the directory tree from remote server as a list
# Get the directory tree from remote server as a list
...
...
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