Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
Connecting B2DROP for HPC
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marvin Winkens
Connecting B2DROP for HPC
Commits
698fdf54
Commit
698fdf54
authored
2 years ago
by
Marvin Winkens
Browse files
Options
Downloads
Patches
Plain Diff
first init
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+3
-0
3 additions, 0 deletions
.gitignore
fingerhuete.py
+83
-0
83 additions, 0 deletions
fingerhuete.py
webdavsync.py
+33
-0
33 additions, 0 deletions
webdavsync.py
with
119 additions
and
0 deletions
.gitignore
0 → 100644
+
3
−
0
View file @
698fdf54
fingerhuete_*/
__pycache__
.idea
This diff is collapsed.
Click to expand it.
fingerhuete.py
0 → 100644
+
83
−
0
View file @
698fdf54
from
rembg
import
remove
from
webdavsync
import
pull
,
push
,
get_info
,
list_b2drop
from
rembg
import
remove
as
remove_bg
import
os
import
threading
import
time
cloud_path_in
=
"
Fingerhüte-Roh
"
local_path_in
=
"
./fingerhuete_in2
"
local_path_out
=
"
./fingerhuete_processed2
"
cloud_path_out
=
"
Fingerhüte_processed2
"
def
process_single
(
path_in
,
path_out
):
with
open
(
path_in
,
'
rb
'
)
as
i
:
with
open
(
path_out
,
'
wb
'
)
as
o
:
img
=
i
.
read
()
output
=
remove_bg
(
img
)
o
.
write
(
output
)
def
process
(
path_in
,
path_out
):
tries
=
0
while
tries
!=
5
:
tries
+=
1
prefix
=
"
rembg_
"
already_processed
=
set
(
os
.
listdir
(
path_out
))
already_processed_original
=
{
name
[
len
(
prefix
):]
for
name
in
already_processed
}
all_processable
=
set
(
os
.
listdir
(
path_in
))
to_process
=
all_processable
-
already_processed_original
print
(
f
'
processing
{
len
(
to_process
)
}
files
'
)
if
len
(
to_process
)
==
0
:
print
(
"
trying again in 10 seconds
"
)
time
.
sleep
(
10
)
continue
tries
=
0
for
fname
in
to_process
:
try
:
process_single
(
f
"
{
path_in
}
/
{
fname
}
"
,
f
"
{
path_out
}
/
{
prefix
}{
fname
}
"
)
except
Exception
as
e
:
print
(
f
"
error while processing file
{
fname
}
"
)
print
(
e
)
def
pull_data
():
pull
(
cloud_path_in
,
local_path_in
)
def
push_data
():
push_count
=
0
while
push_count
!=
5
:
push_count
+=
1
try
:
do_push
=
push
(
cloud_path_out
,
local_path_out
)
if
do_push
:
push_count
=
0
except
Exception
as
e
:
print
(
e
)
push_count
=
0
time
.
sleep
(
60
)
# sleep for a minute
def
main
():
# b2drop_list = list_b2drop()
# for el in b2drop_list:
# print(el["path"])
t1
=
threading
.
Thread
(
target
=
pull_data
)
t2
=
threading
.
Thread
(
target
=
process
,
args
=
(
local_path_in
,
local_path_out
))
t3
=
threading
.
Thread
(
target
=
push_data
)
t1
.
start
()
t2
.
start
()
t3
.
start
()
t1
.
join
()
print
(
"
finished pulling
"
)
t2
.
join
()
print
(
"
finished processing
"
)
t3
.
join
()
print
(
"
finished pushing
"
)
if
__name__
==
"
__main__
"
:
main
()
This diff is collapsed.
Click to expand it.
webdavsync.py
0 → 100644
+
33
−
0
View file @
698fdf54
from
webdav3.client
import
Client
username
=
"
1686b184-4d7a-45ba-8cba-4c8aef619886
"
options
=
{
'
webdav_hostname
'
:
f
"
https://b2drop.eudat.eu/remote.php/dav/files/
{
username
}
"
,
'
webdav_login
'
:
username
,
'
webdav_password
'
:
"
CYFfS-Ff7FG-yke27-XkjTe-dWJrw
"
,
'
verbose
'
:
True
,
'
webdav_timeout
'
:
60
*
4
,
# 10 minutes
}
client
=
Client
(
options
)
def
list_b2drop
():
return
client
.
list
(
get_info
=
True
)
def
get_info
(
cloud_path
:
str
):
return
client
.
info
(
cloud_path
)
def
pull
(
cloud_path
,
local_path
):
return
client
.
pull
(
cloud_path
,
local_path
)
def
push
(
cloud_path
,
local_path
):
return
client
.
push
(
cloud_path
,
local_path
)
def
upload
(
cloud_path
,
local_path
):
return
client
.
upload
(
cloud_path
,
local_path
)
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