Sophie

Sophie

distrib > Fedora > 14 > x86_64 > by-pkgid > df5bdfd6640671b7717a4b9ec9401363 > files > 7

olpc-utils-1.3.7-1.fc14.x86_64.rpm

#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# chkconfig: 345 02 02
# description: If the NAND doesn't have enough free space, set up a VT for\
#              diskspacerecover.
# processname: diskspacecheck

# Author:      Chris Ball <cjb@laptop.org>

import os, sys, statvfs, time

THRESHOLD = 1024 * 20  # 20MB
DATASTORE_PATH = "/home/olpc/.sugar/default/datastore/store/*-*"
ACTIVITY_PATH  = "/home/olpc/Activities/*"

# Determine free space on /.
stat = os.statvfs("/")
freebytes  = stat[statvfs.F_BSIZE] * stat[statvfs.F_BAVAIL]
freekbytes = freebytes / 1024

# If we have enough disk space, exit.
if freekbytes > THRESHOLD:
    sys.exit()

# Disable pretty-boot.
if os.path.exists("/usr/sbin/boot-anim-running") and os.system("/usr/sbin/boot-anim-running") == 0:
    # Pretty-boot is running.  Kill it, and set up a new VT for the next script.
    os.system("/etc/init.d/z-boot-anim-stop start")
    os.system("chvt 2")

try:
	dcon = open('/sys/class/backlight/dcon-bl/device/freeze', 'w')
	dcon.write('0')
	dcon.close()
except IOError:
	# Don't think there's anything useful I can do if this write fails.
	pass

os.system("/sbin/setsysfont")
os.system("/bin/unicode_start sun12x22")