regexp in oozie distcp action - hadoop

I am trying to copy all files that fit certain criteria into a folder
<action name="copy_mta_c">
<distcp xmlns="uri:oozie:distcp-action:0.2">
<arg>${NAME_NODE}${PATH_COMVERSE}${CURRENT_DATE_NO_DASH}_*/*mta.gz</arg>
<arg>${NAME_NODE}${PATH_MTA}/</arg>
</distcp>
<ok to="copy_mta_y"/>
<error to="KILL"/>
</action>
Here symbol * in ${CURRENT_DATE_NO_DASH}_* stands for A or B or C etc. It searches for all folders. If I use ${CURRENT_DATE_NO_DASH}_A it will only search 1 filder. How can I make it take only 2 out of all folders? I tried doing (A|B), but this didn't work.

I'm assuming this will be a bash expansion since your variables look like bash variables.
You can use this:
${CURRENT_DATE_NO_DASH}_[A-C]
Or this:
${CURRENT_DATE_NO_DASH}_{A,B,C}

Related

How To Reference Yaml File Relative to Launch File?

I have a launch file that is loading a yaml file:
<launch>
<rosparam command="load file="filename.yaml" />
<node pkg="my_package" type="my_package_node" name="my_package_node" />
</launch>
The filename.yaml file cannot be found unless I put a complete path: "/home/username/blah/blah/blah". Seeing as this launch file is used on multiple machines by different users and locations for the repository, I obviously cannot hard-code the path. So now what? How do I reference it relative to the location of the launch file?
we can set environment variable PWD for the specified node, eg we'd like to pass a rviz configuration file to rviz, the relative path can be like this:
<arg name="rviz_file" value="$(eval env('PWD')+'/config/showme.rviz')"/>
<node name="rviz" pkg="rviz" type="rviz" args="-d $(arg rviz_file)" required="true" />
Best answer I could find myself was to use $(find package_name) as a starting point:
<launch>
<rosparam command="load file="$(find package_name)/../../yamlFolder/filename.yaml" />
<node pkg="my_package" type="my_package_node" name="my_package_node" />
</launch>
Seems kinda silly though. No reference to the path relative to the launch file itself? Would definitely like a better answer.
If You are using ROS Packages, Launch Folders Are in the root folder of Package So $(find package) are actually one folder before your launch file
If your yaml file is in a ROS package, then I think using the find substitution arg as you do in your answer is the cleanest route. If it's someplace else, I would suggest leveraging environment variables with something like
<launch>
<arg name="yaml_path" default="$(optenv YAML_PATH)"/>
<arg if="$(eval yaml_path == '')" name="yaml_file" value="$(env HOME)/some_folder/filename.yaml" />
<arg unless="$(eval yaml_path == '')" name="yaml_file" value="$(arg yaml_path)/filename.yaml"/>
<rosparam command="load" file="$(arg yaml_file)"/>
</launch>
This kind of gives the best of all worlds. If you've set YAML_PATH as an environment variable (e.g. export YAML_PATH="$HOME/some_path" from terminal or in your bashrc) then the path for yaml_file will use it. If not, optenv will evaluate to an empty string and the arg yaml_file will be set to some default path relative to your home folder. AND, if you have a user that doesn't want to mess with the environment variables at all, they can still pass in a path manually by calling it like
roslaunch my_launch_file.launch yaml_path:=/home/my_name/my_preferred_folder

klish command completion on pressing tab button

Hi I have small doubt in klish xml file. I implemented a small xml file for klish
<COMMAND name="show core"
help="It will show core status"
<ACTION> echo "core status" </ACTION>
</COMMAND>
I thought that by using command "show core" on klish command line it will print the core status as output but I am not able to print core status on command line of klish
How to solve ?
We can not use space in the < COMMAND > tag like in my case I used.
<COMMAND name="show core">
This is not the proper way to use space in the < COMMAND > tag
But if you want that your command should be like this only i.e. show core then there are two ways to achieve it.
First way:-
<COMMAND name="show"
help="Put what help you want to give"/>
<COMMAND name="show core"
help="Put what help you want to give">
<DETAIL>
</DETAIL>
<ACTION>echo "core status"</ACTION>
</COMMAND>
Second way:- Use VAR tag and completion attribute in PARAM tag
<COMMAND name="show"
help="Put what help you want to give">
<PARAM name="pname"
help="Put what help you want to give"
ptype="STRING"
completion="${vartagvariable}"/>
<DETAIL>
</DETAIL>
<ACTION>echo "core status"</ACTION>
<VAR name="vartagvariable" help="Something...." value="core" />
</COMMAND>

Import variable from bleg to aleg‏

I need to import a variable from b-leg to a-leg but renaming. I use the parameter
<action application="set" data="import=this_is_a_variable_name"/>
https://wiki.freeswitch.org/wiki/Variable_import
The problem is that I can not change the name of the variable. Change the value of the variable in aleg.
Is this possible?

Copy files preserving directory structure with rake

My goal is to copy a set of files specified by a pattern to the target dir. The files in source directory can have subdirs.
I tried:
cp_r(Dir.glob('**/*.html'), #target_dir):
and
cp_r(FileList['**/*.html'], #target_dir):
but neither work.
it only works when I do something like:
cp_r(Dir['.'], #target_dir):
But I need to copy only *.html files not anything else.
I need what
cp --parents
Command does
Any advice using existing Ruby/Rake methods?
UPDATE Looks like thing which is easier to do with Ant, is not possible with Ruby/Rake stack - may be I would need to look into something else. I don't want to write custom code to make it work in Ruby. I just thought about Ruby/Rake as appropriate solution for that.
UPDATE 2 This is how I do it with Ant
<target name="buildeweb" description="Builds web site" depends="clean">
<mkdir dir="${build.dir.web}" />
<copy todir="${build.dir.web}" verbose="true">
<fileset dir="${source.dir.web}">
<include name="**/*.html" />
<include name="**/*.htm" />
</fileset>
</copy>
<chmod perm="a+x">
<fileset dir="${build.dir.web}">
<include name="**/*.html" />
<include name="**/*.htm" />
</fileset>
</chmod>
</target>
If you want pure Ruby, you can do this (with a little help from FileUtils in the standard library).
require 'fileutils'
Dir.glob('**/*.html').each do |file|
dir, filename = File.dirname(file), File.basename(file)
dest = File.join(#target_dir, dir)
FileUtils.mkdir_p(dest)
FileUtils.copy_file(file, File.join(dest,filename))
end
I haven't heard of cp --parents, but if it does what you want then there is no shame in just using it from your Rakefile, like this:
system("cp --parents #{your} #{args}")
This could be useful:
# copy "files" to "dest" with any sub-folders after "src_root".
def copy_and_preserve files, dest, src_root
files.each {|f|
f.slice! src_root # the files without src_root dir
dest_dir = File.dirname(File.join(dest, f))
FileUtils.mkdir_p dest_dir # make dest dir
FileUtils.cp(File.join(src_root, f), dest_dir, {:verbose => true})
}
end

CruiseControl.net spaces in <cb:define> field splitting path

I'm using the field to define a path within CC.NET, but the path has spaces in it.
I use the definition within a robocopy task. However when I run the robocopy command in cruisecontrol.net, the path C:\my projects is being interpreted as C:\my.
How can I get around this problem?
Thanks.
Assuming you are using preprocessor text constants it should be something like this:
<cb:define path=""C:\my projects"" />
As an alternative you could use quotation when you pass your preprocessor constant to the Robocopy task:
<cb:define path="C:\my projects" />
<!-- ... -->
<sourcecontrol type="robocopy">
<repositoryRoot>"$(path)"</repositoryRoot>
</sourcecontrol>

Resources