Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CouchPotatoServer
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
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
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
CouchPotatoServer
Commits
ddf03cbc
Commit
ddf03cbc
authored
Mar 4, 2013
by
Ruud
Browse files
Options
Downloads
Patches
Plain Diff
Diskspace event
parent
1e1abf40
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
couchpotato/core/plugins/manage/main.py
+33
-1
33 additions, 1 deletion
couchpotato/core/plugins/manage/main.py
with
33 additions
and
1 deletion
couchpotato/core/plugins/manage/main.py
+
33
−
1
View file @
ddf03cbc
...
@@ -2,11 +2,13 @@ from couchpotato.api import addApiView
...
@@ -2,11 +2,13 @@ from couchpotato.api import addApiView
from
couchpotato.core.event
import
fireEvent
,
addEvent
,
fireEventAsync
from
couchpotato.core.event
import
fireEvent
,
addEvent
,
fireEventAsync
from
couchpotato.core.helpers.encoding
import
ss
from
couchpotato.core.helpers.encoding
import
ss
from
couchpotato.core.helpers.request
import
jsonified
,
getParam
from
couchpotato.core.helpers.request
import
jsonified
,
getParam
from
couchpotato.core.helpers.variable
import
getTitle
,
splitString
from
couchpotato.core.helpers.variable
import
splitString
,
getTitle
from
couchpotato.core.logger
import
CPLog
from
couchpotato.core.logger
import
CPLog
from
couchpotato.core.plugins.base
import
Plugin
from
couchpotato.core.plugins.base
import
Plugin
from
couchpotato.environment
import
Env
from
couchpotato.environment
import
Env
import
ctypes
import
os
import
os
import
sys
import
time
import
time
import
traceback
import
traceback
...
@@ -22,6 +24,7 @@ class Manage(Plugin):
...
@@ -22,6 +24,7 @@ class Manage(Plugin):
fireEvent
(
'
scheduler.interval
'
,
identifier
=
'
manage.update_library
'
,
handle
=
self
.
updateLibrary
,
hours
=
2
)
fireEvent
(
'
scheduler.interval
'
,
identifier
=
'
manage.update_library
'
,
handle
=
self
.
updateLibrary
,
hours
=
2
)
addEvent
(
'
manage.update
'
,
self
.
updateLibrary
)
addEvent
(
'
manage.update
'
,
self
.
updateLibrary
)
addEvent
(
'
manage.diskspace
'
,
self
.
getDiskSpace
)
# Add files after renaming
# Add files after renaming
def
after_rename
(
message
=
None
,
group
=
{}):
def
after_rename
(
message
=
None
,
group
=
{}):
...
@@ -192,6 +195,7 @@ class Manage(Plugin):
...
@@ -192,6 +195,7 @@ class Manage(Plugin):
self
.
in_progress
[
folder
][
'
to_go
'
]
=
self
.
in_progress
[
folder
][
'
to_go
'
]
-
1
self
.
in_progress
[
folder
][
'
to_go
'
]
=
self
.
in_progress
[
folder
][
'
to_go
'
]
-
1
total
=
self
.
in_progress
[
folder
][
'
total
'
]
total
=
self
.
in_progress
[
folder
][
'
total
'
]
movie_dict
=
fireEvent
(
'
movie.get
'
,
identifier
,
single
=
True
)
movie_dict
=
fireEvent
(
'
movie.get
'
,
identifier
,
single
=
True
)
fireEvent
(
'
notify.frontend
'
,
type
=
'
movie.added
'
,
data
=
movie_dict
,
message
=
None
if
total
>
5
else
'
Added
"
%s
"
to manage.
'
%
getTitle
(
movie_dict
[
'
library
'
]))
fireEvent
(
'
notify.frontend
'
,
type
=
'
movie.added
'
,
data
=
movie_dict
,
message
=
None
if
total
>
5
else
'
Added
"
%s
"
to manage.
'
%
getTitle
(
movie_dict
[
'
library
'
]))
return
afterUpdate
return
afterUpdate
...
@@ -214,3 +218,31 @@ class Manage(Plugin):
...
@@ -214,3 +218,31 @@ class Manage(Plugin):
for
group
in
groups
.
itervalues
():
for
group
in
groups
.
itervalues
():
if
group
[
'
library
'
]
and
group
[
'
library
'
].
get
(
'
identifier
'
):
if
group
[
'
library
'
]
and
group
[
'
library
'
].
get
(
'
identifier
'
):
fireEvent
(
'
release.add
'
,
group
=
group
)
fireEvent
(
'
release.add
'
,
group
=
group
)
def
getDiskSpace
(
self
):
free_space
=
{}
for
folder
in
self
.
directories
():
size
=
None
if
os
.
path
.
isdir
(
folder
):
if
os
.
name
==
'
nt
'
:
_
,
total
,
free
=
ctypes
.
c_ulonglong
(),
ctypes
.
c_ulonglong
(),
\
ctypes
.
c_ulonglong
()
if
sys
.
version_info
>=
(
3
,)
or
isinstance
(
folder
,
unicode
):
fun
=
ctypes
.
windll
.
kernel32
.
GetDiskFreeSpaceExW
#@UndefinedVariable
else
:
fun
=
ctypes
.
windll
.
kernel32
.
GetDiskFreeSpaceExA
#@UndefinedVariable
ret
=
fun
(
folder
,
ctypes
.
byref
(
_
),
ctypes
.
byref
(
total
),
ctypes
.
byref
(
free
))
if
ret
==
0
:
raise
ctypes
.
WinError
()
used
=
total
.
value
-
free
.
value
return
[
total
.
value
,
used
,
free
.
value
]
else
:
s
=
os
.
statvfs
(
folder
)
size
=
[
s
.
f_blocks
*
s
.
f_frsize
/
(
1024
*
1024
),
(
s
.
f_bavail
*
s
.
f_frsize
)
/
(
1024
*
1024
)]
free_space
[
folder
]
=
size
return
free_space
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