Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 61 lines (52 sloc) 1.946 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
#!/usr/bin/env python
''' SvxLinkWrapper - wrapper for SvxLink
This is a template module that all other svxlinkwrapper modules extend

Created on Feb 1, 2012
@author: Guy Sheffer <guysoft at gmail dot com>
'''
import json

def turpleList2Dict(tupleList):
    ''' Convert a tuple list to a dict. For easy and saner access
Used in this project because config parser returns a list of tuples
@param tupleList the list of tuples
@return: a dict with lists for each variable
'''
    returnDict={}
    for turple in tupleList:
        key = turple[0]
        data = turple[1]
        if data.startswith("["):#turn to a list if lists
            data = json.loads(data)
        returnDict[key]=data
    return returnDict

class SvxlinkwrapperModule(object):
    def __init__(self,SvxLink):
        self.SvxLink = SvxLink
        return
    
    def handleStdout(self,line):
        '''
Every stdout message would call this function
'''
        return
    
    def shutdown(self):
        '''
Runs when we get ctrl-c to exit
'''
        return
    
    def getConfigVar(self,value):
        '''Get a value from the config ini for a module
@param value - the value you wnat
@return: the value from config.ini
'''
        return self.SvxLink.config.get("modules."+self.__class__.__name__, value)
    
    def getConfigList(self,value):
        '''Get a value from the config ini for a module
@param value - the value you wnat
@return: the value from config.ini
'''
        return json.loads(self.SvxLink.config.get("modules."+self.__class__.__name__, value))
    
    def getConfigFullDict(self):
        ''' Get the whole config as a dict, useful if you need to move it to other clases
@return: a dict with all the config vars from config.ini
'''
        return turpleList2Dict(self.SvxLink.config.items("modules."+self.__class__.__name__))
Something went wrong with that request. Please try again.