Xml script: How do we point our own working directory? - linux

<?xml version="1.0" encoding="UTF-8"?>
<attributes>
<attribute name="priority" type="string"/>
<attribute name="hierarchy" type="script"path="$WORK_DIR/pvim2vmgr/python_script/hierarchy.py">
<scriptParam name="subject"/>
<scriptParam name="test_plan"/>
</attribute>
I'm expecting when I set environment cmd in xterm.
setenv WORK_DIR <my_path>
In xml script, it'll recognize my directory ($WORK_DIR).However, it doesn't, is there any cmd for me to implement it?
Purpose of using xml script
I'm using it to obtain information from certain website and generate a csv file. This xml script is running with command line argument.
Reason I want to replace Working directory
When I'm using other person working_dir to generate this xml script, it automatically replace the $WORK_DIR to other person instead of mine.

Related

Trying to create a handler for .maff files in Linux

MAFF files are simply zip files. I'm trying to create a handler for .maff in linux so that when I click on them or type xdg-open x.maff it will call my handler instead of the default which is to open the directory in nautilus. I created an application-x-maff.xml file that contains:
<?xml version="1.0" encoding="UTF-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<mime-type type="application/x-maff">
<comment>maff type</comment>
<magic priority="100">
<match offset="0" type="string" value="PK\x03\x04" />
</magic>
<glob pattern="*.maff"/>
</mime-type>
</mime-info>
and saved in ~/.local/share/mime/packages. Created also a ~/.local/share/applications/maffapplication.desktop that contains
[Desktop Entry]
Type=Application
MimeType=application/x-maff
Name=Maff Handler
Exec=<my home path>/bin/linux/maffHandler
and executed
% update-mime-database ~/.local/share/mime/packages/
% update-desktop-database ~/.local/share/applications
If I do
% gio info x.maff (filtered)
standard::content-type: application/x-maff
standard::fast-content-type: application/x-maff
and if I do
% gio mime application/x-maff
Registered applications:
maffapplication.desktop
Recommended applications:
maffapplication.desktop
everything seems to be right ... but then xdg-open x.maff does not work, still calls nautilus ... worse yet, if I do
% xdg-mime query filetype x.maff
application/zip
I'm sure I'm missing something ... somehow I need to override this association between the .maff file that starts with the same magic as a zip file to no avail ... I tried all kinds of modifications on the xml file, with and without the magic, nothing works
By the way, if I do
% maffHandler x.maff
it works perfectly and opens the maff file in firefox, I'm willing to share the C++ code of that if anyone is interested
Seems that TDE (Trinity Desktop) does not properly set two important environment variables
setenv XDG_CURRENT_DESKTOP KDE
setenv KDE_SESSION_VERSION 5
Once they are set at .login (unfortunately had to log out and login again) xdg- scripts started working properly and recognizing the MIME types. The other problem is that TDE requires that you manually add the association on Control Center -> TDE Components -> File Associations.
After environment variables properly set for my environment and File Associations set, then it all works perfectly. Thanks

Overriding project properties with a custom task

Our C++ project uses MSBuild to build on Windows and GNU make on *nix. I'm trying to recreate the functionality of the following single line of GNU make in MSBuild:
GENN_PATH:=$(abspath $(dir $(shell which genn-buildmodel.sh))../userproject/include)
Essentially setting a variable to a path relative to an executable in the path. However, this is proving to be a battle to implement in MSBuild...
The following are the (hopefully) pertinent sections from my vcxproj. For testing purposes I am first setting the variable I want to override to something obvious:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
<PropertyGroup Label="Configuration">
...
<GeNNUserProject>UNDEFINED</GeNNUserProject>
</PropertyGroup>
Then, in my ClCompile item definitions, I am adding the value of this property to the additional include directories
<ItemDefinitionGroup>
<ClCompile>
...
<AdditionalIncludeDirectories>include;$(GeNNUserProject)</AdditionalIncludeDirectories>
</ClCompile>
...
</ItemDefinitionGroup>
In order to find this path, I'm using the where command and redirecting it's output to a property. Then, from this, I'm finding the include directory and printing it out - this works!
<Target Name="FindUserProjects">
<Exec Command="where genn-buildmodel.bat" ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GeNNBuildModelPath" />
</Exec>
<PropertyGroup>
<GeNNUserProject>$([System.IO.Path]::GetFullPath($([System.IO.Path]::GetDirectoryName($(GeNNBuildModelPath)))\..\userproject\include))</GeNNUserProject>
</PropertyGroup>
<Message Text="MAGIC GENN-FINDING! $(GeNNBuildModelPath) -> $(GeNNUserProject)"/>
</Target>
I've tried a variety of ways of making this a dependency of ClCompile including setting the Target as BeforeTargets="PrepareForBuild" and the following:
<PropertyGroup>
<BeforeClCompileTargets>
FindUserProjects;
$(BeforeClCompileTargets);
</BeforeClCompileTargets>
</PropertyGroup>
</Project>
Whatever I do, my custom target runs but the property is not being overriden. Google suggests that if properties are overriden in depencies they should be visible from targets and from digging into Microsoft.CPP*.targets this is what setting BeforeClCompileTargets is doing.
The problem here was not that the target wasn't setting the property, it's that the AdditionalIncludeDirectories item metadata was being set from the original value. The solution is to set this directly from the target instead:
<ItemGroup>
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$([System.IO.Path]::GetFullPath($([System.IO.Path]::GetDirectoryName($(GeNNBuildModelPath)))\..\userproject\include))</AdditionalIncludeDirectories>
</ClCompile>
</ItemGroup>

Retrieve value from text file and replace a string constant in another file with that value using ant script

I have a file called versionInfo.txt. This file among other things has the following text: "Implementation-Version: 7.5.0.1".
I need to retrieve the version value and copy this version value to a Java file. The Java file will have the following variable:
version = "#version-info#";
I need to replace this #version-info# with the value I retrieved from the first file. I need to do plug in this code in an existing build.xml file written using ant script.
Create a properties file like this and name it build.properties
version.label=7.5.0.1
Then in your build.xml file
<project basedir=".">
<target name="replace-labels">
<property file="${basedir}/build.properties"/>
<replace
file="${basedir}/myClass.java"
token="#version-info#"
value="${version.label}" />
</target>
</project>
So your file structure should look like
myproject
build.properties
build.xml
myClass.java
Then you can execute your ANT build by changing to the "myproject" directory and executing
ant replace-labels
The replace tag will look for the string "#version-info#" in your myClass.java file and replace it with the value "7.5.0.1"
For the second part of your question, retrieve the version info.. :
If you need to read the Implementation-Version from the Manifest of a jar you may use a macrodef, f.e. :
<!-- Grep a keyvalue from Manifest -->
<macrodef name="mfgrep">
<attribute name="jar"/>
<attribute name="key"/>
<attribute name="catch"/>
<sequential>
<loadproperties>
<zipentry zipfile="#{jar}" name="META-INF/MANIFEST.MF"/>
</loadproperties>
<property name="#{catch}" value="${#{key}}"/>
</sequential>
</macrodef>
<mfgrep
jar="/home/rosebud/temp/ant.jar"
key="Implementation-Version"
catch="foobar"
/>
<echo>$${foobar} => ${foobar}</echo>

unused node detected: ccnet 1.6.7981.1 [duplicate]

This question already has answers here:
Configuration does not have any version information - assuming the configuration is for version 1.5
(2 answers)
Closed 2 years ago.
i try to configure ccnet using this link tag as below
ccnet.config
<?xml version="1.0" encoding="utf-8"?>
<cruisecontrol xmlns:cb="urn:ccnet.config.builder" xmlns="http://thoughtworks.org/ccnet/1/6">
<!--# Genel Tanimlamalar -->
<cb:include href="definitions.config" xmlns:cb="urn:ccnet.config.builder"/>
<!--# Project1.config -->
<cb:include href="C:\buildBase\builds\Project1\Project1.config" xmlns:cb="urn:ccnet.config.builder"/>
</cruisecontrol>
definitions.config
<?xml version="1.0" encoding="utf-8"?>
<cb:config-template xmlns:cb="urn:ccnet.config.builder">
<cb:define name= "project-definition-block">
<workingDirectory>C:\builBase\builds\$(project)</workingDirectory>
<artifactDirectory>C:\builBase\builds\$(project)\artifact</artifactDirectory>
<category>$(category)</category>
<webURL>http://ccnet.gp.tr:81/server/ViewLatestBuildReport.aspx</webURL>
<modificationDelaySeconds>2</modificationDelaySeconds>
<maxSourceControlRetries>5</maxSourceControlRetries>
<initialState>Started</initialState>
<startupMode>UseInitialState</startupMode>
<description>$(description)</description>
<askForForceBuildReason>Required</askForForceBuildReason>
<sourceControlErrorHandling>ReportOnRetryAmount</sourceControlErrorHandling>
<state type="state" directory="C:\builBase\builds\$(project)\state" />
</cb:define>
.
.
.
.
<cb:define name="labeller-block">
<labeller type="assemblyVersionLabeller">
<major>0</major>
<minor>1</minor>
<incrementOnFailure>false</incrementOnFailure>
</labeller>
</cb:define>
</cb:config-template>
Project1.config
<?xml version="1.0" encoding="utf-8"?>
<cb:config-template xmlns:cb="urn:ccnet.config.builder">
<cb:scope xmlns:cb="urn:ccnet.config.builder"
svn-folder="xxxxx"
project="XYZ"
build-args="/p:Configuration=Debug"
build-targets="Clean;Test"
triggerInSeconds = "60"
category = "X"
description= "XYZ Programi">
<project name ="$(project)" queue="Q1" queuePriority="1">
<cb:project-definition-block/>
<cb:svn-block/>
<cb:labeller-block/>
<cb:loggers-block/>
<tasks>
<cb:msbuild-35-block/>
</tasks>
<publishers>
<cb:merge-block/>
<cb:stats-block/>
<cb:loggers-block/>
</publishers>
</project>
</cb:scope>
i am getting
ccnet.log
2011-07-29 15:24:46,109 [1:DEBUG] The trace level is currently set to debug. This will cause CCNet to log at the most verbose level, which is useful for setting up or debugging the server. Once your server is running smoothly, we recommend changing this setting in C:\tools\ci\ccent\server\ccnet.exe.Config to a lower level.
2011-07-29 15:24:46,140 [1:WARN] ! ! Tracing is enabled ! !It allows you to sent the developpers of CCNet very detailed information of the program flow. This setting should only be enabled if you want to report a bug with the extra information. When bug reporting is done, it is advised to set the trace setting off. Adjust the setting in C:\tools\ci\ccent\server\ccnet.exe.Config
2011-07-29 15:24:46,140 [1:DEBUG] [FileChangedWatcher] Add config file 'ccnet.config' to file change watcher collection.
2011-07-29 15:24:46,156 [CCNet Server:INFO] Reading configuration file "C:\tools\ci\ccent\server\ccnet.config"
2011-07-29 15:24:46,515 [CCNet Server:DEBUG] [FileChangedWatcher] Add config file 'C:\tools\ci\ccent\server\ccnet.config' to file change watcher collection.
2011-07-29 15:24:46,515 [CCNet Server:DEBUG] [FileChangedWatcher] Add config file 'C:\tools\ci\ccent\server\definitions.config' to file change watcher collection.
2011-07-29 15:24:46,515 [CCNet Server:DEBUG] [FileChangedWatcher] Add config file 'C:\buildBase\builds\Project1\Project1.config' to file change watcher collection.
2011-07-29 15:24:46,734 [CCNet Server:DEBUG] MergeFilesTask: Add 'C:\builBase\builds\Project1\reports\*.Test.xml' to 'Merge' file list.
2011-07-29 15:24:46,734 [CCNet Server:DEBUG] MergeFilesTask: Add 'C:\builBase\builds\Project1\reports\*.CoverageMerge.xml' to 'Merge' file list.
2011-07-29 15:24:46,734 [CCNet Server:DEBUG] MergeFilesTask: Add 'C:\builBase\builds\Project1\reports\*.CoverageSummary.xml' to 'Merge' file list.
2011-07-29 15:24:46,734 [CCNet Server:DEBUG] MergeFilesTask: Add 'C:\builBase\builds\Project1\reports\*.FxCop.xml' to 'Merge' file list.
2011-07-29 15:24:47,046 [CCNet Server:ERROR] Exception: Unused node detected: xmlns:cb="urn:ccnet.config.builder"
----------
ThoughtWorks.CruiseControl.Core.Config.ConfigurationException: Unused node detected: xmlns:cb="urn:ccnet.config.builder"
at ThoughtWorks.CruiseControl.Core.Config.NetReflectorConfigurationReader.DefaultErrorProcesser.ProcessError(String message)
at ThoughtWorks.CruiseControl.Core.Config.NetReflectorConfigurationReader.<>c__DisplayClass1.<Read>b__0(InvalidNodeEventArgs args)
at Exortech.NetReflector.InvalidNodeEventHandler.Invoke(InvalidNodeEventArgs args)
at Exortech.NetReflector.NetReflectorTypeTable.OnInvalidNode(InvalidNodeEventArgs args)
at Exortech.NetReflector.XmlTypeSerialiser.HandleUnusedNode(NetReflectorTypeTable table, XmlNode orphan)
at Exortech.NetReflector.XmlTypeSerialiser.ReadMembers(XmlNode node, Object instance, NetReflectorTypeTable table)
at Exortech.NetReflector.XmlTypeSerialiser.Read(XmlNode node, NetReflectorTypeTable table)
at Exortech.NetReflector.NetReflectorReader.Read(XmlNode node)
at ThoughtWorks.CruiseControl.Core.Config.NetReflectorConfigurationReader.Read(XmlDocument document, IConfigurationErrorProcesser errorProcesser)
at ThoughtWorks.CruiseControl.Core.Config.DefaultConfigurationFileLoader.Load(FileInfo configFile)
at ThoughtWorks.CruiseControl.Core.Config.FileConfigurationService.Load()
at ThoughtWorks.CruiseControl.Core.Config.FileWatcherConfigurationService.Load()
at ThoughtWorks.CruiseControl.Core.Config.CachingConfigurationService.Load()
at ThoughtWorks.CruiseControl.Core.CruiseServer..ctor(IConfigurationService configurationService, IProjectIntegratorListFactory projectIntegratorListFactory, IProjectSerializer projectSerializer, IProjectStateManager stateManager, IFileSystem fileSystem, IExecutionEnvironment executionEnvironment, List`1 extensionList)
at ThoughtWorks.CruiseControl.Core.CruiseServerFactory.CreateLocal(String configFile)
at ThoughtWorks.CruiseControl.Core.CruiseServerFactory.Create(Boolean remote, String configFile)
at ThoughtWorks.CruiseControl.Core.ConsoleRunner.LaunchServer()
at ThoughtWorks.CruiseControl.Console.AppRunner.Run(String[] args, Boolean usesShadowCopying)
i almost tried everything, spent time for googling, what can be the problem? Which one is the node unused.. ?
Thanks in advance
Unused-node-detected-Exceptions often point to a malformed configuration.
First guess: The publisher block in Project1.config is missing its closing tag. Perhaps this is the cause?

How to search for files containing a particular text string?

How to search for files containing a particular text string using MSBuild?
Thanks guys! I appreciate all of your quick replies!
I've try Grep but I need to read the xml file to see the result.
I've just found out that we can use the task FilterByContent in MSBuild Extension Pack which gives us a direct result in properties & items. I'd like to share it back to you in case you may need it. An example of usage is as below:
<Target Name="ttt">
<ItemGroup>
<files Include="d:\temp\test\**" />
</ItemGroup>
<MSBuild.ExtensionPack.FileSystem.File TaskAction="FilterByContent" RegexPattern="abbcc" Files="#(files)" >
<Output TaskParameter="IncludedFileCount" PropertyName="out"/>
</MSBuild.ExtensionPack.FileSystem.File>
<Message Text="ttt:$(out)" />
</Target>
Nam.
You can find a "grep" task in the MSBuild Contrib project on CodePlex. Haven't used it myself though.
It's not clear whether you want to search of the text in the name or in the file itself.
If you simply want a list of files that their name match particular (simple) criteria I would suggest using the ItemGroup like this:
The Grep taks from the MSBuild Contrib project would look like this
<PropertyGroup>
<MSBuildContribCommonTasksAssembly>$(MSBuildExtensionsPath)\MSBuildContrib\MSBuildContrib.Tasks.dll</MSBuildContribCommonTasksAssembly>
</PropertyGroup>
<UsingTask TaskName="MSBuildContrib.Tasks.Grep" AssemblyFile="$(MSBuildContribCommonTasksAssembly)" Condition="Exists('$(MSBuildContribCommonTasksAssembly)')" />
<ItemGroup>
<FilesToSearch Include="**\*.cs" />
</ItemGroup>
<!-- very simple search -->
<Grep InputFiles="#(FilesToSearch )" OutputFile="out.xml" Pattern="Error" />
<!-- slightly more complicated search (search and extract info) -->
<Grep InputFiles="#(FilesToSearch )"
OutputFile="out.xml"
Pattern="// (?'Type'TODO|UNDONE|HACK): (\[(?'Author'\w*),(?'Date'.*)\])? (?'Text'[^\n\r]*)" />
The Grep task will generate the out.xml file that can subsequently be used to read information from it and use in the build process.

Resources