Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
blender-addons
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
blender
blender-addons
Commits
464dd1a5
Commit
464dd1a5
authored
6 years ago
by
Vilem Duha
Browse files
Options
Downloads
Patches
Plain Diff
set a maximum number of retries for downloads.
parent
68639b4d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
blenderkit/download.py
+17
-8
17 additions, 8 deletions
blenderkit/download.py
blenderkit/ui_panels.py
+6
-0
6 additions, 0 deletions
blenderkit/ui_panels.py
with
23 additions
and
8 deletions
blenderkit/download.py
+
17
−
8
View file @
464dd1a5
...
@@ -475,12 +475,9 @@ def timer_update(): # TODO might get moved to handle all blenderkit stuff, not
...
@@ -475,12 +475,9 @@ def timer_update(): # TODO might get moved to handle all blenderkit stuff, not
if
len
(
file_names
)
==
2
:
# todo this should try to check if both files exist and are ok.
if
len
(
file_names
)
==
2
:
# todo this should try to check if both files exist and are ok.
shutil
.
copyfile
(
file_names
[
0
],
file_names
[
1
])
shutil
.
copyfile
(
file_names
[
0
],
file_names
[
1
])
print
(
'
appending asset
'
)
utils
.
p
(
'
appending asset
'
)
# progress bars:
# progress bars:
if
bpy
.
context
.
scene
[
'
search results
'
]
is
not
None
:
for
sres
in
bpy
.
context
.
scene
[
'
search results
'
]:
if
asset_data
[
'
id
'
]
==
sres
[
'
id
'
]:
sres
[
'
downloaded
'
]
=
100
# we need to check if mouse isn't down, which means an operator can be running.
# we need to check if mouse isn't down, which means an operator can be running.
# Especially for sculpt mode, where appending a brush during a sculpt stroke causes crasehes
# Especially for sculpt mode, where appending a brush during a sculpt stroke causes crasehes
#
#
...
@@ -495,6 +492,7 @@ def timer_update(): # TODO might get moved to handle all blenderkit stuff, not
...
@@ -495,6 +492,7 @@ def timer_update(): # TODO might get moved to handle all blenderkit stuff, not
done
=
try_finished_append
(
asset_data
,
**
tcom
.
passargs
)
done
=
try_finished_append
(
asset_data
,
**
tcom
.
passargs
)
if
not
done
:
if
not
done
:
at
=
asset_data
[
'
asset_type
'
]
at
=
asset_data
[
'
asset_type
'
]
tcom
.
passargs
[
'
retry_counter
'
]
=
tcom
.
passargs
.
get
(
'
retry_counter
'
,
0
)
+
1
if
at
in
(
'
model
'
,
'
material
'
):
if
at
in
(
'
model
'
,
'
material
'
):
download
(
asset_data
,
**
tcom
.
passargs
)
download
(
asset_data
,
**
tcom
.
passargs
)
elif
asset_data
[
'
asset_type
'
]
==
'
material
'
:
elif
asset_data
[
'
asset_type
'
]
==
'
material
'
:
...
@@ -503,7 +501,12 @@ def timer_update(): # TODO might get moved to handle all blenderkit stuff, not
...
@@ -503,7 +501,12 @@ def timer_update(): # TODO might get moved to handle all blenderkit stuff, not
download
(
asset_data
,
**
tcom
.
passargs
)
download
(
asset_data
,
**
tcom
.
passargs
)
elif
asset_data
[
'
asset_type
'
]
==
'
brush
'
or
asset_data
[
'
asset_type
'
]
==
'
texture
'
:
elif
asset_data
[
'
asset_type
'
]
==
'
brush
'
or
asset_data
[
'
asset_type
'
]
==
'
texture
'
:
download
(
asset_data
,
**
tcom
.
passargs
)
download
(
asset_data
,
**
tcom
.
passargs
)
print
(
'
finished download thread
'
)
if
bpy
.
context
.
scene
[
'
search results
'
]
is
not
None
and
done
:
for
sres
in
bpy
.
context
.
scene
[
'
search results
'
]:
if
asset_data
[
'
id
'
]
==
sres
[
'
id
'
]:
sres
[
'
downloaded
'
]
=
100
utils
.
p
(
'
finished download thread
'
)
return
.
2
return
.
2
...
@@ -590,9 +593,15 @@ def download(asset_data, **kwargs):
...
@@ -590,9 +593,15 @@ def download(asset_data, **kwargs):
scene_id
=
get_scene_id
()
scene_id
=
get_scene_id
()
tcom
=
ThreadCom
()
tcom
=
ThreadCom
()
tcom
.
passargs
=
kwargs
tcom
.
passargs
=
kwargs
if
kwargs
.
get
(
'
retry_counter
'
,
0
)
>
3
:
sprops
=
utils
.
get_search_props
()
sprops
.
report
=
f
"
Maximum retries exceeded for
{
asset_data
[
'
name
'
]
}
"
utils
.
p
(
sprops
.
report
)
return
# incoming data can be either directly dict from python, or blender id property
# incoming data can be either directly dict from python, or blender id property
# (recovering failed downloads on reload)
# (recovering failed downloads on reload)
if
type
(
asset_data
)
==
dict
:
if
type
(
asset_data
)
==
dict
:
...
@@ -654,7 +663,7 @@ def try_finished_append(asset_data, **kwargs): # location=None, material_target
...
@@ -654,7 +663,7 @@ def try_finished_append(asset_data, **kwargs): # location=None, material_target
This means probably wrong download, so download should restart
'''
This means probably wrong download, so download should restart
'''
file_names
=
paths
.
get_download_filenames
(
asset_data
)
file_names
=
paths
.
get_download_filenames
(
asset_data
)
done
=
False
done
=
False
print
(
'
try to append allready existing asset
'
)
utils
.
p
(
'
try to append allready existing asset
'
)
if
len
(
file_names
)
>
0
:
if
len
(
file_names
)
>
0
:
if
os
.
path
.
isfile
(
file_names
[
-
1
]):
if
os
.
path
.
isfile
(
file_names
[
-
1
]):
kwargs
[
'
name
'
]
=
asset_data
[
'
name
'
]
kwargs
[
'
name
'
]
=
asset_data
[
'
name
'
]
...
...
This diff is collapsed.
Click to expand it.
blenderkit/ui_panels.py
+
6
−
0
View file @
464dd1a5
...
@@ -802,6 +802,12 @@ class VIEW3D_PT_blenderkit_downloads(Panel):
...
@@ -802,6 +802,12 @@ class VIEW3D_PT_blenderkit_downloads(Panel):
row
.
label
(
text
=
asset_data
[
'
name
'
])
row
.
label
(
text
=
asset_data
[
'
name
'
])
row
.
label
(
text
=
str
(
int
(
tcom
.
progress
))
+
'
%
'
)
row
.
label
(
text
=
str
(
int
(
tcom
.
progress
))
+
'
%
'
)
row
.
operator
(
'
scene.blenderkit_download_kill
'
,
text
=
''
,
icon
=
'
CANCEL
'
)
row
.
operator
(
'
scene.blenderkit_download_kill
'
,
text
=
''
,
icon
=
'
CANCEL
'
)
if
tcom
.
passargs
.
get
(
'
retry_counter
'
,
0
)
>
0
:
row
=
layout
.
row
()
row
.
label
(
text
=
'
failed. retrying ...
'
,
icon
=
'
ERROR
'
)
row
.
label
(
text
=
str
(
tcom
.
passargs
[
"
retry_counter
"
]))
layout
.
separator
()
classess
=
(
classess
=
(
...
...
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