Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
elphel-tools-x393
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Elphel
elphel-tools-x393
Commits
3ff00693
Commit
3ff00693
authored
Jul 27, 2023
by
Andrey Filippov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
implemented transfer over ssh (10x slower), restored input(), forced python3
parent
5e1a0164
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
209 additions
and
55 deletions
+209
-55
int_ssd_download.py
int_ssd_download.py
+65
-45
x393.py
x393.py
+144
-10
No files found.
int_ssd_download.py
View file @
3ff00693
#!/usr/bin/env python
#!/usr/bin/env python
3
# Download footage from ssd's raw partition:
# * standalone SSDs connected using a docking station or enclosure or else, raw partition, camera can be powered off
...
...
@@ -72,6 +72,7 @@ parser.add_argument("-bc",type=int,default=512,help="Number of blocks of size [b
parser
.
add_argument
(
"-fs"
,
"--file_start"
,
default
=
""
,
help
=
".disk file name with start LBA pointer, will calculate 'skip' value"
)
parser
.
add_argument
(
"-fe"
,
"--file_end"
,
default
=
"camogm.disk"
,
help
=
".disk file name with end LBA pointer, default is 'camogm.disk'"
)
parser
.
add_argument
(
"dest"
,
help
=
"desitnation directory: /data/footage/test"
)
parser
.
add_argument
(
"-l"
,
"--lan"
,
action
=
'store_true'
,
help
=
"Transfer data over LAN instead of eSATA"
)
args
=
parser
.
parse_args
()
print
(
args
)
...
...
@@ -106,13 +107,18 @@ if len(cams)==0:
pc
=
x393
.
PC
()
if
(
args
.
lan
):
print
(
"Using data transfer over LAN"
)
else
:
print
(
"Using data transfer over eSATA, multiplexing camera SSD to eSATA external port"
)
# ssd to camera for all
for
cam
in
cams
:
for
cam
in
cams
:
cam
[
'obj'
]
.
ssd_to_camera
()
# get raw partitions
# get raw partitions
for
cam
in
cams
:
d
=
cam
[
'obj'
]
.
first_found_raw_partition_name
()
d
=
cam
[
'obj'
]
.
first_found_raw_partition_name
()
# ssh
if
d
!=
"undefined"
:
dirs
.
append
(
d
)
print
(
cam
[
'user'
]
+
"@"
+
cam
[
'ip'
]
+
": raw partition name: "
+
d
)
...
...
@@ -120,12 +126,12 @@ for cam in cams:
cam
[
'disable'
]
=
1
print
(
bcolors
.
FAIL
+
cam
[
'user'
]
+
"@"
+
cam
[
'ip'
]
+
" : error: already switched or raw partition not found"
+
bcolors
.
ENDC
)
#raise Exception(cam['user']+"@"+cam['ip']+" : error: already switched or raw partition not found")
# no need
cams
[:]
=
[
tmp
for
tmp
in
cams
if
tmp
.
get
(
'disable'
)
!=
1
]
# no need
cams
[:]
=
[
tmp
for
tmp
in
cams
if
tmp
.
get
(
'disable'
)
!=
1
]
# switch ssd to pc for all (not caring which cable is in)
for
cam
in
cams
:
if
(
not
args
.
lan
):
# switch ssd to pc for all (not caring which cable is in)
for
cam
in
cams
:
cam
[
'obj'
]
.
ssd_to_pc
()
# download
...
...
@@ -133,18 +139,35 @@ for cam in cams:
plist
=
[]
all_downloaded
=
False
for
i
in
range
(
len
(
cams
)):
raw_input
(
bcolors
.
OKGREEN
+
"Connect camera (eSATA) to PC (eSATA/SATA). Press Enter to continue..."
+
bcolors
.
ENDC
)
#for i in range(len(cams)):
for
i
,
cam
in
enumerate
(
cams
):
# raw_input(bcolors.OKGREEN+"Connect camera (eSATA) to PC (eSATA/SATA). Press Enter to continue..."+bcolors.ENDC)
if
(
args
.
lan
):
print
(
bcolors
.
OKGREEN
+
"Initiating data transfer over LAN ..."
+
bcolors
.
ENDC
)
else
:
input
(
bcolors
.
OKGREEN
+
"Connect camera (eSATA) to PC (eSATA/SATA). Press Enter to continue..."
+
bcolors
.
ENDC
)
proceed_to_next
=
False
t
=
0
while
not
all_downloaded
:
plist
=
pc
.
list_partitions
()
if
(
args
.
lan
):
plist
=
cam
[
'obj'
]
.
list_partitions_as_host
()
# Camera partitions, same format as for host (label, path)
#[['NT-1TB_2242_0007988000104', 'sda'], ['NT-1TB_2242_0007988000104-part1', 'sda1'], ['NT-1TB_2242_0007988000104-part2', 'sda2']]
else
:
plist
=
pc
.
list_partitions
()
# HOST(!) partitions, such as /dev/sdc1
#[[u'NT-1TB_2242_0007988000104', u'sdc'], [u'NT-1TB_2242_0007988000104-part1', u'sdc1'], [u'NT-1TB_2242_0007988000104-part2', u'sdc2']]
for
d
in
dirs
:
for
p
in
plist
:
if
d
==
p
[
0
]:
# p[1] == sdb2
# hardcoded /dev/sd?1
if
args
.
n
==
0
:
if
(
args
.
lan
):
# data_size_blocks = pc.read_camogm_disk_file_blocks_lan(cams[i].ip, p[1][0:-1]+"1", args.file_end)
# data_skip_blocks = pc.read_camogm_disk_file_blocks_lan(cams[i].ip, p[1][0:-1]+"1", args.file_start)
data_size_blocks
=
cam
[
'obj'
]
.
read_camogm_disk_file_blocks
(
p
[
1
][
0
:
-
1
]
+
"1"
,
args
.
file_end
)
data_skip_blocks
=
cam
[
'obj'
]
.
read_camogm_disk_file_blocks
(
p
[
1
][
0
:
-
1
]
+
"1"
,
args
.
file_start
)
#read_camogm_disk_file_blocks
else
:
data_size_blocks
=
pc
.
read_camogm_disk_file_blocks
(
"/dev/"
+
p
[
1
][
0
:
-
1
]
+
"1"
,
args
.
file_end
)
data_skip_blocks
=
pc
.
read_camogm_disk_file_blocks
(
"/dev/"
+
p
[
1
][
0
:
-
1
]
+
"1"
,
args
.
file_start
)
data_size_blocks
-=
data_skip_blocks
# before it included skipped !
...
...
@@ -159,33 +182,30 @@ for i in range(len(cams)):
data_size_gb
=
(
data_size_blocks
*
block_size
)
/
(
1024
*
1024
*
1024
)
file_gb
=
args
.
bs
*
args
.
bc
//
1024
# just for compatibility, change to parameter
print
(
"Data size:
%
d
%
d-byte blocks (
%
f GB)"
%
(
data_size_blocks
,
block_size
,
data_size_gb
))
pc
.
download_blocks
(
args
.
dest
,
# def download_blocks(self, dest, part, blocks_load, blocks_skip= 0, file_gb=10, chunk_blocks=32768, block_size=512):
if
(
args
.
lan
):
print
(
cam
)
pc
.
download_blocks_lan
(
cam
,
args
.
dest
,
"/dev/"
+
p
[
1
],
blocks_load
=
data_size_blocks
,
blocks_skip
=
data_skip_blocks
,
file_gb
=
file_gb
,
chunk_blocks
=
chunk_blocks
,
block_size
=
block_size
)
else
:
pc
.
download_blocks
(
# after testing use download_blocks_lan (rename/delete download_blocks) with cam=None
args
.
dest
,
"/dev/"
+
p
[
1
],
blocks_load
=
data_size_blocks
,
blocks_skip
=
data_skip_blocks
,
file_gb
=
file_gb
,
chunk_blocks
=
chunk_blocks
,
block_size
=
block_size
)
'''
data_size = pc.read_camogm_disk_file("/dev/"+p[1][0:-1]+"1")
data_size = round(data_size,2)
# bs is in kB
chunk_size = float(args.bs*args.bc)/1024
n_chunks = int(math.ceil(data_size/chunk_size))
if args.n==0:
args.n = n_chunks - args.skip
print("Data size: "+str(data_size)+" GB")
print(bcolors.BOLDWHITE+"Download size: "+str(args.n)+"x "+str(round(chunk_size,2))+"GB, skipped the first "+str(args.skip)+" chunks"+bcolors.ENDC)
pc.download (args.dest, "/dev/"+p[1], args.bs,args.bc,args.skip,args.n)
'''
# def download(self,dest,part,dl_bs=20,dl_bc=512,dl_skip=0,dl_n=0):
#parser.add_argument("-bs",type=int,default=20,help="block size in MB, default = 20")
#parser.add_argument("-bc",type=int,default=512,help="Number of blocks of size [bs] in a single chunk, default = 512, so the default chunk size is 10GB")
dirs
.
remove
(
d
)
proceed_to_next
=
True
if
len
(
dirs
)
!=
0
:
if
len
(
dirs
)
!=
0
:
print
(
"wait for the next ssd"
)
else
:
all_downloaded
=
True
...
...
x393.py
View file @
3ff00693
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment