Commit 1e98674e authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

Read camogm.disk, get the footage size from it and download all if n==0

parent e9c39d0f
......@@ -18,6 +18,7 @@ import argparse
import os
import sys
import time
import math
import x393
from x393 import bcolors
......@@ -135,6 +136,20 @@ for i in range(len(cams)):
for d in dirs:
for p in plist:
if d==p[0]:
# p[1] == sdb2
# hardcoded /dev/sd?1
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("Download size: "+str(n_chunks)+"x "+str(round(chunk_size,2))+"GB, skipped the first "+str(args.skip)+" chunks")
pc.download(args.dest,"/dev/"+p[1],args.bs,args.bc,args.skip,args.n)
dirs.remove(d)
proceed_to_next = True
......
......@@ -10,6 +10,7 @@ import os
import re
import subprocess
import time
import tempfile
def shout(cmd):
#subprocess.call prints to console
......@@ -170,6 +171,34 @@ class PC():
plist.append([name[len(self.pattern):],item[-1]])
return plist
# mounts partition (/dev/sd?1), reads camogm.disk file
# returns the download size from raw partition ((/dev/sd?2))
def read_camogm_disk_file(self,part):
result = ""
tmp_mount_point = tempfile.mkdtemp()
print("mounting "+part+" to "+tmp_mount_point)
shout("sudo mount "+part+" "+tmp_mount_point)
try:
with open (tmp_mount_point+"/camogm.disk", "r") as myfile:
data=myfile.readlines()
if len(data)==2:
l2 = data[1]
pointers = l2.split("\t")
pntr1 = int(pointers[1])
pntr2 = int(pointers[2])
result = float(pntr2-pntr1)*512/1024/1024/1024
except IOError:
print(tmp_mount_point+"/camogm.disk NOT FOUND")
shout("sudo umount "+tmp_mount_point)
os.rmdir(tmp_mount_point)
return result
def is_raw(self,part):
res = shout("sudo blkid | grep "+str(part))
typ = "TYPE="
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment