def __init__(self): """Table for one application in the applications module""" self.bleex = serverTools.getSystemDb() self.bleex.beginTransaction() self.bleex.checkTable( "home_applications", [{ "name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY" }, { "name": "name", "type": "text" }, { "name": "url", "type": "text" }, { "name": "description", "type": "text" }, { "name": "image", "type": "text" }, { "name": "position", "type": "integer" }, { "name": "username", "type": "text" }]) self.bleex.commitTransaction() """if position is None:
def freePBX_login(): db = serverTools.getSystemDb() success = False if request.method == 'POST': user = request.form['username'] password = request.form['password'] success = validate(db, user, password) if success: serverTools.setUser(user) return jsonify(success=success) return render_template('freepbx/freepbxLogin.html')
def freePBX_login(): db = serverTools.getSystemDb() success = False if request.method == 'POST': user = request.form['username'] password = request.form['password'] success = validate(db, user, password) if success: serverTools.setUser(user) return jsonify(success=success) return render_template('freepbx/freepbxLogin.html')
def settings_create_login(): db = serverTools.getSystemDb() success = False if request.method == 'POST': user = request.form['username'] password = request.form['password'] success = createLogin(db, user, password) if success: return jsonify(success=success) return render_template('bleex/settingsLogin.html')
def settings_create_login(): db = serverTools.getSystemDb() success = False if request.method == 'POST': user = request.form['username'] password = request.form['password'] success = createLogin(db, user, password) if success: return jsonify(success=success) return render_template('bleex/settingsLogin.html')
def house_login(): if 'username' in session: db = serverTools.getSystemDb() success = False if request.method == 'POST': user = request.form['username'] password = request.form['password'] success = validate(db, user, password) if success: serverTools.setUser(user) serverTools.setPyEmoncmsLogin(success, user) return jsonify(success=success) return render_template('house/houseLogin.html') return render_template('index.html')
def house_login(): if 'username' in session: db = serverTools.getSystemDb() success = False if request.method == 'POST': user = request.form['username'] password = request.form['password'] success = validate(db, user, password) if success: serverTools.setUser(user) serverTools.setPyEmoncmsLogin(success, user) return jsonify(success=success) return render_template('house/houseLogin.html') return render_template('index.html')
def settings_login(): db = serverTools.getSystemDb() success = False if request.method == 'POST': user = request.form['username'] password = request.form['password'] #print password success = validate(db, user, password) if success: serverTools.setUser(user) return jsonify(success=success) return render_template('bleex/settingsLogin.html')
def settings_login(): db = serverTools.getSystemDb() success = False if request.method == 'POST': user = request.form['username'] password = request.form['password'] #print password success = validate(db, user, password) if success: serverTools.setUser(user) return jsonify(success=success) return render_template('bleex/settingsLogin.html')
def __init__(self): """Table for one application in the applications module""" self.bleex = serverTools.getSystemDb() self.bleex.beginTransaction() self.bleex.checkTable("home_applications", [ {"name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY"}, {"name": "name", "type": "text"}, {"name": "url", "type": "text"}, {"name": "description", "type": "text"}, {"name": "image", "type": "text"}, {"name": "position", "type": "integer"}, {"name": "username", "type": "text"}]) self.bleex.commitTransaction() """if position is None:
def __init__(self): """Table for the XBMC server config""" self.bleex = serverTools.getSystemDb() self.bleex.beginTransaction() self.bleex.checkTable( "xbmc_servers", [{ "name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY" }, { "name": "label", "type": "text" }, { "name": "position", "type": "text" }, { "name": "hostname", "type": "text" }, { "name": "port", "type": "text" }, { "name": "xbmc_username", "type": "text" }, { "name": "xbmc_password", "type": "text" }, { "name": "mac_address", "type": "text" }, { "name": "active_server", "type": "text" }, { "name": "username", "type": "text" }]) self.bleex.commitTransaction()
def __init__(self): """Table for the XBMC server config""" self.bleex = serverTools.getSystemDb() self.bleex.beginTransaction() self.bleex.checkTable("xbmc_servers", [ {"name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY"}, {"name": "label", "type": "text"}, {"name": "position", "type": "text"}, {"name": "hostname", "type": "text"}, {"name": "port", "type": "text"}, {"name": "xbmc_username", "type": "text"}, {"name": "xbmc_password", "type": "text"}, {"name": "mac_address", "type": "text"}, {"name": "active_server", "type": "text"}, {"name": "username", "type": "text"}]) self.bleex.commitTransaction()
def __init__(self): self.db = serverTools.getSystemDb()
def __init__(self): self.db = serverTools.getSystemDb() self.logger = serverTools.getLogger() self.date = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S') self.db.beginTransaction() self.db.query("SET SQL_MODE=\"NO_AUTO_VALUE_ON_ZERO\";") self.db.query("CREATE TABLE IF NOT EXISTS `applications` (`application_k` int(11) NOT NULL AUTO_INCREMENT,`application_parent_k` int(11) DEFAULT NULL,`name` varchar(200) NOT NULL,`description` text NOT NULL,`klass` varchar(255) NOT NULL,`configurations` text NOT NULL,`date_created` datetime NOT NULL,`date_updated` datetime NOT NULL,`active` tinyint(1) NOT NULL,PRIMARY KEY (`application_k`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;") self.db.query("CREATE TABLE IF NOT EXISTS `permissions` (`permission_k` int(11) NOT NULL AUTO_INCREMENT,`application_k` int(11) NOT NULL,`action` varchar(50) NOT NULL,`name` varchar(100) NOT NULL,`description` text NOT NULL,PRIMARY KEY (`permission_k`),KEY `application_k` (`application_k`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=42 ;") self.db.query("CREATE TABLE IF NOT EXISTS `roles` (`role_k` int(11) NOT NULL AUTO_INCREMENT,`name` varchar(50) NOT NULL,`description` text NOT NULL,PRIMARY KEY (`role_k`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;") self.db.query("CREATE TABLE IF NOT EXISTS `role_permissions` (`role_permission_k` int(11) NOT NULL AUTO_INCREMENT,`role_k` int(11) NOT NULL,`permission_k` int(11) NOT NULL,`value` tinyint(1) NOT NULL,`date_created` datetime NOT NULL,PRIMARY KEY (`role_permission_k`),KEY `role_k` (`role_k`),KEY `permission_k` (`permission_k`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=58 ;") self.db.query("CREATE TABLE IF NOT EXISTS `users` (`user_k` int(11) NOT NULL AUTO_INCREMENT,`username` varchar(20) NOT NULL,`password` char(128) NOT NULL,`email` varchar(100) NOT NULL,`name` varchar(50) NOT NULL,`lastname` varchar(50) NOT NULL,`avatar` varchar(255) DEFAULT NULL,`active` tinyint(1) NOT NULL,PRIMARY KEY (`user_k`),UNIQUE KEY `username` (`username`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;") self.db.query("CREATE TABLE IF NOT EXISTS `user_permissions` (`user_permission_k` int(11) NOT NULL AUTO_INCREMENT,`user_k` int(11) NOT NULL,`permission_k` int(11) NOT NULL,`value` int(11) NOT NULL,`date_created` datetime NOT NULL,PRIMARY KEY (`user_permission_k`),KEY `user_k` (`user_k`),KEY `permission_k` (`permission_k`)) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;") self.db.query("CREATE TABLE IF NOT EXISTS `user_roles` (`user_k` int(11) NOT NULL,`role_k` int(11) NOT NULL,`date_created` datetime NOT NULL,KEY `user_k` (`user_k`),KEY `role_k` (`role_k`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;") # Check basic defaults #Applications self.checkDesktopDefaults("applications", data={ "application_k": "1", "application_parent_k": "0", "name": "Administration", "description": "Administration Folder", "klass": "", "configurations": '{"iconCls":"","width":800,"height":480,"shorcutIconCls":""}', "date_created": self.date, "date_updated": self.date, "active": "1"}) self.checkDesktopDefaults("applications", data={ "application_k": "2", "application_parent_k": '1', "name": 'Applications', "description": 'Applications Catalog', "klass": 'Bleext.modules.catalogs.applications.controller.Application', "configurations": '{"iconCls":"applications-icon"}', "date_created": self.date, "date_updated": self.date, "active": "1"}) self.checkDesktopDefaults("applications", data={ "application_k": "3", "application_parent_k": '1', "name": 'Roles', "description": 'Roles Catalog', "klass": 'Bleext.modules.catalogs.roles.controller.Roles', "configurations": '{"iconCls":"roles-icon","width":800,"height":480,"shorcutIconCls":""}', "date_created": self.date, "date_updated": self.date, "active": "1"}) self.checkDesktopDefaults("applications", data={ "application_k": "4", "application_parent_k": '1', "name": 'Users', "description": 'Users Module', "klass": 'Bleext.modules.catalogs.users.controller.Users', "configurations": '{"iconCls":"users-icon","shorcutIconCls":"roles-app-shorcut-icon","width":800,"height":480}', "date_created": self.date, "date_updated": self.date, "active": "1"}) self.checkDesktopDefaults("applications", data={ "application_k": "5", "application_parent_k": '1', "name": 'Privileges', "description": 'This module allow you to set the privileges to the roles and applications', "klass": 'Bleext.modules.security.permissions.controller.Permission', "configurations": '{"iconCls":"permissions-icon-16","width":800,"height":480,"shorcutIconCls":""}', "date_created": self.date, "date_updated": self.date, "active": "1"}) self.checkDesktopDefaults("applications", data={ "application_k": "6", "application_parent_k": '1', "name": 'Groups', "description": 'Groups Module', "klass": 'Bleext.modules.security.groups.controller.Groups', "configurations": '{"iconCls":"groups-icon-16","width":800,"height":480,"shorcutIconCls":""}', "date_created": self.date, "date_updated": self.date, "active": "1"}) #Permissions self.checkDesktopDefaults("permissions", data={ "permission_k": '1', "application_k": '1', "action": 'access', "name": 'Access', "description": 'Permission Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '2', "application_k": '2', "action": 'access', "name": 'Access', "description": 'Permission to read all the applications'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '3', "application_k": '2', "action": 'edit', "name": 'Edit', "description": 'Edit Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '4', "application_k": '2', "action": 'create', "name": 'Create', "description": 'Create'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '5', "application_k": '2', "action": 'update', "name": 'Update', "description": 'Update Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '6', "application_k": '2', "action": 'list', "name": 'List', "description": 'List'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '7', "application_k": '2', "action": 'delete', "name": 'Delete', "description": 'Delete Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '8', "application_k": '2', "action": 'print', "name": 'Print', "description": 'Print'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '9', "application_k": '2', "action": 'export', "name": 'Export', "description": 'Export Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '10', "application_k": '3', "action": 'access', "name": 'Access', "description": 'To Access the module'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '11', "application_k": '3', "action": 'edit', "name": 'Edit', "description": 'Edit Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '12', "application_k": '3', "action": 'create', "name": 'Create', "description": 'Create'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '13', "application_k": '3', "action": 'update', "name": 'Update', "description": 'Update Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '14', "application_k": '3', "action": 'list', "name": 'List', "description": 'List'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '15', "application_k": '3', "action": 'delete', "name": 'Delete', "description": 'Delete Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '16', "application_k": '3', "action": 'print', "name": 'Print', "description": 'Print'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '17', "application_k": '3', "action": 'export', "name": 'Export', "description": 'Export Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '18', "application_k": '4', "action": 'access', "name": 'Access', "description": 'To appear in the menu'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '19', "application_k": '4', "action": 'edit', "name": 'Edit', "description": 'Edit Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '20', "application_k": '4', "action": 'create', "name": 'Create', "description": 'Create'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '21', "application_k": '4', "action": 'update', "name": 'Update', "description": 'Update Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '22', "application_k": '4', "action": 'list', "name": 'List', "description": 'List'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '23', "application_k": '4', "action": 'delete', "name": 'Delete', "description": 'Delete Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '24', "application_k": '4', "action": 'print', "name": 'Print', "description": 'Print'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '25', "application_k": '4', "action": 'export', "name": 'Export', "description": 'Export Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '26', "application_k": '5', "action": 'access', "name": 'Access', "description": 'Allow users to access the permissions module, this module should be visible only for administrators'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '27', "application_k": '5', "action": 'edit', "name": 'Edit', "description": 'Edit Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '28', "application_k": '5', "action": 'create', "name": 'Create', "description": 'Create'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '29', "application_k": '5', "action": 'update', "name": 'Update', "description": 'Update Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '30', "application_k": '5', "action": 'list', "name": 'List', "description": 'List'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '31', "application_k": '5', "action": 'delete', "name": 'Delete', "description": 'Delete Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '32', "application_k": '5', "action": 'print', "name": 'Print', "description": 'Print'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '33', "application_k": '5', "action": 'export', "name": 'Export', "description": 'Export Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '34', "application_k": '6', "action": 'access', "name": 'Access', "description": 'Groups Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '35', "application_k": '6', "action": 'edit', "name": 'Edit', "description": 'Edit Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '36', "application_k": '6', "action": 'create', "name": 'Create', "description": 'Create'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '37', "application_k": '6', "action": 'list', "name": 'List', "description": 'List'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '38', "application_k": '6', "action": 'delete', "name": 'Delete', "description": 'Delete Access'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '39', "application_k": '6', "action": 'print', "name": 'Print', "description": 'Print'}) self.checkDesktopDefaults("permissions", data={ "permission_k": '40', "application_k": '6', "action": 'export', "name": 'Export', "description": 'Export Access'}) #Roles self.checkDesktopDefaults("roles", data={ "role_k": "1", "name": 'Administrator', "description": 'The Super User'}) self.checkDesktopDefaults("roles", data={ "role_k": "2", "name": 'Users', "description": 'The Users Role'}) self.checkDesktopDefaults("roles", data={ "role_k": "3", "name": 'Visitors', "description": 'Visitors'}) #Role Permissions #Administrator self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '1', "permission_k": '1', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '2', "permission_k": '2', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '3', "permission_k": '3', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '4', "permission_k": '4', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '5', "permission_k": '5', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '6', "permission_k": '6', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '7', "permission_k": '7', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '8', "permission_k": '8', "value": '5', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '9', "permission_k": '9', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '10', "permission_k": '10', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '11', "permission_k": '11', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '12', "permission_k": '12', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '13', "permission_k": '13', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '14', "permission_k": '14', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '15', "permission_k": '15', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '16', "permission_k": '16', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '17', "permission_k": '17', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '18', "permission_k": '18', "value": '1', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '1', "role_permission_k": '19', "permission_k": '19', "value": '1', "date_created": self.date}) #User self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '20', "permission_k": '4', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '21', "permission_k": '5', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '22', "permission_k": '6', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '23', "permission_k": '7', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '24', "permission_k": '8', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '25', "permission_k": '9', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '26', "permission_k": '10', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '27', "permission_k": '11', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '28', "permission_k": '12', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '29', "permission_k": '13', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '30', "permission_k": '14', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '31', "permission_k": '15', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '2', "role_permission_k": '32', "permission_k": '16', "value": '0', "date_created": self.date}) #Visitor self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '33', "permission_k": '4', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '34', "permission_k": '5', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '35', "permission_k": '6', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '36', "permission_k": '7', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '37', "permission_k": '8', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '38', "permission_k": '9', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '39', "permission_k": '10', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '40', "permission_k": '11', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '41', "permission_k": '12', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '42', "permission_k": '13', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '43', "permission_k": '14', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '44', "permission_k": '15', "value": '0', "date_created": self.date}) self.checkDesktopDefaults("role_permissions", data={ "role_k": '3', "role_permission_k": '45', "permission_k": '16', "value": '0', "date_created": self.date}) #User Permissions self.checkDesktopDefaults("user_permissions", data={ "user_permission_k": '1', "user_k": '1', "permission_k": '1', "value": '1', "date_created": self.date}) #User Roles self.checkDesktopDefaults("user_roles", data={ "user_k": '1', "role_k": '1', "date_created": self.date}) #Users password is "password" self.checkDesktopDefaults("users", data={ "user_k": '1', "username": '', "password": '', "email": '', "name": "Admin", "lastname": "Super", "avatar": "default.png", "active": "1"}) try: self.db.query("ALTER TABLE `permissions`ADD CONSTRAINT `permissions_ibfk_1` FOREIGN KEY (`application_k`) REFERENCES `applications` (`application_k`);") self.db.query("ALTER TABLE `role_permissions`ADD CONSTRAINT `role_permissions_ibfk_1` FOREIGN KEY (`role_k`) REFERENCES `roles` (`role_k`),ADD CONSTRAINT `role_permissions_ibfk_2` FOREIGN KEY (`permission_k`) REFERENCES `permissions` (`permission_k`);") self.db.query("ALTER TABLE `user_permissions`ADD CONSTRAINT `user_permissions_ibfk_1` FOREIGN KEY (`user_k`) REFERENCES `users` (`user_k`),ADD CONSTRAINT `user_permissions_ibfk_2` FOREIGN KEY (`permission_k`) REFERENCES `permissions` (`permission_k`);") self.db.query("ALTER TABLE `user_roles`ADD CONSTRAINT `user_roles_ibfk_1` FOREIGN KEY (`user_k`) REFERENCES `users` (`user_k`),ADD CONSTRAINT `user_roles_ibfk_2` FOREIGN KEY (`role_k`) REFERENCES `roles` (`role_k`);") except Exception as e: self.logger.log(e, "WARNING") self.db.commitTransaction()
def __init__(self): self.db = serverTools.getPyEMONCMSDb() self.logger = serverTools.getLogger() self.bleexDb = serverTools.getSystemDb() self.db.beginTransaction() self.db.checkTable("users", [ {"name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY"}, {"name": "username", "type": "varchar(30)"}, {"name": "email", "type": "varchar(30)"}, {"name": "avatar", "type": "varchar(255)"}, {"name": "apikey_write", "type": "char(128)"}, {"name": "apikey_read", "type": "char(128)"}, {"name": "admin", "type": "INT(11) NOT NULL"}, {"name": "name", "type": "varchar(30) DEFAULT ''"}, {"name": "location", "type": "varchar(30) DEFAULT ''"}, {"name": "timezone", "type": "INT(11) DEFAULT 0"}, {"name": "language", "type": "varchar(5) DEFAULT 'en_EN'"}, {"name": "bio", "type": "text"}]) self.db.checkTable("menu_left", [ {"name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY"}, {"name": "name", "type": "text"}, {"name": "value", "type": "text"}]) self.db.checkTable("menu_right", [ {"name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY"}, {"name": "name", "type": "text"}, {"name": "value", "type": "text"}]) self.db.checkTable("menu_dropdown", [ {"name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY"}, {"name": "name", "type": "text"}, {"name": "value", "type": "text"}]) self.db.checkTable("dashboard", [ {"name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY"}, {"name": "userid", "type": "int(11)"}, {"name": "content", "type": "text"}, {"name": "height", "type": "int(11)"}, {"name": "name", "type": "varchar(30) DEFAULT 'no name'"}, {"name": "alias", "type": "varchar(10)"}, {"name": "description", "type": "varchar(255) DEFAULT 'no description'"}, {"name": "main", "type": "tinyint(1) DEFAULT false"}, {"name": "public", "type": "tinyint(1) DEFAULT false"}, {"name": "published", "type": "tinyint(1) DEFAULT false"}, {"name": "showdescription", "type": "tinyint(1) DEFAULT false"}]) self.db.checkTable("feeds", [ {"name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY"}, {"name": "userid", "type": "int(11)"}, {"name": "name", "type": "text"}, {"name": "tag", "type": "text"}, {"name": "time", "type": "datetime"}, {"name": "value", "type": "float"}, {"name": "datatype", "type": "INT(11) NOT NULL"}, {"name": "public", "type": "tinyint(1) DEFAULT false"}, {"name": "size", "type": "INT(11)"}, {"name": "engine", "type": "INT(11) NOT NULL DEFAULT 0"}]) self.db.checkTable("input", [ {"name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY"}, {"name": "userid", "type": "int(11)"}, {"name": "name", "type": "text"}, {"name": "description", "type": "text"}, {"name": "time", "type": "datetime"}, {"name": "nodeid", "type": "int(11)"}, {"name": "processList", "type": "text"}, {"name": "value", "type": "float"}]) self.db.checkTable("myelectric", [ {"name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY"}, {"name": "userid", "type": "int(11)"}, {"name": "data", "type": "text"}]) self.db.checkTable("node", [ {"name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY"}, {"name": "userid", "type": "int(11)"}, {"name": "data", "type": "text"}]) self.db.checkTable("process_list", [ {"name": "id", "type": "INT NOT NULL AUTO_INCREMENT PRIMARY KEY"}, {"name": "description", "type": "text"}, {"name": "arg_type", "type": "varchar(30)"}, {"name": "function", "type": "varchar(30)"}, {"name": "num_datafields", "type": "INT"}, {"name": "datatype", "type": "varchar(30)"}, {"name": "heading", "type": "varchar(30)"}, {"name": "engine", "type": "text"}]) self.db.commitTransaction() self.setCMSUsers() self.checkCMSDefaults("menu_left", data={"name": 'Node', "value": '{\\\'path\\\': \\\'node/list\\\', \\\'session\\\': \\\'write\\\', \\\'order\\\': \\\'0\\\'}'}) self.checkCMSDefaults("menu_left", data={"name": "Input", "value": '{\\\'path\\\': \\\'input/view\\\', \\\'session\\\': \\\'write\\\', \\\'order\\\': \\\'1\\\'}'}) self.checkCMSDefaults("menu_left", data={"name": "Feeds", "value": "{\\'path\\': \\'feed/list\\', \\'session\\': \\'write\\', \\'order\\': \\'2\\'}"}) self.checkCMSDefaults("menu_left", data={"name": "Vis", "value": "{\\'path\\': \\'vis/list\\', \\'session\\': \\'write\\', \\'order\\': \\'3\\'}"}) self.checkCMSDefaults("menu_left", data={"name": "Dashboard", "value": "{\\'path\\': \\'dashboard/view\\', \\'session\\': \\'write\\', \\'order\\': \\'4\\'}"}) self.checkCMSDefaults("menu_left", data={"name": "My Electric", "value": "{\\'path\\': \\'myelectric\\', \\'session\\': \\'write\\', \\'order\\': \\'-2\\'}"}) self.checkCMSDefaults("process_list", data={"description": "Log to feed", "arg_type": "FEEDID", "function": "log_to_feed", "num_datafields": "1", "datatype": "REALTIME", "heading": "Main", "engine": "[\\'PHPFIWA\\', \\'PHPFINA\\']"}) self.checkCMSDefaults("process_list", data={"description": "x", "arg_type": "VALUE", "function": "scale", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Calibration"}) self.checkCMSDefaults("process_list", data={"description": "+", "arg_type": "VALUE", "function": "offset", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Calibration"}) self.checkCMSDefaults("process_list", data={"description": "Power to kWh", "arg_type": "FEEDID", "function": "power_to_kwh", "num_datafields": "1", "datatype": "REALTIME", "heading": "Power", "engine": "[\\'PHPFINA\\', \\'PHPTIMESERIES\\']"}) self.checkCMSDefaults("process_list", data={"description": "Power to kWh/d", "arg_type": "FEEDID", "function": "power_to_kwhd", "num_datafields": "1", "datatype": "DAILY", "heading": "Power", "engine": "[\\'PHPTIMESERIES\\']"}) self.checkCMSDefaults("process_list", data={"description": "x input", "arg_type": "INPUTID", "function": "times_input", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Input"}) self.checkCMSDefaults("process_list", data={"description": "Input on-time", "arg_type": "FEEDID", "function": "input_ontime", "num_datafields": "1", "datatype": "DAILY", "heading": "Input", "engine": "[\\'PHPTIMESERIES\\']"}) self.checkCMSDefaults("process_list", data={"description": "Wh increments to kWh/d", "arg_type": "FEEDID", "function": "kwhinc_to_kwhd", "num_datafields": "1", "datatype": "DAILY", "heading": "Power", "engine": "[\\'PHPTIMESERIES\\']"}) self.checkCMSDefaults("process_list", data={"description": "update feed @time", "arg_type": "FEEDID", "function": "update_feed_data", "num_datafields": "1", "datatype": "DAILY", "heading": "Input", "engine": "[\\'MYSQL\\']"}) self.checkCMSDefaults("process_list", data={"description": "+ input", "arg_type": "INPUTID", "function": "add_input", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Input"}) self.checkCMSDefaults("process_list", data={"description": "/ input", "arg_type": "INPUTID", "function": "divide_input", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Input"}) self.checkCMSDefaults("process_list", data={"description": "Accumulator", "arg_type": "FEEDID", "function": "accumulator", "num_datafields": "1", "datatype": "REALTIME", "heading": "Misc", "engine": "[\\PHPFINA\\', \\'PHPTIMESERIES\\']"}) self.checkCMSDefaults("process_list", data={"description": "Rate of change", "arg_type": "FEEDID", "function": "ratechange", "num_datafields": "1", "datatype": "REALTIME", "heading": "Misc", "engine": "[\\'PHPFIWA\\', \\'PHPFINA\\', \\'PHPTIMESERIES\\']"}) self.checkCMSDefaults("process_list", data={"description": "Histogram", "arg_type": "FEEDID", "function": "histogram", "num_datafields": "2", "datatype": "HISTOGRAM", "heading": "Power", "engine": "[\\'MYSQL\\']"}) # to be reintroduced in post-processing self.checkCMSDefaults("process_list", data={"description": "Heat flux", "arg_type": "FEEDID", "function": "heat_flux", "num_datafields": "1", "datatype": "REALTIME", "heading": "Deleted", "engine": "[\\'PHPFIWA\\', \\'PHPFINA\\', \\'PHPTIMESERIES\\']"}) # - look into implementation that doesnt need to store the ref feed self.checkCMSDefaults("process_list", data={"description": "Total pulse count to pulse increment", "arg_type": "FEEDID", "function": "pulse_diff", "num_datafields": "1", "datatype": "REALTIME", "heading": "Pulse", "engine": "[\\'PHPFINA\\', \\'PHPTIMESERIES\\']"}) # - look into state implementation without feed self.checkCMSDefaults("process_list", data={"description": "kWh to Power", "arg_type": "FEEDID", "function": "kwh_to_power", "num_datafields": "1", "datatype": "REALTIME", "heading": "Power", "engine": "[\\'PHPFIWA\\', \\'PHPFINA\\', \\'PHPTIMESERIES\\']"}) self.checkCMSDefaults("process_list", data={"description": "- input", "arg_type": "INPUTID", "function": "subtract_input", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Input"}) self.checkCMSDefaults("process_list", data={"description": "kWh to kWh/d", "arg_type": "FEEDID", "function": "kwh_to_kwhd", "num_datafields": "2", "datatype": "DAILY", "heading": "Power", "engine": "[\\'PHPTIMESERIES\\']"}) self.checkCMSDefaults("process_list", data={"description": "Allow positive", "arg_type": "NONE", "function": "allowpositive", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Limits"}) self.checkCMSDefaults("process_list", data={"description": "Allow negative", "arg_type": "NONE", "function": "allownegative", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Limits"}) self.checkCMSDefaults("process_list", data={"description": "Signed to unsigned", "arg_type": "NONE", "function": "signed2unsigned", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Misc"}) self.checkCMSDefaults("process_list", data={"description": "Max value", "arg_type": "FEEDID", "function": "max_value", "num_datafields": "1", "datatype": "DAILY", "heading": "Misc", "engine": "[\\'PHPTIMESERIES\\']"}) self.checkCMSDefaults("process_list", data={"description": "Min value", "arg_type": "FEEDID", "function": "min_value", "num_datafields": "1", "datatype": "DAILY", "heading": "Misc", "engine": "[\\'PHPTIMESERIES\\']"}) self.checkCMSDefaults("process_list", data={"description": " + feed", "arg_type": "FEEDID", "function": "add_feed", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Feed"}) # Klaus 24.2.2014 self.checkCMSDefaults("process_list", data={"description": " - feed", "arg_type": "FEEDID", "function": "sub_feed", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Feed"}) # Klaus 24.2. self.checkCMSDefaults("process_list", data={"description": " * feed", "arg_type": "FEEDID", "function": "multiply_by_feed", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Feed"}) self.checkCMSDefaults("process_list", data={"description": " / feed", "arg_type": "FEEDID", "function": "divide_by_feed", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Feed"}) self.checkCMSDefaults("process_list", data={"description": "Reset to ZERO", "arg_type": "NONE", "function": "reset2zero", "num_datafields": "0", "datatype": "UNDEFINED", "heading": "Misc"}) self.checkCMSDefaults("process_list", data={"description": "Wh Accumulator", "arg_type": "FEEDID", "function": "wh_accumulator", "num_datafields": "1", "datatype": "REALTIME", "heading": "Main", "engine": "[\\'PHPFINA\\', \\'PHPTIMESERIES\\']"})
def __init__(self): self.db = serverTools.getSystemDb()