def setup_app(command, conf, vars): """Place any commands to setup astportal2 here""" load_environment(conf.global_conf, conf.local_conf) # Load the models from astportal2 import model print "Dropping tables" model.metadata.drop_all(bind=config['pylons.app_globals'].sa_engine) print "Creating tables" model.metadata.create_all(bind=config['pylons.app_globals'].sa_engine) # for table in (model.User, model.Group, model.Permission, model.CDR, model.Phone, model.Department, model.Phonebook, model.Sound, model.Queue, model.Queue_log, model.Queue_event, model.Pickup, model.Application, model.Scenario, model.Action, model.Holiday): # table.__table__.create(bind=config['pylons.app_globals'].sa_engine) u = model.User() # u.user_id = -1 u.user_name = u'admin' u.display_name = u'Administrateur' u.email_address = u'*****@*****.**' u.password = u'0000' model.DBSession.add(u) g = model.Group() # g.group_id = -1 g.group_name = u'admin' g.display_name = u'Groupe des administrateurs' g.users.append(u) model.DBSession.add(g) d = model.Department() # d.dptm_id = -1 d.name = u'Divers' d.comment = u'Téléphones divers' model.DBSession.add(d) actions = ((u'Début', u''), (u'Annonce', u'Joue un fichier ou un message'), (u'Menu', u'Joue un fichier, saute vers choix'), (u'Saisie', u'Joue un fichier, attend entrée'), (u'Raccroché', u'Fin de communication'), (u'Synthèse', u'Lit le texte'), (u'Enregistrement', u'joue message, puis enregistre appelant'), (u'Transfert', u'appel nouveau numéro, puis transfert'), (u'Service', u'requête web'), (u'Boucle', u'Répétition action'), (u'Décision', u'Test variable, puis action'), (u'Planification', u'Décision basée sur date / heure'), (u'Bloc', u'Création nouveau bloc'), (u'Variable', u'Création / modification d\'une variable'), (u'Saut', u'Saut vers action'), (u'Sélection', u'Joue un fichier, stocke choix'), (u'Etiquette', u'Cible pour l\'application "saut"'), (u'En base', u'Sauvegarde variable en base de données'), (u'Jour férié', u'Vérification jour férié'), (u'Messagerie', u'Dépôt message vocal'), (u'Groupe', u'Transfert groupe d\'appel'), (u'Trace', u'Trace dans journal groupe d\'appel'), ) for i, a in enumerate(actions): act = model.Action() act.action_id = i act.name = a[0] act.comment = a[1] model.DBSession.add(act) q_events = 'UNKOWN ABANDON AGENTDUMP AGENTLOGIN AGENTCALLBACKLOGIN AGENTLOGOFF AGENTCALLBACKLOGOFF COMPLETEAGENT COMPLETECALLER CONFIGRELOAD CONNECT ENTERQUEUE EXITWITHKEY EXITWITHTIMEOUT QUEUESTART SYSCOMPAT TRANSFER PAUSE UNPAUSE RINGNOANSWER EXITEMPTY PAUSEALL UNPAUSEALL ADDMEMBER REMOVEMEMBER INCOMING CLOSED DISSUASION INFO'.split() for i, e in enumerate(q_events): qe = model.Queue_event() qe.qe_id = i+1 qe.event = e model.DBSession.add(qe) model.DBSession.flush() transaction.commit() print "Successfully setup"
#! /opt/Python-2.6.7/bin/python # -*- coding: utf-8 -*- # # Calcul du coût des appels sortants # # Jean-Denis Girard <*****@*****.**> # SysNux (c) http://www.sysnux.pf/ from paste.deploy import appconfig from astportal2.config.environment import load_environment from astportal2 import model from sqlalchemy import desc conf = appconfig('config:/home/astportal21/csb-shell.ini') load_environment(conf.global_conf, conf.local_conf) DBSession = model.DBSession CDR = model.CDR Phone = model.Phone # Dictionnaire utilisateur SIP -> utilisateur, département sip = {} for p in DBSession.query(Phone): u = p.user.user_name if p.user else 'Inconnu' d = p.department.name if p.department else 'Inconnu' # print p.sip_id, u, d sip[p.sip_id] = {'u': u, 'd': d} # Recherche des appels sortant vers la passerelle Mediatrix, dont le coût n'a # pas encore été calculé cdrs = DBSession.query(CDR).filter(CDR.dstchannel.like('SIP/TOICSB%'))
#! /home/SysNux/tg234/bin/python # -*- coding: utf-8 -*- from os import popen from sys import path, exit, argv from getopt import getopt import re import logging logging.basicConfig() path.insert(0, '/home/SysNux/Projets/astportal3') from paste.deploy import appconfig from astportal2.config.environment import load_environment conf = appconfig('config:/home/SysNux/Projets/astportal3/tiare.ini') load_environment(conf.global_conf, conf.local_conf) # Needed for DBSession from tg import config from astportal2.lib.grandstream import Grandstream from astportal2.model import DBSession, Phone server_sip = config.get('server.sip') server_firmware = config.get('server.firmware') server_config = config.get('server.config') server_syslog = config.get('server.syslog') server_ntp = config.get('server.ntp') command_fping = config.get('command.fping') command_arp = config.get('command.arp') directory_tftp = config.get('directory.tftp') directory_asterisk = config.get('directory.asterisk')
def load_config(filename): conf = appconfig('config:' + os.path.abspath(filename)) load_environment(conf.global_conf, conf.local_conf)