Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
f931d0f6
authored
Mar 14, 2014
by
Guba Sándor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
storage: changed is_downloading and get_download_precentage
parent
1135d99d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
11 deletions
+10
-11
circle/storage/models.py
+10
-11
No files found.
circle/storage/models.py
View file @
f931d0f6
...
...
@@ -17,7 +17,8 @@ from acl.models import AclBase
from
.tasks
import
local_tasks
,
remote_tasks
from
celery.exceptions
import
TimeoutError
from
manager.mancelery
import
celery
from
common.models
import
ActivityModel
,
activitycontextimpl
,
WorkerNotFound
from
common.models
import
(
ActivityModel
,
activitycontextimpl
,
WorkerNotFound
,
method_cache
)
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -111,6 +112,7 @@ class Disk(AclBase, TimeStampedModel):
return
self
.
activity_log
.
filter
(
activity_code__endswith
=
"deploy"
,
succeeded__isnull
=
False
)
@property
def
path
(
self
):
"""The path where the files are stored.
"""
...
...
@@ -153,15 +155,16 @@ class Disk(AclBase, TimeStampedModel):
}[
self
.
type
]
def
is_downloading
(
self
):
da
=
DiskActivity
.
objects
.
filter
(
disk
=
self
)
.
latest
(
"created"
)
return
(
da
.
activity_code
==
"storage.Disk.download"
and
da
.
succeeded
is
Non
e
)
return
self
.
activity_log
.
filter
(
activity_code__endswith
=
"downloading_disk"
,
succeeded__isnull
=
Tru
e
)
def
get_download_percentage
(
self
):
if
not
self
.
is_downloading
():
return
None
task
=
DiskActivity
.
objects
.
latest
(
"created"
)
.
task_uuid
task
=
self
.
activity_log
.
filter
(
activity_code__endswith
=
"deploy"
,
succeeded__isnull
=
True
)[
0
]
.
task_uuid
result
=
celery
.
AsyncResult
(
id
=
task
)
return
result
.
info
.
get
(
"percent"
)
...
...
@@ -270,8 +273,7 @@ class Disk(AclBase, TimeStampedModel):
self
.
save
()
if
self
.
ready
:
return
False
return
True
with
disk_activity
(
code_suffix
=
'deploy'
,
disk
=
self
,
task_uuid
=
task_uuid
,
user
=
user
)
as
act
:
...
...
@@ -289,9 +291,6 @@ class Disk(AclBase, TimeStampedModel):
queue
=
queue_name
)
.
get
(
timeout
=
timeout
)
self
.
ready
=
True
self
.
save
()
return
True
def
deploy_async
(
self
,
user
=
None
):
...
...
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