How to refer to files that were added via the data_files attribute? - py2app

With py2app, say I added several files to my package using this:
DATA_FILES = [
('images', ['images/picture.jpg', 'images/picture2.png']),
('images/icons', ['images/icons/ico1.ico'])
]
and in my original I used to access these files using './images/picture.jpg' for example. How should I refer to them now?
I've tried both using the same path and using ./Contents/Resources//images/picture.jpg but neither work

In general, paths obtained via os.getcwd() refer to ./Contents/Resources/ after running py2app on my machine.
To better understand your exact problem, run the executable file in *.app/Contents/MacOS/, then copy and share the traceback error message that comes up in your Terminal console. Also, try to insert print statements to analyse your paths in Terminal.

Related

No module named 'data'

I get the error No module named 'data' whenever I try to execute the line below
from data import batch_gen, encode
Can anyone help me fix this? I tried looking into other online resources but could not fix this problem.
try the following and then do your import:
pip install data
The line
from data import batch_gen, encode
lets you import only parts of modules and gives you the possibility to reference them directly without writing data.encode
So to get this running you need a module called data in a file, either a file in the same location as your python file or in the installation folder where the other std python files life. otherwise you would always get an error. more information is easily found here:
https://www.digitalocean.com/community/tutorials/how-to-import-modules-in-python-3#using-from-%E2%80%A6-import

Doxygen for Lua

I am trying to get lua2dox running but it's not generating the examples.
What I do is download the zip file and download doxygen 1.8.8. I'll then place the doxygen.exe file into the extracted content od lua2dox and simply call
> doxygen.exe
in my command line. The docs/ directory is getting created but it does not look like the example docs as it is shown e.g. here.
The generated documentation has just the list of files - and that's it.
I've checked the Doxygen file but I can't find anything that seems to be wrong.
What I am not sure about is if lua2dox_filter.bat is actually getting used by doxygen. As I run it, I do not see some output from this script, not even if I add some echo but maybe it's just doxygen itself suppressing it.
Two things: The only modification I had to make was to lua2dox_filter.bat. In order to run Lua it has to prompt lua5.1 instead of just lua as it is in the script.
Also the Doxyfile didn't point to the examples/lua directory so I hat to set it:
INPUT = examples/lua/
Answer: Don't use Doxygen 1.8.8.
I didn't test it with later versions but it worked with Doxygen v1.8.2. Apparently things broke later on for lua2dox.

SP2-0310: unable to open file "dba_files_all.sql"

Please advise. This SQLPlus call:
SQL > #dba_files_all
...is not working.
SP2-0310: unable to open file "dba_files_all.sql"
How can I resolve the error?
You need to provide the path of the file as string.
Put the path in double quotes and it will work.
For example:
#"C:\Users\Arpan Saini\Zions R2\Reports Statements and Notices\Patch\08312017_Patch_16.2.3.17\DB Scripts\snsp.sql";
I encountered this error when attempting to execute a file in the same folder as the calling function. In my example, this process:
Was executed in SQL Developer;
Has been a long-standing part of my system (moving a setup file with some settings and variable names through various folders; those folder names include the feature IDs and a short description);
Has worked fine in the past;
Did not require any pathing in my case because the files were in the same folder;
Failed on the most recent attempt with the error above (SP2-0310).
The issue in my situation was that the folder name in which it failed included a character (#) that was valid for a Windows file name, but confusing to SQL Developer.
1.Use absolute path:
/u01/app/oaracle/test.sql
2.Check the path to see if script exists:
ls -l /u01/app/oaracle/test.sql
Note that
SQL> #some_file.sql
means that sql app you are using will look for that using "absolute path" so if you want to use "relative path" use following format [add ?]
SQL> #?some_file.sql
else, use "full path" with first command.
All the answers so far imply that absolute paths are required. That aren't. Relative paths in sql is pretty universal in sql tools. Sometimes, you have to configure a lost default configuration such as in the case of SQLDeveloper as explained in this answer:
https://stackoverflow.com/a/24003529/442968
I just run into same error when I was trying to unlock oe schema.
While reading the error, I realized that when I run the following line:
>SQL #?/demo/schema/order_entry/oe_main.sql
The error returned a completely different path
SP2-0310: unable to open file "C:/app/USER/product/18.0.0/dbhomeXE/demo/schema/order_entry/oe_main.sql"
Thus I copied my sql file to the path specified by the error and everything worked. I recommend that you do the same. Check the path in the error and adjust accordingly.
Use absolute path or run sqlplus command from a shell/dos that points to the path of the script. Also, to use a masterscript, refer to subscripts with ##.
verify that your file has an extension .sql not .sql.txt

Simple storage not persisting data between sessions

I'm trying to use the simplestorage from my extension, but I can't retrieve values between browser sessions. Here's the thing: From my main code, I created a value this way:
var ss = require("sdk/simple-storage");
ss.storage.foo = [{id:"bar1", properties:{a:"aaa", b:"bbb"}}]
console.log(ss.storage.foo);
This is ok, I coud see the object through the log. But then I closed the browser, commented the "foo definition" (line 2) and the console log was "undefined".
I know cfx run by default uses a fresh profile each time it runs, so simple storage won't persist from one run to the next. But I'm using
cfx -b firefox run --profiledir=$HOME/.mozilla/firefox/nightly.ext-dev
So I'm sure I'm using the same profile everytime.
What could be happening? What am I missing? Any idea is welcome! Thanks in advance!
Thanks to the answer of Notidart, I could discover that the problem was the file is saved when you close Firefox in the right way. When you just kill it through console, it's not persisting data.
This is how simple storage works. It creates a folder in your ProfD folder which is your profile directory: https://github.com/mozilla/addon-sdk/blob/master/lib/sdk/simple-storage.js#L188
let storeFile = Cc["#mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).
get("ProfD", Ci.nsIFile);
storeFile.append(JETPACK_DIR_BASENAME);
storeFile.append(jpSelf.id);
storeFile.append("simple-storage");
file.mkpath(storeFile.path);
storeFile.append("store.json");
return storeFile.path;
The exact location of the file made is in a your profile folder, in a folder named jetpack then your addon id, then a folder called simple-storage, then in a file in that folder called store.json. Example path:
ProfD/jetpack/addon-id/simple-storage/store.json
It then writes data to that file. Every time your profile folder is recreated (due to the nature of temp profile, due to jpm / cfx), your data is erased.
You should just use OS.File to create your own file to save data. OS.File is better way then nsIFile which is what simple-storage does. Save it outside that ProfD folder, so but make sure to remove it on uninstall of your addon otherwise you pollute your users computers
Just in case someone else finds this question while using jpm, note that --profiledir is removed from jpm, so to make jpm run using the same profile directory (and thereby the same simple-storage data), you have to run it with the --profile option pointing at the profile path - not the profile name.
jpm run --profile path/to/profile
For future readers, an alternative to #Noitidart's recommendation of using OS.File, is to use the Low-Level API io/file
You can create a file using fileIO.open(path). If the file doesn't exist, it will be created. You can read and write by including the second argument fileIO.open(path, mode).
The mode can be:
r - Read-only mode
w - Write-only Mode
b - Binary mode
It defaults to r. You can use this to read and write to a file (obviously the file cannot be in the ProfD folder or it will get removed each time jpm / cfx is run)

link analysis using nutch

I am new to nutch. I have crawled some urls using nutch. Now I want to get linkrank of them. I read about it here. The problem is that I can't create webGraphdb. In my crawl directory I have linkdb, segments and crawldb directory. I need it when I run the command
./nutch -webgraph -segment <seg name> -segmentDir <seg dir> webgrapgdb??
I need to give the address of webgraphdb. How should I generate it. My nutch version is 1.7.
The webgraph command is for generating or updating of webgraphs. You can pass anything as the value of webgraphdb argument. If a directory with that name does not exist, nutch will create one for you.

Resources