Skip to content

Commit

Permalink
Added new plugin checkspace #438
Browse files Browse the repository at this point in the history
Checks if it's enough space in disk, if not, error status is set.
  • Loading branch information
dpeite committed Mar 23, 2017
1 parent 0ad14a9 commit 70ed438
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
4 changes: 4 additions & 0 deletions conf-dist.ini
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ lockscreen = False
appearance = False
cameracontrol = False
muteinputs = False
checkspace = False

[checkspace]
minfreespace = 10 ;In GB

[cameracontrol]
path = /dev/ttyUSB0
Expand Down
43 changes: 43 additions & 0 deletions galicaster/plugins/checkspace.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# -*- coding:utf-8 -*-
# Galicaster, Multistream Recorder and Player
#
# galicaster/plugins/checkspace
#
# Copyright (c) 2016, Teltek Video Research <galicaster@teltek.es>
#
# This work is licensed under the Creative Commons Attribution-
# NonCommercial-ShareAlike 3.0 Unported License. To view a copy of
# this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
# or send a letter to Creative Commons, 171 Second Street, Suite 300,
# San Francisco, California, 94105, USA.

"""
"""

from galicaster.core import context
from galicaster.recorder.service import PREVIEW_STATUS

conf = None
logger = None
repo = None
dispatcher = None

def init():
global conf, logger, repo, dispatcher, minfreespace, freespace
conf = context.get_conf()
dispatcher = context.get_dispatcher()
logger = context.get_logger()
repo = context.get_repository()

minfreespace = conf.get_int('checkspace','minfreespace')
if not minfreespace:
raise Exception("Parameter minfreespace not configured")

logger.info("Parameter 'minfreespace' set to {} GB".format(minfreespace))
dispatcher.connect("recorder-ready", check_space)

def check_space(sender):
freespace = repo.get_free_space() /(1024*1024*1024)
if freespace < minfreespace:
dispatcher.emit("recorder-error", "Low repository space: repo has {} GB free space available". format(freespace))
2 changes: 1 addition & 1 deletion galicaster/recorder/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ def preview(self):
self.__prepare()
self.recorder.preview()
self.__set_status(PREVIEW_STATUS)
self.dispatcher.emit("recorder-ready")
return True

except Exception as exc:
Expand All @@ -109,7 +110,6 @@ def __prepare(self):


self.recorder = self.__recorderklass(bins)
self.dispatcher.emit("recorder-ready")

self.mute_preview(self.mute)
if self.__create_drawing_areas_func:
Expand Down

0 comments on commit 70ed438

Please sign in to comment.