]> git.ipfire.org Git - ipfire.org.git/blobdiff - src/backend/base.py
Implement a basic wiki
[ipfire.org.git] / src / backend / base.py
index d7d6e328984da06dcbccd60fc6e5b977bbefdb73..9e4ae21b2578626d39758f2362e4e7afb0414b7b 100644 (file)
@@ -1,7 +1,8 @@
 #!/usr/bin/python
 
-import configparser as configparser
+import configparser
 import io
+import tornado.gen
 
 from . import accounts
 from . import database
@@ -16,6 +17,7 @@ from . import settings
 from . import talk
 
 from . import blog
+from . import wiki
 from . import zeiterfassung
 
 DEFAULT_CONFIG = io.StringIO("""
@@ -43,7 +45,6 @@ class Backend(object):
 
                # Initialize backend modules.
                self.accounts = accounts.Accounts(self)
-               self.downloads = mirrors.Downloads(self)
                self.geoip = geoip.GeoIP(self)
                self.fireinfo = fireinfo.Fireinfo(self)
                self.iuse = iuse.IUse(self)
@@ -54,6 +55,7 @@ class Backend(object):
                self.talk = talk.Talk(self)
 
                self.blog = blog.Blog(self)
+               self.wiki = wiki.Wiki(self)
                self.zeiterfassung = zeiterfassung.ZeiterfassungClient(self)
 
        def read_config(self, configfile):
@@ -79,3 +81,22 @@ class Backend(object):
                }
 
                self.db = database.Connection(**credentials)
+
+       @tornado.gen.coroutine
+       def run_task(self, task, *args, **kwargs):
+               tasks = {
+                       "update-blog-feeds" : self.blog.update_feeds,
+               }
+
+               # Get the task from the list of all tasks
+               func = tasks.get(task, None)
+               if not func:
+                       raise ValueError("Unknown task: %s" % task)
+
+               # Run the task
+               r = yield func(*args, **kwargs)
+
+               # If any error code has been returned,
+               # we will end the program
+               if r:
+                       raise SystemExit(r)