Search Results

Search found 6 results on 1 pages for 'saminny'.

Page 1/1 | 1 

  • template files in python

    - by saminny
    I am trying to use python for translating a set of templates to a set of configuration files based on values taken from a main configuration file. However, I am having certain issues. Consider the following example of a template file. file1.cfg.template %(CLIENT1)s %(HOST1)s %(PORT1)d C %(COMPID1)s %(CLIENT2)s %(HOST2)s %(PORT2)d C %(COMPID2)s This file contains an entry for each client. There are hundreds of config files like this and I don't want to have logic for each type of config file. Python should do the replacements and generate config files automatically given a set of global values read from a main xml config file. However, in the above example, if CLIENT2 does not exist, how do I delete that line? I expect Python would generate the config file using the following simple code: os.open("file1.cfg.template").read() & myhash where myhash is hash of all configuration parameters which may not contain CLIENT2 at all. In the case it does not contain CLIENT2, I want that line to disappear from the file. Is it possible to insert some 'IF' block in the file and have python evaluate it? Thanks for your help. Any suggestions most welcome.

    Read the article

  • template files evaluation in python

    - by saminny
    I am trying to use python for translating a set of templates to a set of configuration files based on values taken from a main configuration file. However, I am having certain issues. Consider the following example of a template file. file1.cfg.template %(CLIENT1)s %(HOST1)s %(PORT1)d C %(COMPID1)s %(CLIENT2)s %(HOST2)s %(PORT2)d C %(COMPID2)s This file contains an entry for each client. There are hundreds of config files like this and I don't want to have logic for each type of config file. Python should do the replacements and generate config files automatically given a set of global values read from a main xml config file. However, in the above example, if CLIENT2 does not exist, how do I delete that line? I expect Python would generate the config file using something like this: os.open("file1.cfg.template").read() % myhash where myhash is hash of configuration parameters from the main config file which may not contain CLIENT2 at all. In the case it does not contain CLIENT2, I want that line to disappear from the file. Is it possible to insert some 'IF' block in the file and have python evaluate it? Thanks for your help. Any suggestions most welcome.

    Read the article

  • C++ shared libraries

    - by saminny
    Hi, I am trying to get my head around the way shared libraries work in the c++ unix environment. I understand we only need header files and no shared libraries specification when compiling code. But if I want to create an executable or shared library from my compiled files, do I need to specify shared library dependencies (those are dynamic)? And do the paths of shared libraries need to match the path at runtime loading? I am using Linux 2.6.18-164.11.1.el5 #1 SMP x86_64 GNU/Linux I am having a problem where my code is not able to pick up a library at runtime. I have tried setting LD_LIBRARY_PATH and PATH. But at runtime when I run the executable, I get the following error: Error: librc.so: cannot open shared object file: No such file or directory Sam

    Read the article

  • installing a package with xml based configuration in python

    - by saminny
    Hi, I am planning to write a generic python module for installing a package. This script should retrieve the module from a remote machine or locally and install it on a given host and user. However, there needs to be changes made to the package files based on the host, user and given environment. My approach is to use XML to describe changes to be made to package files based on environment. It will first extract the package to the user directory and then using an xml configuration file, it should replace the file values in the package directory. The xml would look something like this: <package version="1.3.3"> <environment type="prod"> <file dir="d1/d2" name="f1"> <var id="RECV_HOST" value="santo"> <var id="RECV_PORT" value="RECV_PORT_SERVICE" type="service"> <var id="JEPL_SERVICE_NAME" value="val_omgact"> </file> <var dir="d4/d3/s2" name="f2"> <var id="PRECISION" value="true"> <var id="SEND_STATUS_CODE" value="323"> <var id="JEPL_SERVICE_NAME" value="val_omgact"> </file> </environment> <environment type="qa"> <file dir="d1/d2" name="f1"> <var id="RECV_HOST" value="test"> <var id="RECV_PORT" value="1444"> <var id="JEPL_SERVICE_NAME" value="val_tsdd"> </file> <file dir="d4/d3/s2" name="f2"> <var id="PRECISION" value="false"> <var id="SEND_STATUS_CODE" value="323"> <var id="JEPL_SERVICE_NAME" value="val_dsd"> </file> </environment> </package> What are your thoughts on this approach? Is there an existing python module, package or script that I could use for this purpose since this seems fairly generic and can be used for any installation. Thanks! Sam

    Read the article

  • when is a v-table created in C++?

    - by saminny
    When exactly does the compiler create a virtual function table? 1) when the class contains at least one virtual function. OR 2) when the immediate base class contains at least one virtual function. OR 3) when any parent class at any level of the hierarchy contains at least one virtual function. A related question to this: Is it possible to give up dynamic dispatch in a C++ hierarchy? e.g. consider the following example. #include <iostream> using namespace std; class A { public: virtual void f(); }; class B: public A { public: void f(); }; class C: public B { public: void f(); }; Which classes will contain a V-Table? Since B does not declare f() as virtual, does class C get dynamic polymorphism?

    Read the article

  • xml filtering with python

    - by saminny
    Hi, I have a following xml document: <node1> <node2 a1="x1"> ... </node2> <node2 a1="x2"> ... </node2> <node2 a1="x1"> ... </node2> </node1> I want to filter out node2 when a1 = x2. The user provides the xpath and attribute values that need to tested and filtered out. I looked at some solutions in python like BeautifulSoup but they are too complicated and dont preserve the case of text. I want to keep the document same as before with some stuff filtered out. Can you recommend a simple and succinct solution? This should not be too complicated from the looks of it. The actual xml document is not as simple as above but idea is the same.

    Read the article

1