Is there a way to get the location of the Jamroot file, for use as a constant in another Jamfile in the project?
Right now, I have this kludge in my Jamroot:
constant HOME : [ os.environ HOME ] ;
constant MYPROJECT_ROOT : $(HOME)/src/myproject ;
And then later I might do something like this in another Jamfile, to allow me to include headers with paths from the root of the project.
<include>$(MYPROJECT_ROOT)
It's especially unsatisfactory because it means that if I share this project with others, they have to either keep it in exactly the same location relative to their $HOME or they have to update the Jamroot.
I'm interested in the smart way to do this specific include (instead of my ignorant beginner way of using constants). But I'd also be interested in solving the problem the way I asked -- by getting the Jamroot location into a constant -- because this might be useful in other ways too.
Use the path-constant rule.
path-constant MYPROJECT_ROOT : . ;
Then in sub-projects, you can get the directory of the Jamroot with $(MYPROJECT_ROOT).
Note that usually people name this variable TOP instead of MYPROJECT_ROOT, but that's just a convention.
Related
I can't find a way to search for TCPs / search TCP usages / renaming all TCPs.
Let's assume I have a 'licensePlate' TCP set up on the highest level of the hierarchy, and that I have 2 subfolders. In one of them I use the value as it is, in the other folder I change the value. I have some libraries using 'licensePlate'.
I then proceed to rename the TCP to 'carId' on the highest level (and in the libraries). The folder which inherited it will be updated. But the other one will now have two TCPs. This is illustrated in the figure below.
So at the moment I need to manually go into all my subfolders/testcases, find all of them where 'licensePlate' was re-configured, and: (1) set the value to the new param ('carId'); (2) delete the old param ('licensePlate').
The logic behind this imho is that I may still be using that param name (e.g. if I resolved my libraries). Still, I'm guessing that there must be a way to bulk-rename or at least to search for TCP usages (?)
That is really tricky and abstruse. You can find TCP usage with following TQL (Home - Search - TQL Search tab)
=>SUBPARTS[(param_name!="")]
where "param_name" is the name of your parameter.
And it seems that only usages are being found where values has been changed and are not default values.
I'm trying to figure out how to assign a VM to a folder that does not contain a unique name. I'm currently testing with the clone_vm.py template. With the sample, I have the ability to set the folder, but it does not work correctly if there's nested folders with the same name (example below). I would like to make sure the folder assigned is the "Linux/Dev" folder, but I can only pass "Dev" and hope that it picks the right one. The line of code below is how the folder is being set.
destfolder = get_obj(content, [vim.Folder], vm_folder)
Linux
|------Dev
|------Prod
Windows
|------Dev
|------Prod
Thanks!
The best way to do that is to use a search_index.FindByInventoryPath and get the folder by the path. It can be a little confusing because of hidden folders but the MOB can help you. I answered a question where I covered how to use that search method see this answer.
I'm working with python-firebase. I've been trying to access the root folder, but I've been unable to do so with the post and put commands. For example, I need to do:
database.post (root, {"HELLO" : "HELLO"})
but the best I can do is two directories down. Can anyone help?
Check out this post on getting started with Firebase. The example uses a put.
In short, you can simply do:
firebase.put('/test', 'testing/tester/test', putData)
Each / defines another route down. So, in the above example, that is 3 levels down from the root. Just keep adding / the further you want to go.
I have a small requirement to internationalize strings. Honestly the topic itself is so wide. but I only wish to use its ResourceBundle functionality where I only wish to include strings.json files for each language and use $L("some key") in my enyo app. Is it possible with minimum number of individual dependent javascript files ?
This is what I am talking about. Thanks in advance for your efforts.
The enyo-ilib package has 3 "sizes" of ilib in it. By default, you get the "standard" size which has a reasonable set of things that people might need in it like date formatting, number formatting, etc. What you want is the "core" size which includes only the resource bundle class and the string formatter plus all the classes they depend on like the locale class. In order to use the core size of ilib in your enyo app, you would do the following in your package.js file:
enyo.depends({
"$lib/enyo-ilib/core-package.js",
<other libraries>,
...
});
Then, set up a resources directory right beside where your index.html is:
index.html
resources/
de/
strings.json -- strings for German
fr/
strings.json -- strings for French
etc.
Then you should be able to use $L without the memory footprint of the standard size of ilib.
I'm working on a drupal 6 site at mydomain.com/drupalsite, and the designer has put a lot of hardcoded image paths in there, for instance a custom img folder in mydomain.com/drupalsite/img. So a lot of the site uses links to /drupalsite/img/myimg1.png.
Here's the problem -- the site is eventually moving to finaldomain.com, via pointing finaldomain.com to mydomain.com/drupalsite. So now paths like /drupalsite/img/myimg1.png will resolve to finaldomain.com/drupalsite/img/myimg1.png, instead of what should be finaldomain.com/img/myimg1.png. The finaldomain.com site has to point to that subdirectory so it hits the index.php.
My first instinct is to use an .htaccess file to replace the /drupalsite with "", but I've tried about a dozen different solutions and they haven't worked. My hack of a solution was to use some ln -s links but I really don't like it :) tia
Andrew
The best method, in hindsight, is to ensure folks use Drupal functions to make all links:
l (that's the letter L)
drupal_get_path()
base_path()
The l() function takes care of base path worries, and provides a systematic way to define your URL's. Using things like theme_image() plus the l() function are a sure win. Use the second and third functions above if you have to write your own <a> tags and for use inside theme functions like theme_image().
But for your current situation:
As regards Andy's solution, it would be better if you could limit your changes to certain database fields where you know the links are located.
So write a query to select all those fields (e.g. all body fields):
$my_query = db_query("SELECT vid, body FROM {node_revisions}");
This, for example, will get you every body field in the node_revisions table, so even your old revisions would have proper links.
Then run through those results, do str_replace() on each, and then write the changes back:
while($node = db_fetch_object($my_query)) {
$new_body = str_replace('what you have', 'what you want', $node->body);
db_query("UPDATE {node_revisions} SET body = '%s' WHERE vid = %d", $new_body, $node->vid);
}
I'd obviously try it on one record first, to make sure your code behaves as intended (just add a WHERE vid = 5, for example, to narrow it down to one revision). Furthermore, I haven't taken advantage of node_load and node_save, which are better for loading and saving nodes properly, so as to provide a more general solution (for you to replace text in blocks, etc.).
For your files, I'd suggest a good ol' sed command, by running something like the following from within your "sites" folder:
find ./ -type f -exec sed -i ’s/string1/string2/’ {} \;
Nabbed that from here, so take a look on that site for more explanation. If you're going to be working with paths, you'll either need to escape the / of the paths in your version of the sed command, or use a different sed separator (i.e. you can write s#string1#string2# instead of s/string1/string2/, so you could write s#/drupalsite/img/#/img# instead of s/\/drupalsite\/img\//\/img/ :-). See also Drupal handbook page for quick sed commands: http://drupal.org/node/128513.
A bit of a mess, which is why I try to enforce using the proper functions up front. But this is difficult if you want themers to create Drupal content but you don't want to give them access to the "PHP Filter" input format, or they simply don't know PHP. Proper Drupal theming, at any point past basic HTML/CSS work, requires a knowledge of PHP and Drupal's theme-related functions.
I've done this before by taking a full database dump, opening it in a text editor, and doing a global search and replace on the paths. Then on the new host, load the modified dump file, and it will have the correct paths in.
You could try Pathologic, it should be able to correct paths like this.