Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
G
gopro
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tony Mai
gopro
Commits
741cbd8b
Commit
741cbd8b
authored
Aug 01, 2019
by
Tony Mai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
e316f46f
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
318 additions
and
77 deletions
+318
-77
wireless_copy_files_to_backup.py
fusion/scripts/wireless_copy_files_to_backup.py
+96
-77
wireless_copy_files_to_backup.py
python/wireless_copy_files_to_backup.py
+124
-0
wireless_copy_files_to_nfs.py
python/wireless_copy_files_to_nfs.py
+98
-0
No files found.
fusion/scripts/wireless_copy_files_to_backup.py
View file @
741cbd8b
...
...
@@ -9,84 +9,103 @@ import sys
import
re
import
time
log_ptr
=
None
def
msg
(
str
):
global
log_ptr
if
log_ptr
!=
None
:
log_ptr
=
str
else
:
print
(
str
)
def
run
(
filename
,
ptr
=
None
):
if
(
ptr
):
log_ptr
=
ptr
if
len
(
sys
.
argv
)
<
2
:
print
(
"Usage cp_fusion_files.py <destination directory> "
)
exit
()
file_path
=
"/backup/"
+
sys
.
argv
[
1
]
file_path
=
"/backup/"
+
filename
if
os
.
path
.
isdir
(
file_path
):
print
(
"directroy exist "
+
file_path
+
" exiting.."
)
if
os
.
path
.
isdir
(
file_path
):
msg
(
"directroy exist "
+
file_path
+
" exiting.."
)
exit
()
elif
os
.
path
.
exists
(
file_path
):
print
(
"file exist "
+
file_path
+
" exiting.."
)
elif
os
.
path
.
exists
(
file_path
):
msg
(
"file exist "
+
file_path
+
" exiting.."
)
exit
()
os
.
system
(
"mkdir "
+
file_path
)
print
(
"mkdir "
+
file_path
)
os
.
system
(
"mkdir "
+
file_path
)
print
(
"mkdir "
+
file_path
)
if
os
.
system
(
"ifconfig wlan1 | grep inet"
)
==
""
:
print
(
"wlan1 not connected to Gopro SSID. exiting..."
)
if
os
.
system
(
"ifconfig wlan1 | grep inet"
)
==
""
:
msg
(
"wlan1 not connected to Gopro SSID. exiting..."
)
exit
()
gpCam
=
GoProCamera
.
GoPro
()
gpCam
.
pair
(
usepin
=
False
)
#gpCam.pair(usepin=True)
gpCam
=
GoProCamera
.
GoPro
()
gpCam
.
pair
(
usepin
=
False
)
#gpCam.pair(usepin=True)
if
not
os
.
path
.
exists
(
file_path
):
if
not
os
.
path
.
exists
(
file_path
):
os
.
makedirs
(
file_path
);
print
(
"Start..."
)
msg
(
"Start..."
)
localtime
=
time
.
asctime
(
time
.
localtime
(
time
.
time
())
)
start_time
=
time
.
time
()
print
(
"Start time :"
,
localtime
)
gpCam
.
overview
()
#print
(gpCam.getMedia())
#print
(gpCam.getMediaInfo("file"))
gpCam
.
listMedia
(
True
)
#exit()
localtime
=
time
.
asctime
(
time
.
localtime
(
time
.
time
())
)
start_time
=
time
.
time
()
msg
(
"Start time :"
,
localtime
)
gpCam
.
overview
()
#msg
(gpCam.getMedia())
#msg
(gpCam.getMediaInfo("file"))
gpCam
.
listMedia
(
True
)
#exit()
data
=
gpCam
.
listMedia
(
True
,
True
)
for
i
in
data
:
data
=
gpCam
.
listMedia
(
True
,
True
)
for
i
in
data
:
folder
=
i
[
0
]
if
not
os
.
path
.
exists
(
file_path
+
"/"
+
folder
):
os
.
makedirs
(
file_path
+
"/"
+
folder
);
mp4_file
=
i
[
1
]
lrv_file
=
re
.
sub
(
".MP4"
,
".LRV"
,
mp4_file
)
print
(
"copy "
+
folder
+
"/"
+
mp4_file
+
" to "
+
file_path
);
msg
(
"copy "
+
folder
+
"/"
+
mp4_file
+
" to "
+
file_path
);
gpCam
.
downloadMedia
(
folder
,
mp4_file
,
file_path
+
"/"
+
folder
+
"/"
+
mp4_file
)
print
(
"copy "
+
folder
+
"/"
+
lrv_file
+
" to "
+
file_path
);
msg
(
"copy "
+
folder
+
"/"
+
lrv_file
+
" to "
+
file_path
);
gpCam
.
downloadMedia
(
folder
,
lrv_file
,
file_path
+
"/"
+
folder
+
"/"
+
lrv_file
)
if
re
.
search
(
"GPBK"
,
mp4_file
)
or
re
.
search
(
"GB"
,
mp4_file
):
wav_file
=
re
.
sub
(
".MP4"
,
".WAV"
,
mp4_file
)
#print
("copy "+folder+"/"+wav_file+" to "+file_path);
#msg
("copy "+folder+"/"+wav_file+" to "+file_path);
gpCam
.
downloadMedia
(
folder
,
wav_file
,
file_path
+
"/"
+
folder
+
"/"
+
wav_file
)
if
re
.
search
(
"GPBK"
,
mp4_file
):
thm_file
=
re
.
sub
(
".MP4"
,
".THM"
,
mp4_file
)
#print
("copy "+folder+"/"+thm_file+" to "+file_path);
#msg
("copy "+folder+"/"+thm_file+" to "+file_path);
gpCam
.
downloadMedia
(
folder
,
thm_file
,
file_path
+
"/"
+
folder
+
"/"
+
thm_file
)
if
re
.
search
(
"GPFR"
,
mp4_file
):
thm_file
=
re
.
sub
(
".MP4"
,
".THM"
,
mp4_file
)
#print
("copy "+folder+"/"+thm_file+" to "+file_path);
#msg
("copy "+folder+"/"+thm_file+" to "+file_path);
gpCam
.
downloadMedia
(
folder
,
thm_file
,
file_path
+
"/"
+
folder
+
"/"
+
thm_file
)
print
(
"Done"
)
localtime
=
time
.
asctime
(
time
.
localtime
(
time
.
time
())
)
elapsed_time
=
time
.
time
()
-
start_time
print
(
"End time :"
,
localtime
)
msg
(
"Done"
)
localtime
=
time
.
asctime
(
time
.
localtime
(
time
.
time
())
)
elapsed_time
=
time
.
time
()
-
start_time
msg
(
"End time :"
,
localtime
)
hours
,
rem
=
divmod
(
elasped_time
,
3600
)
minutes
,
seconds
=
divmod
(
rem
,
60
)
print
(
"Elaspse time: "
+
"{:0>2}:{:0>2}:{:05.2f}"
.
format
(
int
(
hours
),
int
(
minutes
),
seconds
))
hours
,
rem
=
divmod
(
elasped_time
,
3600
)
minutes
,
seconds
=
divmod
(
rem
,
60
)
msg
(
"Elaspse time: "
+
"{:0>2}:{:0>2}:{:05.2f}"
.
format
(
int
(
hours
),
int
(
minutes
),
seconds
))
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
<
2
:
msg
(
"Usage cp_fusion_files.py <destination directory> "
)
exit
()
run
(
sys
.
argv
[
1
])
python/wireless_copy_files_to_backup.py
0 → 100755
View file @
741cbd8b
#!/usr/bin/python3
from
goprocam
import
GoProCamera
from
goprocam
import
constants
import
os
import
sys
import
re
import
time
import
netifaces
BACKUPPATH
=
"/backup"
log_ptr
=
None
def
msg
(
str
):
global
log_ptr
if
log_ptr
!=
None
:
log_ptr
=
str
else
:
print
(
str
)
def
run
(
folder_dst
=
None
,
ptr
=
None
):
global
BACKUPPATH
if
(
ptr
):
log_ptr
=
ptr
if
folder_dst
==
None
:
msg
(
"Generating generic folder..."
)
for
i
in
range
(
0
,
1000
):
folder_dst
=
BACKUPPATH
+
"/CP_"
+
str
(
i
)
#if not(os.path.isdir(BACKUPPATH+"/CP_"+str(i))) or not(os.path.exists(BACKUPPATH+"/CP_"+str(i))):
if
not
(
os
.
path
.
isdir
(
folder_dst
))
or
not
(
os
.
path
.
exists
(
folder_dst
)):
break
if
i
==
1000
:
msg
(
"Can not generate CP_[0:1000]"
)
return
else
:
msg
(
"Done"
)
elif
os
.
path
.
isdir
(
folder_dst
):
msg
(
"directroy exist "
+
folder_dst
+
" exiting.."
)
return
elif
os
.
path
.
exists
(
folder_dst
):
msg
(
"file exist "
+
folder_dst
+
" exiting.."
)
return
print
(
"mkdir "
+
folder_dst
)
#os.system("mkdir "+folder_dst)
#if not os.path.exists(folder_dst):
os
.
makedirs
(
folder_dst
);
msg
(
"Checking wlan1..."
)
try
:
print
(
netifaces
.
ifaddresses
(
'wlan1'
)[
netifaces
.
AF_INET
][
0
][
'addr'
])
except
:
msg
(
"wlan1 not connected to Gopro SSID. exiting..."
)
return
gpCam
=
GoProCamera
.
GoPro
()
gpCam
.
pair
(
usepin
=
False
)
#gpCam.pair(usepin=True)
msg
(
"Start..."
)
localtime
=
time
.
asctime
(
time
.
localtime
(
time
.
time
())
)
start_time
=
time
.
time
()
msg
(
"Start time :"
+
str
(
localtime
))
gpCam
.
overview
()
#msg(gpCam.getMedia())
#msg(gpCam.getMediaInfo("file"))
gpCam
.
listMedia
(
True
)
#exit()
data
=
gpCam
.
listMedia
(
True
,
True
)
for
i
in
data
:
folder
=
i
[
0
]
if
not
os
.
path
.
exists
(
folder_dst
+
"/"
+
folder
):
os
.
makedirs
(
folder_dst
+
"/"
+
folder
);
mp4_file
=
i
[
1
]
lrv_file
=
re
.
sub
(
".MP4"
,
".LRV"
,
mp4_file
)
msg
(
"copy "
+
folder
+
"/"
+
mp4_file
+
" to "
+
folder_dst
);
gpCam
.
downloadMedia
(
folder
,
mp4_file
,
folder_dst
+
"/"
+
folder
+
"/"
+
mp4_file
)
msg
(
"copy "
+
folder
+
"/"
+
lrv_file
+
" to "
+
folder_dst
);
gpCam
.
downloadMedia
(
folder
,
lrv_file
,
folder_dst
+
"/"
+
folder
+
"/"
+
lrv_file
)
if
re
.
search
(
"GPBK"
,
mp4_file
)
or
re
.
search
(
"GB"
,
mp4_file
):
wav_file
=
re
.
sub
(
".MP4"
,
".WAV"
,
mp4_file
)
#msg("copy "+folder+"/"+wav_file+" to "+folder_dst);
gpCam
.
downloadMedia
(
folder
,
wav_file
,
folder_dst
+
"/"
+
folder
+
"/"
+
wav_file
)
if
re
.
search
(
"GPBK"
,
mp4_file
):
thm_file
=
re
.
sub
(
".MP4"
,
".THM"
,
mp4_file
)
#msg("copy "+folder+"/"+thm_file+" to "+folder_dst);
gpCam
.
downloadMedia
(
folder
,
thm_file
,
folder_dst
+
"/"
+
folder
+
"/"
+
thm_file
)
if
re
.
search
(
"GPFR"
,
mp4_file
):
thm_file
=
re
.
sub
(
".MP4"
,
".THM"
,
mp4_file
)
#msg("copy "+folder+"/"+thm_file+" to "+folder_dst);
gpCam
.
downloadMedia
(
folder
,
thm_file
,
folder_dst
+
"/"
+
folder
+
"/"
+
thm_file
)
msg
(
"Done"
)
localtime
=
time
.
asctime
(
time
.
localtime
(
time
.
time
())
)
elapsed_time
=
time
.
time
()
-
start_time
msg
(
"End time :"
,
localtime
)
hours
,
rem
=
divmod
(
elasped_time
,
3600
)
minutes
,
seconds
=
divmod
(
rem
,
60
)
msg
(
"Elaspse time: "
+
"{:0>2}:{:0>2}:{:05.2f}"
.
format
(
int
(
hours
),
int
(
minutes
),
seconds
))
if
__name__
==
'__main__'
:
if
len
(
sys
.
argv
)
<
2
:
msg
(
"Usage cp_fusion_files.py <destination directory> "
)
exit
()
run
(
sys
.
argv
[
1
])
python/wireless_copy_files_to_nfs.py
0 → 100755
View file @
741cbd8b
#!/usr/bin/python3
from
goprocam
import
GoProCamera
from
goprocam
import
constants
import
os
import
sys
import
re
import
time
if
len
(
sys
.
argv
)
<
2
:
print
(
"Usage cp_fusion_files.py <destination directory> "
)
exit
()
file_path
=
"/nfs/ANGELICA/videos/"
+
sys
.
argv
[
1
]
os
.
system
(
"umount /nfs/ANGELICA/videos"
)
if
os
.
system
(
"mount 192.168.0.2:/mnt/user/videos /nfs/ANGELICA/videos"
)
!=
0
:
print
(
"fail to mount 192.168.0.2:/mnt/user/videos... exiting.."
)
exit
()
print
(
"192.168.0.2:/mnt/user/videos mounted..."
)
if
os
.
path
.
isdir
(
file_path
):
print
(
"directroy exist "
+
file_path
+
" exiting.."
)
exit
()
elif
os
.
path
.
exists
(
file_path
):
print
(
"file exist "
+
file_path
+
" exiting.."
)
exit
()
os
.
system
(
"mkdir "
+
file_path
)
print
(
"mkdir "
+
file_path
)
if
os
.
system
(
"ifconfig wlan1 | grep inet"
)
==
""
:
print
(
"wlan1 not connected to Gopro SSID. exiting..."
)
exit
()
gpCam
=
GoProCamera
.
GoPro
()
gpCam
.
pair
(
usepin
=
False
)
#gpCam.pair(usepin=True)
print
(
"Start..."
)
localtime
=
time
.
asctime
(
time
.
localtime
(
time
.
time
())
)
start_time
=
time
.
time
()
print
(
"Start time :"
,
localtime
)
gpCam
.
overview
()
#print(gpCam.getMedia())
#print(gpCam.getMediaInfo("file"))
gpCam
.
listMedia
(
True
)
data
=
gpCam
.
listMedia
(
True
,
True
)
for
i
in
data
:
folder
=
i
[
0
]
if
not
os
.
path
.
exists
(
file_path
+
"/"
+
folder
):
os
.
makedirs
(
file_path
+
"/"
+
folder
);
mp4_file
=
i
[
1
]
lrv_file
=
re
.
sub
(
".MP4"
,
".LRV"
,
mp4_file
)
print
(
"copy "
+
folder
+
"/"
+
mp4_file
+
" to "
+
file_path
);
gpCam
.
downloadMedia
(
folder
,
mp4_file
,
file_path
+
"/"
+
folder
+
"/"
+
mp4_file
)
print
(
"copy "
+
folder
+
"/"
+
lrv_file
+
" to "
+
file_path
);
gpCam
.
downloadMedia
(
folder
,
lrv_file
,
file_path
+
"/"
+
folder
+
"/"
+
lrv_file
)
if
re
.
search
(
"GPBK"
,
mp4_file
)
or
re
.
search
(
"GB"
,
mp4_file
):
wav_file
=
re
.
sub
(
".MP4"
,
".WAV"
,
mp4_file
)
#print("copy "+folder+"/"+wav_file+" to "+file_path);
gpCam
.
downloadMedia
(
folder
,
wav_file
,
file_path
+
"/"
+
folder
+
"/"
+
wav_file
)
if
re
.
search
(
"GPBK"
,
mp4_file
):
thm_file
=
re
.
sub
(
".MP4"
,
".THM"
,
mp4_file
)
#print("copy "+folder+"/"+thm_file+" to "+file_path);
gpCam
.
downloadMedia
(
folder
,
thm_file
,
file_path
+
"/"
+
folder
+
"/"
+
thm_file
)
if
re
.
search
(
"GPFR"
,
mp4_file
):
thm_file
=
re
.
sub
(
".MP4"
,
".THM"
,
mp4_file
)
#print("copy "+folder+"/"+thm_file+" to "+file_path);
gpCam
.
downloadMedia
(
folder
,
thm_file
,
file_path
+
"/"
+
folder
+
"/"
+
thm_file
)
print
(
"Done"
)
os
.
system
(
"umount /nfs/ANGELICA/videos"
)
localtime
=
time
.
asctime
(
time
.
localtime
(
time
.
time
())
)
elapsed_time
=
time
.
time
()
-
start_time
print
(
"End time :"
,
localtime
)
hours
,
rem
=
divmod
(
elapsed_time
,
3600
)
minutes
,
seconds
=
divmod
(
rem
,
60
)
print
(
"Elaspse time: "
+
"{:0>2}:{:0>2}:{:05.2f}"
.
format
(
int
(
hours
),
int
(
minutes
),
seconds
))
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