Asterisk 16 has the status of macros deprecated.
Which is an alternative of the macros in Asterisk?
Macro() and MacroExit() are now replaced by Gosub() and Return()
Be carefull when runing Gosub's, as variables will be shared across all of your Gosub.
In case you call a Gosub(context_1,s,1) that's running a same => n,Set(test="foo") to set variable test, this variable will be accessible and set on a Gosub(context_2,s,1) for example
Alternative:
Macro() => Gosub()
MacroExit() => Return()
Please note, the name of the context you are going in to Gosub() to, are not prefixed, like it was with Macro(), where it was prefixed with "macro-".
Related
I need to insert some data to SQL ftom Asterisk dialplan. I am using ODBC connection and func_odbc.conf file. There are good way to READ several values from SQl, but apparently, i can't find any working solution for inserting several variables to func_odbc function.
I already tried to use NoOp(ODBC_FunctionName(${ARG1},${ARG2},${ARG3})) and it does not work with 'writesql'. Set(${ODBC_Function()={${ARG1},${ARG2},${ARG3}}) is not working either due to Set limited for one name/value pair.
Here is my func_odbc:
[putClientEvaluation]
;${ARG1} - uniqueid
;${ARG2} - operator
;${ARG3} - client
;${ARG4} - rating
;${ARG5} - queue
dsn=voip
writesql=INSERT INTO cc_service_rating(timestamp,callid,operator,client,rating,queue) values(now(),'${SQL_ESC(${ARG1})}','${SQL_ESC(${ARG2})}','${SQL_ESC(${ARG3})}','${SQL_ESC(${ARG4})}','${SQL_ESC(${ARG5})}')
So i need a working way to pass several arguments at once to odbc writesql function.
UPDATE:
Looks like i just have to use VAL instead of ARG:
writesql=INSERT INTO cc_service_rating(timestamp,callid,operator,client,rating,queue) values(now(),'${SQL_ESC(${VAL1})}','${SQL_ESC(${VAL2})}','${SQL_ESC(${VAL3})}','${SQL_ESC(${VAL4})}','${SQL_ESC(${VAL5})}')
But i still get warning from Set:
WARNING[1227][C-00000020]: pbx_variables.c:1155 pbx_builtin_setvar: Set requires one variable name/value pair.
So, how do i do this without using Set?
UPD:
Did this, no warnings now:
macro extension
exten => s,n,Set(operator=${ARG1})
exten => s,n,Set(quename=${ARG2})
exten => s,n,Set(client=${ARG3})
;timestamp,callid,operator,client,rating,queue
exten => s,n,Set(ODBC_putClientEvaluation()=${UNIQUEID},${operator},${client},${MACRO_EXTEN},${quename})
function
writesql=INSERT INTO cc_service_rating(timestamp,callid,operator,client,rating,queue) values(now(),'${VAL1}','${ARG1}','${ARG3}','${VAL2}','${ARG3}')
Not shure why does this work, obviousely i don't understand how ARG and VAL works here, and why putting args in function brackets does not work at all (even with comma screening).
You are using variables incorrect. Please read book article about variables.
Set(ODBC_Function(${ARG1},${ARG2})=${VAL1},"fixed_param",${VAL3})
I think you should try like this:
Set(ODBC_Function()=${VAR1},"fixed_param",${VAL3});
I'm having problem understanding how to correctly set the COMPILE_DEFINITIONS target properti in CMake.
my target is add_library(modelutilities STATIC ${modelutilities_SRCS})
I if use
set(modelutilities_COMPILE_DEFINE ${modelutilities_COMPILE_DEFINE} ${Qt5Widgets_COMPILE_DEFINITIONS})
set_target_properties(modelutilities PROPERTIES
VERSION "0.0.1"
SOVERSION 0
EXPORT_NAME "ModelUtilities"
ARCHIVE_OUTPUT_DIRECTORY "${modelutilities_PlatformDir}/lib"
LIBRARY_OUTPUT_DIRECTORY "${modelutilities_PlatformDir}/lib"
RUNTIME_OUTPUT_DIRECTORY "${modelutilities_PlatformDir}/bin"
COMPILE_DEFINITIONS ${modelutilities_COMPILE_DEFINE}
)
everything works fine, but if I add another line between them with set(modelutilities_COMPILE_DEFINE ${modelutilities_COMPILE_DEFINE} MODELUTILITIES_LIB) it stops working complaining that set_target_properties was called with the wrong number of arguments.
Anyone can spot what I'm doing wrong?
P.S.
I already tried using doublequotes: set(modelutilities_COMPILE_DEFINE ${modelutilities_COMPILE_DEFINE} "MODELUTILITIES_LIB"). It did not change anything
P.P.S.
If I message(STATUS ${modelutilities_COMPILE_DEFINE}) QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB in the first case and QT_WIDGETS_LIB;QT_GUI_LIB;QT_CORE_LIB;MODELUTILITIES_LIB in the second
With newer version of CMake, what is being preached is the idea of targets. So, for example, instead of include_directories() it's now preferred to use target_include_directories().
That being the case I think you'd be better served using the preferred target_compile_definitions() to set compile definitions for your utilities library.
One advantage you get is that your can scope your compile definitions using the PUBLIC or PRIVATE keywords.
If I have data set named 'example' and it has 'id'variable.
I want to create function like this;
a<-function(data,variable){
work<-data[!duplicated(data$variable),]
work$obs<-c(1:length(work$variable))
work1<-merge.data.frame(data, work, by="variable")
}
a(data=example, variable=weight)
There is no warning message but it doesn't work.
'work' and 'work1' data set is not created.
When I run this code without function, it works.
The reason it doesn't work is that work and work1 only exist in your function. You need to set it globally for it to exist outside. Try:
a<-function(data,variable){
work<<-data[!duplicated(data$variable),]
work$obs<-c(1:length(work$variable))
work1<<-merge.data.frame(data, work, by="variable")
}
a(data=example, variable=weight)
However, I wouldn't recommend doing this as every time you run your function you will overwrite work and work1 in your environment. Consider returning something and using this to overwrite your variables.
I'm trying to write a completion method for fsharpi (F# interactive), which has options like the following:
--use:<file> Use the given file on startup as initial input
--debug:{full|pdbonly} Specify debugging type: full, pdbonly. ('full' is the default and enables attaching a debugger to a running program).
--warn:<n> Set a warning level (0-5)
I'm guessing this has to be handled with $state similarly to sub-commands, but the documentation is monolithic and the language isn't very descriptive, so I've gotten nowhere with experimentation and by stitching together different examples.
A solution to this would also work for aspell, which uses an equals-sign instead of the colon e.g.
--conf=<str> main configuration file
This is one of the most common forms of completion, and it can be easily handled by _arguments. Note that literal colons in options can be quoted with a backslash. Here's the code example:
#compdef command
arguments=(
'--use\:-:initial input file:_files'
'--debug\:-:debugging type:(full pbonly)'
'--warn\:-:warning level:(0 1 2 3 4 5)'
)
_arguments -S $arguments[#]
Reference: _arguments in official documentation.
I am running ruby unit tests against Chrome using watir-webdriver. Whenever a test is run and chromedriver.exe is launched output similar to below appears:
Started ChromeDriver
port=9515
version=26.0.1383.0
log=C:\Home\Server\Test\Watir\web\chromedriver.log
[5468:8796:0404/150755:ERROR:accelerated_surface_win.cc(208)] Reseting D3D device
[5468:8996:0404/150758:ERROR:textfield.h(156)] NOT IMPLEMENTED
[WARNING:..\..\..\..\flash\platform\pepper\pep_module.cpp(63)] SANDBOXED
None of this impacts the correct functioning of the tests, but as one might imagine the appearance of "ERROR" and "WARNING" might be rather confusing to, for example, parsing rules in Jenkins looking for failures. Sure I can get really fancy with regular expression in the parsing rules, but it would be really nice to turn off this verbose and unnecessary logging on the part of chromedriver.exe. I have seen many mentions of this searching for an answer. No one has come up with a solution. Yes, chromedriver possibly has a "--silent" option, but there seems to be no way to pass that to the executable. Code similar to below is supposed to work, but has zero effect as far as I can see. Any ideas?
profile = Selenium::WebDriver::Chrome::Profile.new
profile['--cant-make-any-switches-work-here-how-about-you'] = true
browser = Watir::Browser.new :chrome, :profile => profile, :switches => %w[--ignore-certificate-errors --disable-extensions --disable-popup-blocking --disable-translate--allow-file-access]
Here's help for anyone else searching
Find ...selenium\webdriver\chrome\service.rb
Path start may differ on your system
And I added "-silent" to the passed parameters .... However, this silenced everything but the error/warning messages.
def initialize(executable_path, port)
#uri = URI.parse "http://#{Platform.localhost}:#{port}"
server_command = [executable_path, " -silent", "--port=#{port}"]
#process = ChildProcess.build(*server_command)
#socket_poller = SocketPoller.new Platform.localhost, port, START_TIMEOUT
#process.io.inherit! if $DEBUG == true
end
set chromeOptions with key --log-level=3 this should shut it up
I was able to divert the hundreds, yes hundreds, of chrome driver log messages that were showing up in cucumber stdout by using the :service_log_path argument.
#browser = Watir::Browser.new :chrome, :service_log_path => 'chromedriver.out'
the '-silent', or '--silent', or ' -silent', or ' --silent' parameter suggested above did nothing when I added it to ...selenium\webdriver\chrome\service.rb. And having to tweak the gem itself is not a particularly viable solution.
I couldn't find a place to capture the chromedriver stderr and divert it to null (not to mention having to handle doing that in windows and in *nix/osx)
The driver should default to something way less verbose. In this case INFO is way too verbose as hundreds of log entries pop out as INFO, 90%+ of them identical.
At least the :service_log_path argument works most of them.
You can try -Dwebdriver.chrome.logfile="/dev/null" and/or -Dwebdriver.chrome.args="--disable-logging" to the options of java that runs selenium-server-standalone-what.ever.jar