[svn-commits] russell: branch russell/bindings r102966 - /team/russell/bindings/cdr/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Feb 7 22:55:40 CST 2008


Author: russell
Date: Thu Feb  7 22:55:39 2008
New Revision: 102966

URL: http://svn.digium.com/view/asterisk?view=rev&rev=102966
Log:
Add a CLI command to show configuring python cdr modules as well as some info
from python - the version and current search path

Modified:
    team/russell/bindings/cdr/cdr_python.c

Modified: team/russell/bindings/cdr/cdr_python.c
URL: http://svn.digium.com/view/asterisk/team/russell/bindings/cdr/cdr_python.c?view=diff&rev=102966&r1=102965&r2=102966
==============================================================================
--- team/russell/bindings/cdr/cdr_python.c (original)
+++ team/russell/bindings/cdr/cdr_python.c Thu Feb  7 22:55:39 2008
@@ -42,6 +42,7 @@
 #include "asterisk/linkedlists.h"
 #include "asterisk/config.h"
 #include "asterisk/astobj2.h"
+#include "asterisk/cli.h"
 
 #include "../bindings/swigpyrun.h"
 
@@ -178,6 +179,58 @@
 	py_cdr_mod = unref_py_cdr_mod(py_cdr_mod);
 }
 
+static int print_py_cdr_mod(void *obj, void *arg, int flags)
+{
+	int fd = *((int *) arg);
+	struct py_cdr_mod *py_cdr_mod = obj;
+
+	ast_cli(fd, "=== ---> %s\n", py_cdr_mod->name);
+
+	return 0;
+}
+
+static char *cli_python_settings(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+	char *version, *str;
+
+	switch (cmd) {
+	case CLI_INIT:
+		e->command = "python settings";
+		e->usage =
+			"Usage: python settings\n"
+			"   Show various settings for the Python bindings.\n";
+		return NULL;
+	case CLI_GENERATE:
+		return NULL;
+	}
+
+	ast_cli(a->fd, "\n"
+	            "=============================================================\n"
+	            "=== Python Bindings Settings ================================\n"
+	            "=============================================================\n"
+	            "===\n");
+
+	str = ast_strdupa(Py_GetVersion());
+	version = strsep(&str, "\n");
+	ast_cli(a->fd, "=== Python Version: %s\n", version);
+	while ((version = strsep(&str, "\n")))
+		ast_cli(a->fd, "===                 %s\n", version);
+
+	ast_cli(a->fd, "=== Python Path: %s\n", Py_GetPath());
+
+	ast_cli(a->fd, "===\n=== Configured CDR Modules:\n");
+
+	ao2_callback(py_cdr_mods, 0, print_py_cdr_mod, &a->fd);
+
+	ast_cli(a->fd, "===\n=============================================================\n\n");
+
+	return 0;
+}
+
+static struct ast_cli_entry cli_cdr_python[] = {
+	AST_CLI_DEFINE(cli_python_settings, "Show Python bindings settings"),
+};
+
 static int reload_module(void)
 {
 	struct ast_config *cfg;
@@ -205,6 +258,7 @@
 static int unload_module(void)
 {
 	ast_cdr_unregister(cdr_mod_name);
+	ast_cli_unregister_multiple(cli_cdr_python, ARRAY_LEN(cli_cdr_python));
 
 	PyEval_AcquireLock();
 	Py_Finalize();
@@ -252,6 +306,8 @@
 		return AST_MODULE_LOAD_DECLINE;
 	}
 
+	ast_cli_register_multiple(cli_cdr_python, ARRAY_LEN(cli_cdr_python));
+
 	return AST_MODULE_LOAD_SUCCESS;
 }
 




More information about the svn-commits mailing list