def __init__(self): self.settings = serverTools.getCMSSettings() if self.settings == None: self.settings = cmsSettings.Settings() serverTools.setCMSSettings(self.settings) self.logger = serverTools.getLogger() self.timezoneoffset = None
def __init__(self): self.settings = serverTools.getCMSSettings() if self.settings == None: self.settings = cmsSettings.Settings() serverTools.setCMSSettings(self.settings) self.logger = serverTools.getLogger() self.csvdownloadlimit_mb = 10 # 5 years of daily data self.max_npoints_returned = 1825 // Load different storage engines require "Modules/feed/engine/MysqlTimeSeries.php"; require "Modules/feed/engine/Timestore.php"; require "Modules/feed/engine/PHPTimestore.php"; require "Modules/feed/engine/Histogram.php"; require "Modules/feed/engine/PHPTimeSeries.php"; require "Modules/feed/engine/GraphiteTimeSeries.php"; // Development engines require "Modules/feed/engine/PHPFina.php"; require "Modules/feed/engine/PHPFiwa.php"; // Backwards compatibility if (!isset($settings)) $settings= array(); if (!isset($settings['timestore'])) { global $timestore_adminkey; $settings['timestore'] = array('adminkey'=>$timestore_adminkey); }
def __init__(self): self.settings = serverTools.getCMSSettings() if self.settings == None: self.settings = cmsSettings.Settings() serverTools.setCMSSettings(self.settings) self.logger = serverTools.getLogger() self.max_node_id_limit = 32
def __init__(self): self.settings = serverTools.getCMSSettings() if self.settings == None: self.settings = cmsSettings.Settings() serverTools.setCMSSettings(self.settings) self.logger = serverTools.getLogger() self.max_node_id_limit = 32
def __init__(self): self.ampdb = serverTools.getAmpDb() self.logger = serverTools.getLogger() self.username = "" self.password = "" self.extension_high = "" self.extension_low = "" self.deptname = "" self.sections = ""
def __init__(self): self.ampdb = serverTools.getAmpDb() self.logger = serverTools.getLogger() self.username = "" self.password = "" self.extension_high = "" self.extension_low = "" self.deptname = "" self.sections = ""
from flask import jsonify, render_template, session from ironworks import serverTools from ironworks.updater import checkGithub, Update import ironworks app = serverTools.getApp() logger = serverTools.getLogger() COMMITS_BEHIND = serverTools.getCommitsBehind() COMMITS_COMPARE_URL = serverTools.getCommitsCompareURL() @app.route('/xhr/update_bar') def xhr_update_bar(): if 'username' in session: if ironworks.COMMITS_BEHIND != 0: return render_template('includes/update_bar.html', commits=ironworks.COMMITS_BEHIND, compare_url=ironworks.COMMITS_COMPARE_URL, ) else: return jsonify(up_to_date=True) else: return @app.route('/xhr/updater/check') def xhr_update_check(): if 'username' in session: check = checkGithub() return jsonify(update=check) else:
from flask import jsonify, render_template, session import jsonrpclib from ironworks import serverTools from ironworks.noneditable import * from ironworks.tools import * app = serverTools.getApp() logger = serverTools.getLogger() @app.route('/xhr/currently_playing') def xhr_currently_playing(): if 'username' in session: try: api_address = server_api_address() if not api_address: raise Exception xbmc = jsonrpclib.Server(api_address) active_player = xbmc.Player.GetActivePlayers() playerid = active_player[0]['playerid'] player_info = xbmc.Player.GetProperties(playerid=playerid, properties=[ 'time', 'totaltime', 'position', 'percentage', 'repeat', 'shuffled' ]) volume = xbmc.Application.GetProperties( properties=['volume'])['volume']
def __init__(self): self.settings = serverTools.getCMSSettings() self.logger = serverTools.getLogger()
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, extdisplay=None, restrictmods=None, skip_astman=None, handler=None): self.db = serverTools.getPrefsDb() self.ampDB = serverTools.getAmpDb() self.logger = serverTools.getLogger() self.bootstrap_settings = {} self.action = self.db.getPBXAction() self.confirm_email = self.db.getPBXConfirmEmail() self.confirm_password = self.db.getPBXConfirmPassword() self.display = self.db.getPBXDisplay() if self.db.getPBXExtdisplay() == "False": self.extdisplay = False else: self.extdisplay = self.db.getPBXExtdisplay() self.email_address = self.db.getPBXEmailAddress() self.fw_popover = self.db.getPBXFwPopover() self.fw_popover_process = self.db.getPBXFwPopoverProcess() self.logout = self.db.getPBXLogout() self.password = self.db.getPBXPassword() self.quietmode = self.db.getPBXQuietMode() if self.db.getPBXRestrcitmods() == "False": self.restrictmods = False else: self.restricmods = self.db.getPBXRestrcitmods() self.skip = self.db.getPBXSkip() if self.db.getPBXSkipAstman() == "False": self.skip_astman = False else: self.skip_astman = self.db.getPBXSkipAstman() self.type = self.db.getPBXType() self.username = self.db.getPBXUsername() if extdisplay != None and extdisplay != False: # htmlspecialchars($extdisplay, ENT_QUOTES) : false; self.extdisplay = extdisplay if restrictmods != None: self.restrictmods = restrictmods if skip_astman != None: self.skip_astman = skip_astman self.bootstrap_settings['skip_astman'] = skip_astman self.ampUser = ampuser.class.Ampuser_Class() if handler != None: if self.restrictmods == 'False': self.restrictmods = 'True' if 'api' in handler: pass if 'reload' in handler: pass # If we didn't provide skip_astman in the $_REQUEST[] array # it will be boolean false and for handlers, this should default # to true, if we did provide it, it will NOT be a boolean # (it could be 0) so we will honor the setting if self.bootstrap_settings['skip_astman'] == 'False': self.bootstrap_settings['skip_astman'] = 'True' self.bootstrap = bootstrap.Bootstrap(self.bootstrap_settings, self.restricmods)
def __init__(self, bootstrap_settings, restrictmods): self.logger = serverTools.getLogger() self.freepbx_log = serverTools.getFreePBXLog() self.bootstrap_settings = bootstrap_settings self.restrict_mods = restrictmods # Read the freepbx.conf file to ensure consistancy # TODO: Update the freepbx.conf file when changes are made in pyFreePBX try: freePBXConf = open('/etc/freepbx.conf', 'r') except: try: freePBXConf = open('/etc/asterisk/freepbx.conf', 'r') except: self.logger.log("Unable to open 'freepbx.conf'!", "ERROR") settings = {} key = "" foundKey = False value = "" foundValue = False j = 0 if freePBXConf: for line in freePBXConf: if "[" in line: for i in range(10, len(line)): if foundKey == False and foundValue == False and line[i] != '\'': key += line[i] if foundKey == False and foundValue == False and line[i + 1] == '\'': key += line[i] foundKey = True j = i + 6 for i in range(j, len(line)): if foundKey and foundValue == False and line[i] != '\'': value += line[i] try: if foundKey and foundValue == False and line[i + 1] == '\'': foundValue = True except: pass if foundKey and foundValue: settings[key] = value key = "" foundKey = False value = "" foundValue = False j = 0 try: bootstrapped = self.bootstrap_settings['bootstrapped'] if bootstrapped: self.logger.log("Bootstrap has already been called once, bad code somewhere", "ERROR") self.freepbx_log("FPBX_LOG_ERROR", "Bootstrap has already been called once, bad code somewhere") return except: self.bootstrap_settings['bootstrapped'] = True try: self.bootstrap_settings['skip_astman'] except: self.bootstrap_settings['skip_astman'] = False try: self.bootstrap_settings['astman_config'] except: self.bootstrap_settings['astman_config'] = "" try: self.bootstrap_settings['astman_options'] if len(self.bootstrap_settings['astman_options']) > 0: pass else: self.bootstrap_settings['astman_options'] = [] except: self.bootstrap_settings['astman_options'] = [] try: self.bootstrap_settings['astman_events'] except: self.bootstrap_settings['astman_events'] = "off" try: self.bootstrap_settings['freepbx_error_handler'] except: self.bootstrap_settings['freepbx_error_handler'] = True try: self.bootstrap_settings['freepbx_auth'] except: self.bootstrap_settings['freepbx_auth'] = True try: self.bootstrap_settings['cdrdb'] except: self.bootstrap_settings['cdrdb'] = False
def __init__(self, bootstrap_settings, restrictmods): self.logger = serverTools.getLogger() self.freepbx_log = serverTools.getFreePBXLog() self.bootstrap_settings = bootstrap_settings self.restrict_mods = restrictmods # Read the freepbx.conf file to ensure consistancy # TODO: Update the freepbx.conf file when changes are made in pyFreePBX try: freePBXConf = open('/etc/freepbx.conf', 'r') except: try: freePBXConf = open('/etc/asterisk/freepbx.conf', 'r') except: self.logger.log("Unable to open 'freepbx.conf'!", "ERROR") settings = {} key = "" foundKey = False value = "" foundValue = False j = 0 if freePBXConf: for line in freePBXConf: if "[" in line: for i in range(10, len(line)): if foundKey == False and foundValue == False and line[ i] != '\'': key += line[i] if foundKey == False and foundValue == False and line[ i + 1] == '\'': key += line[i] foundKey = True j = i + 6 for i in range(j, len(line)): if foundKey and foundValue == False and line[i] != '\'': value += line[i] try: if foundKey and foundValue == False and line[ i + 1] == '\'': foundValue = True except: pass if foundKey and foundValue: settings[key] = value key = "" foundKey = False value = "" foundValue = False j = 0 try: bootstrapped = self.bootstrap_settings['bootstrapped'] if bootstrapped: self.logger.log( "Bootstrap has already been called once, bad code somewhere", "ERROR") self.freepbx_log( "FPBX_LOG_ERROR", "Bootstrap has already been called once, bad code somewhere" ) return except: self.bootstrap_settings['bootstrapped'] = True try: self.bootstrap_settings['skip_astman'] except: self.bootstrap_settings['skip_astman'] = False try: self.bootstrap_settings['astman_config'] except: self.bootstrap_settings['astman_config'] = "" try: self.bootstrap_settings['astman_options'] if len(self.bootstrap_settings['astman_options']) > 0: pass else: self.bootstrap_settings['astman_options'] = [] except: self.bootstrap_settings['astman_options'] = [] try: self.bootstrap_settings['astman_events'] except: self.bootstrap_settings['astman_events'] = "off" try: self.bootstrap_settings['freepbx_error_handler'] except: self.bootstrap_settings['freepbx_error_handler'] = True try: self.bootstrap_settings['freepbx_auth'] except: self.bootstrap_settings['freepbx_auth'] = True try: self.bootstrap_settings['cdrdb'] except: self.bootstrap_settings['cdrdb'] = False
def __init__(self): self.feed = None self.timestore_adminkey = None self.result = False self.logger = serverTools.getLogger() self.settings = serverTools.getCMSSettings()