summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mkaay <mkaay@mkaay.de> 2010-03-30 15:49:01 +0200
committerGravatar mkaay <mkaay@mkaay.de> 2010-03-30 15:49:01 +0200
commitd56fd050ced8c31eabae7a1ceabe8adaeec6b3bd (patch)
tree8d6329b93957ca5848f01f76c69d107268f7ad18
parentnew server method (get_config) (diff)
downloadpyload-d56fd050ced8c31eabae7a1ceabe8adaeec6b3bd.tar.xz
fixes #64
-rw-r--r--module/XMLConfigParser.py8
-rw-r--r--module/config/core_default.xml1
-rw-r--r--module/thread_list.py6
-rwxr-xr-xpyLoadCore.py8
4 files changed, 19 insertions, 4 deletions
diff --git a/module/XMLConfigParser.py b/module/XMLConfigParser.py
index bde46afe5..0aede384c 100644
--- a/module/XMLConfigParser.py
+++ b/module/XMLConfigParser.py
@@ -70,11 +70,13 @@ class XMLConfigParser():
self.xml.writexml(fh)
def _read_config(self):
- def format(val):
+ def format(val, t="str"):
if val.lower() == "true":
return True
elif val.lower() == "false":
return False
+ elif t == "int":
+ return int(val)
else:
return val
root = self.xml.documentElement
@@ -92,8 +94,8 @@ class XMLConfigParser():
if opt.nodeType == opt.ELEMENT_NODE:
data[section]["options"][opt.tagName] = {}
try:
- config[section][opt.tagName] = format(opt.firstChild.data)
- data[section]["options"][opt.tagName]["value"] = format(opt.firstChild.data)
+ config[section][opt.tagName] = format(opt.firstChild.data, opt.getAttribute("type"))
+ data[section]["options"][opt.tagName]["value"] = format(opt.firstChild.data, opt.getAttribute("type"))
except:
config[section][opt.tagName] = ""
data[section]["options"][opt.tagName]["name"] = opt.getAttribute("name")
diff --git a/module/config/core_default.xml b/module/config/core_default.xml
index 8223768ec..4925c06cf 100644
--- a/module/config/core_default.xml
+++ b/module/config/core_default.xml
@@ -40,6 +40,7 @@
<max_download_time type="int" name="Max Download Time">5</max_download_time>
<download_speed_limit type="int" name="Download Speed Limit">0</download_speed_limit>
<checksum type="bool" name="Use Checksum">True</checksum>
+ <min_free_space type="int" name="Min Free Space (MB)">200</min_free_space>
</general>
<updates name="Updates">
<search_updates type="bool" name="Search">True</search_updates>
diff --git a/module/thread_list.py b/module/thread_list.py
index 13dba309e..000e86d27 100644
--- a/module/thread_list.py
+++ b/module/thread_list.py
@@ -41,7 +41,7 @@ class Thread_List(object):
self.lock = RLock()
self.py_downloading = [] # files downloading
self.occ_plugins = [] #occupied plugins
- self.pause = False
+ self.pause = True
self.reconnecting = False
self.select_thread()
@@ -69,6 +69,10 @@ class Thread_List(object):
if not self.parent.server_methods.is_time_download() or self.pause or self.reconnecting or self.list.queueEmpty(): #conditions when threads dont download
return None
+
+ if self.parent.freeSpace() < self.parent.config["general"]["min_free_space"]:
+ self.parent.logger.debug("min free space exceeded")
+ return None
self.init_reconnect()
diff --git a/pyLoadCore.py b/pyLoadCore.py
index 5c659e538..5264ef1e1 100755
--- a/pyLoadCore.py
+++ b/pyLoadCore.py
@@ -38,6 +38,7 @@ from os import makedirs
from os import remove
from os import sep
from os import _exit
+from os import statvfs
from os.path import abspath
from os.path import basename
from os.path import dirname
@@ -221,6 +222,9 @@ class Core(object):
self.file_list.continueAborted()
except:
pass
+
+ self.logger.info(_("Free space: %sMB") % self.freeSpace())
+ self.thread_list.pause = False
while True:
sleep(2)
@@ -432,6 +436,10 @@ class Core(object):
return args[0]
else:
return join(self.path, * args)
+
+ def freeSpace(self):
+ s = statvfs(self.make_path(self.config['general']['download_folder']))
+ return s.f_bsize * s.f_bavail / 1024 / 1024 #megabyte
####################################
########## XMLRPC Methods ##########