diff options
Diffstat (limited to 'module')
| -rw-r--r-- | module/UserManager.py | 23 | ||||
| -rw-r--r-- | module/database/DatabaseBackend.py | 31 | ||||
| -rw-r--r-- | module/debug.py | 95 | ||||
| -rw-r--r-- | module/lib/forwarder.py (renamed from module/forwarder.py) | 0 | ||||
| -rw-r--r-- | module/plugins/UserAddon.py | 25 | 
5 files changed, 75 insertions, 99 deletions
| diff --git a/module/UserManager.py b/module/UserManager.py new file mode 100644 index 000000000..9d5e8c5db --- /dev/null +++ b/module/UserManager.py @@ -0,0 +1,23 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +    This program is free software; you can redistribute it and/or modify +    it under the terms of the GNU General Public License as published by +    the Free Software Foundation; either version 3 of the License, +    or (at your option) any later version. + +    This program is distributed in the hope that it will be useful, +    but WITHOUT ANY WARRANTY; without even the implied warranty of +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +    See the GNU General Public License for more details. + +    You should have received a copy of the GNU General Public License +    along with this program; if not, see <http://www.gnu.org/licenses/>. + +    @author: RaNaN +""" + +class UserManager: +    """ +    Manager class to handle all user related stuff +    """
\ No newline at end of file diff --git a/module/database/DatabaseBackend.py b/module/database/DatabaseBackend.py index 18898a93c..6373120ff 100644 --- a/module/database/DatabaseBackend.py +++ b/module/database/DatabaseBackend.py @@ -322,13 +322,36 @@ class DatabaseBackend(Thread):          self.c.execute(              'CREATE TABLE IF NOT EXISTS "users" (' -            '"name" TEXT PRIMARY KEY NOT NULL, ' +            '"id" INTEGER PRIMARY KEY AUTOINCREMENT, ' +            '"name" TEXT NOT NULL, '              '"email" TEXT DEFAULT "" NOT NULL, '              '"password" TEXT NOT NULL, '              '"role" INTEGER DEFAULT 0 NOT NULL, '              '"permission" INTEGER DEFAULT 0 NOT NULL, '              '"folder" TEXT DEFAULT "" NOT NULL, ' -            '"template" TEXT DEFAULT "default" NOT NULL' +            '"ratio" INTEGER DEFAULT -1 NOT NULL, ' +            '"limit" INTEGER DEFAULT -1 NOT NULL, ' +            '"template" TEXT DEFAULT "default" NOT NULL, ' +            '"user" INTEGER DEFAULT -1 NOT NULL, ' +            'FOREIGN KEY(user) REFERENCES users(id)' +            ')' +        ) + +        self.c.execute( +            'CREATE TRIGGER IF NOT EXISTS "insert_user" AFTER INSERT ON "users"' +            'BEGIN ' +            'UPDATE users SET user = new.id ' +            'WHERE rowid = new.rowid;' +            'END' +        ) + +        self.c.execute( +            'CREATE TABLE IF NOT EXISTS "settings" (' +            '"plugin" TEXT NOT NULL, ' +            '"owner" INTEGER NOT NULL, ' +            '"configuration" TEXT NOT NULL, ' +            'FOREIGN KEY(owner) REFERENCES users(id), ' +            'PRIMARY KEY (plugin, owner) ON CONFLICT REPLACE'              ')'          ) @@ -339,8 +362,8 @@ class DatabaseBackend(Thread):              '"activated" INTEGER DEFAULT 1, '              '"password" TEXT DEFAULT "", '              '"options" TEXT DEFAULT "", ' -#            '"user" TEXT NOT NULL, ' -#            'FOREIGN KEY(user) REFERENCES users(name)' +#            '"owner" INTEGER NOT NULL, ' TODO: shared, owner attribute +#            'FOREIGN KEY(owner) REFERENCES users(id)'              'PRIMARY KEY (plugin, loginname) ON CONFLICT REPLACE'              ')'          ) diff --git a/module/debug.py b/module/debug.py deleted file mode 100644 index 8d1ddd3d0..000000000 --- a/module/debug.py +++ /dev/null @@ -1,95 +0,0 @@ -#!/usr/bin/env python -#coding:utf-8 - -import re -import InitHomeDir -from os import listdir - -class Wrapper(object): -	pass - -def filter_info(line): -	if "object at 0x" in line: -		return False -	elif " at line " in line: -		return False -	elif " <DownloadThread(" in line: -		return False -	elif "<class '" in line: -		return False -	elif "PyFile " in line: -		return False -	elif " <module '" in line: -		return False -	 -	else: -		return True -	 -def appendName(lines, name): -	test = re.compile("^[a-zA-z0-9]+ = ") -	 -	for i, line in enumerate(lines): -		if test.match(line): -			lines[i] = name+"."+line -			 -	return lines - -def initReport(): -	reports = [] -	for f in listdir("."): -		if f.startswith("debug_"): -			reports.append(f) -		 -	for i, f in enumerate(reports): -		print "%s. %s" % (i,f)  -	 -	choice = raw_input("Choose Report: ") -	 -	report = reports[int(choice)] -	 -	f = open(report, "rb") - -	content = f.readlines() -	content = [x.strip() for x in content if x.strip()] -	 -	frame = Wrapper() -	plugin = Wrapper() -	pyfile = Wrapper() -	 -	frame_c = []  -	plugin_c = [] -	pyfile_c = [] -	 -	dest = None -	 -	for line in  content: -		if line == "FRAMESTACK:": -			dest = frame_c -			continue -		elif line == "PLUGIN OBJECT DUMP:": -			dest = plugin_c -			continue -		elif line == "PYFILE OBJECT DUMP:": -			dest = pyfile_c -			continue -		elif line == "CONFIG:": -			dest = None -	 -		if dest is not None: -			dest.append(line) -			 -			 -	frame_c = filter(filter_info, frame_c) -	plugin_c = filter(filter_info, plugin_c) -	pyfile_c = filter(filter_info, pyfile_c) -	 -	frame_c = appendName(frame_c, "frame") -	plugin_c = appendName(plugin_c, "plugin") -	pyfile_c = appendName(pyfile_c, "pyfile") -		 -	exec("\n".join(frame_c+plugin_c+pyfile_c) ) -	 -	return frame, plugin, pyfile -	 -if __name__=='__main__': -	print "No main method, use this module with your python shell"
\ No newline at end of file diff --git a/module/forwarder.py b/module/lib/forwarder.py index eacb33c2b..eacb33c2b 100644 --- a/module/forwarder.py +++ b/module/lib/forwarder.py diff --git a/module/plugins/UserAddon.py b/module/plugins/UserAddon.py new file mode 100644 index 000000000..c49b1ef41 --- /dev/null +++ b/module/plugins/UserAddon.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +""" +    This program is free software; you can redistribute it and/or modify +    it under the terms of the GNU General Public License as published by +    the Free Software Foundation; either version 3 of the License, +    or (at your option) any later version. + +    This program is distributed in the hope that it will be useful, +    but WITHOUT ANY WARRANTY; without even the implied warranty of +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +    See the GNU General Public License for more details. + +    You should have received a copy of the GNU General Public License +    along with this program; if not, see <http://www.gnu.org/licenses/>. + +    @author: RaNaN +""" + +from Addon import Addon + +class UserAddon(Addon): +    """ +    Special type of an addon that only works a specific user. Has a configuration for every user who added it . +    """
\ No newline at end of file | 
