Asterisk - The Open Source Telephony Project  18.5.0
Functions | Variables
sip_to_pjsql Namespace Reference

Functions

def cli_options ()
 
def write_pjsip (filename, pjsip, non_mappings)
 

Variables

 non_mappings
 
 pjsip
 
 pjsip_filename
 
 sip = sqlconfigparser.SqlConfigParser(table)
 
 sip_filename
 

Function Documentation

◆ cli_options()

def sip_to_pjsql.cli_options ( )
Parse command line options and apply them. If invalid input is given,
print usage information

Definition at line 22 of file sip_to_pjsql.py.

References len().

22 def cli_options():
23  """
24  Parse command line options and apply them. If invalid input is given,
25  print usage information
26 
27  """
28  global user
29  global password
30  global host
31  global port
32  global database
33  global table
34 
35  usage = "usage: %prog [options] [input-file [output-file]]\n\n" \
36  "Converts the chan_sip configuration input-file to mysql output-file.\n" \
37  "The input-file defaults to 'sip.conf'.\n" \
38  "The output-file defaults to 'pjsip.sql'."
39  parser = optparse.OptionParser(usage=usage)
40  parser.add_option('-u', '--user', dest='user', default="root",
41  help='mysql username')
42  parser.add_option('-p', '--password', dest='password', default="root",
43  help='mysql password')
44  parser.add_option('-H', '--host', dest='host', default="127.0.0.1",
45  help='mysql host ip')
46  parser.add_option('-P', '--port', dest='port', default="3306",
47  help='mysql port number')
48  parser.add_option('-D', '--database', dest='database', default="asterisk",
49  help='mysql port number')
50  parser.add_option('-t', '--table', dest='table', default="sippeers",
51  help='name of sip realtime peers table')
52 
53  options, args = parser.parse_args()
54 
55  user = options.user
56  password = options.password
57  host = options.host
58  port = options.port
59  database = options.database
60  table = options.table
61 
62  sip_filename = args[0] if len(args) else 'sip.conf'
63  pjsip_filename = args[1] if len(args) == 2 else 'pjsip.sql'
64 
65  return sip_filename, pjsip_filename
66 
def cli_options()
Definition: sip_to_pjsql.py:22
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)

◆ write_pjsip()

def sip_to_pjsql.write_pjsip (   filename,
  pjsip,
  non_mappings 
)
Write pjsip.sql file to disk

Definition at line 11 of file sip_to_pjsql.py.

11 def write_pjsip(filename, pjsip, non_mappings):
12  """
13  Write pjsip.sql file to disk
14  """
15  try:
16  with open(filename, 'wt') as fp:
17  pjsip.write(fp)
18 
19  except IOError:
20  print("Could not open file " + filename + " for writing")
21 
def write_pjsip(filename, pjsip, non_mappings)
Definition: sip_to_pjsql.py:11

Variable Documentation

◆ non_mappings

non_mappings

Definition at line 77 of file sip_to_pjsql.py.

◆ pjsip

pjsip

Definition at line 77 of file sip_to_pjsql.py.

◆ pjsip_filename

pjsip_filename

Definition at line 68 of file sip_to_pjsql.py.

◆ sip

Definition at line 69 of file sip_to_pjsql.py.

◆ sip_filename

sip_filename

Definition at line 68 of file sip_to_pjsql.py.