Using the Xcode iOS Instruments UI Automation tuneup.js javascript library https://github.com/alexvollmer/tuneup_js .
I'm having challenges understanding the current working diretory of my launched instrument.
I have not been able to make a relative path to the tuneup/tuneup.js script. The destination of the relative path is of course "tuneup/tuneup.js". But what is the starting point?
Here's the code:
// This works:
#import "/Users/mikes/Documents/Full/Path/To/File/Tests/tuneup/tuneup.js"
// These do not work:
//#import "tuneup/tuneup.js"
//#import "Tests/tuneup/tuneup.js"
//
// See https://github.com/alexvollmer/tuneup_js
//
test("First Screen", function(target, app) {
var window = app.mainWindow();
window.logElementTree();
});
See tuneup.js reports "Can't find variable" for test() method for a related question.
-Thanks
-Mike
I'm willing to bet that the reason this isn't working is because you created an embedded script in the Instruments document. Instead of choosing "Add > Create Script" in the sidebar of instruments, you need to choose "Add > Import" and import your script file from the file system. That will link the Instruments document to your script file and when you use the #import keyword, it will look in the directory relative to where your script file resides.
Embedded (as opposed to imported) scripts do not have a "current directory" which is why you need to absolute path to the tuneup.js file.
Related
In Steam, we can configure multiple directories/folders where it will look for applications. It is found in the menu Steam->Settings->Downloads->STEAM LIBRARY FOLDERS dialog.
Where can I find those settings if I'm looking programatically from outside Steam?
I'm more interested in the location for the Windows client.
Found it. On Windows they are stored in C:\Program Files (x86)\Steam\SteamApps\libraryfolders.vdf, and you also have to add Steam's install folder C:\Program Files (x86)\Steam
Here's a sample Python script to extract the information:
import re
with open(r"C:\Program Files (x86)\Steam\SteamApps\libraryfolders.vdf") as f:
folders = [r"C:\Program Files (x86)\Steam"]
lf = f.read()
folders.extend([fn.replace("\\\\", "\\") for fn in
re.findall('^\s*"\d*"\s*"([^"]*)"', lf, re.MULTILINE)])
I found it here:
C:\Program Files (x86)\Steam\config\config.vdf
There's a line in that file:
"BaseInstallFolder_1" "{YourSteamLibraryFolder}"
So I just open it with Notepad then Ctrl+F search 'Base'.
If that line is not in there:
Open Steam. > Sign into you account. > 'Steam'. > 'Settings'.
Then click on 'Downloads'. > 'STEAM LIBRARY FOLDERS'.
Make an empty folder somewhere.
Click on 'ADD LIBRARY FOLDER'.
Browse to the empty folder you made. > Click on 'SELECT'.
If you then look at the config.vdf again; there should be a line like this:
"BaseInstallFolder_1" "{YourNewEmptySteamLibraryFolder}"
If Steam hasn't been installed in the default location in Windows, you can find it in the registry under HKEY_LOCAL_MACHINE, on path SOFTWARE\Wow6432Node\Valve\Steam. Here's how I found it in Kotlin:
private val steamFolder: File = File(WinRegistry.getString(
WinRegistry.HKEY_LOCAL_MACHINE,
"SOFTWARE\\Wow6432Node\\Valve\\Steam",
"InstallPath"))
You can then find the libraryfolders.vdf and config.vdf files, as per the other answers.
In each of those library folders you'll find files called appmanifest_<id>.acf, where <id> is the id of the game (find it in Properties / Updates on Steam). If you're looking for a particular game, that will help to determine which folder the game is in, if there's more than one game install location.
Original design :
Setting in property :
When the program is running :
All the image inside the project folder "QuickRecorder/Images/MainWindow".
How to solve this problem?
Thank you for your help.
In cases like this the reason almost always is: You use relative path to the image, and the working directory is different when you run the application, and image is not found by the relative path.
To debug, add this to your main to print current working directory:
qDebug() << QDir::currentPath();
A few solutions:
Use absolute paths (preferably so that you construct them at runtime, for example using QCoreApplication::applicationDirPath(), instead of hard-coding).
Put images to Qt resources, so they are embedded to the executable.
Change working directory after application starts (might have unintended consequences if you for example launch child processes, or with file open/save dialogs).
Untested, moved from comment to answer: To automatically copy files from the source dir to the build dir, you could add a build step "Custom Process Step" in the Qt Creator project settings. The command you might want to use for the case of this question might be (again, untested):
cp -rv %{sourceDir}/QuickRecorder %{buildDir}
I am trying to include a file in my resource bundle the files contains the following:
LeadPunc="({[`'
TrailPunc=}:;-]!?`,.)"'
NumLeadPunc=#({[#$
NumTrailPunc=}):;].,%
Operators=*+-/.:,()[]
Digits=0123456789
Alphas=abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
*extra line*
The files is called:
eng.cube.lm
The error I get is:
IExpenseReporter/tessdata/eng.cube.lm:6: premature EOF
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lex failed with exit code 1
This file goes along with the newest version of tesseract (OCR). Does anyone have an idea what is causing this error and how to fix it?
Make sure you select the "Create folder references" option when adding the tessdata folder to your project.
From the documentation:
NOTE: This library currently requires the tessdata folder to be linked
as a referenced folder instead of a symbolic group. If Tesseract can't
find a language file in your own project, it's probably because you
created the tessdata folder as a symbolic group instead of a
referenced folder. It should look like this if you did it correctly:
Note how the tessdata folder has a blue icon, indicating it was
imported as a referenced folder instead of a symbolic group.
Trashing the current folder and adding it again as a folder reference should solve the problem.
XCode "thinks" this is a lex file and try to process it by calling lex. However, lex finds and unbalanced quote and thus a premature end of file.
You should try to call the designated tool explicitly.
I had this issue and I found that copying the folder "tessdata" from the language zip into the project directory rather then into Xcode fixed the issue.
I develop Firefox extension with bundled executable file which should be run on browser startup.
To run process I need get nsIFile or nsILocalFile instance which points to executable file.
I know one solution how to get it using directory service:
var file = Components.classes["#mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIProperties).get("ProfD", Components.interfaces.nsIFile);
file.append("extensions");
file.append("<extension id>");
file.append("<relative path>");
But this solution has two disadvantages:
It doesn't work in development mode, when instead of installed extension I have only text file with real extension path
I'm not sure that it will work on all Firefox configurations because of hardcoded "extensions" part of the path
So is there any nicer way to run executable file which comes with Firefox extension?
Thanks.
You are making way too many assumptions about the directory structure of the Firefox profile - don't. The Add-on Manager API lets you get the path of a file inside the extension, you should use it:
Components.utils.import("resource://gre/modules/AddonManager.jsm");
AddonManager.getAddonByID("<extension id>", function(addon)
{
var uri = addon.getResourceURI("<relative path>");
var file = uri.QueryInterface(Components.interfaces.nsIFileURL).file;
...
});
A restartless addon's startup function (in the bootstrap.js file) will receive, as its first parameter, the path where the addon is installed. You can then play various tricks to read files inside the .jar file, if any: see https://github.com/protz/GMail-Conversation-View/blob/master/bootstrap.js#L55 as an example.
In a non-restartless case, I must confess I don't have much of an idea :).
I found this thread looking for a way to reference a path to an image hosted in extension's directory from a content script. Here's a solution:
Include your files in web_accessible_resources in the extension's manifest.
"web_accessible_resources": [
"images/*"
]
Absolute paths to these resources contain randomly generated UUID, therefore we're using runtime.getUrl() giving it the path relative to manifest.json. Example:
let myImg = document.createElement('img');
myImg.src = browser.runtime.getURL("images/my-img.png")
I'm having a little trouble making my app bundle work from the terminal or just double clicking it.
This App actually compiles, links and runs perfectly within the Qt Creator IDE. But, if I try to open it from the terminal I get a "media/file.x file not found" error. The App bundle nor the /Contents/MacOS/executable is finding the "media" folder that is supposed to be beside the executable.
In my app I do something like:
openFile("media/file.x");
In Windows and Linux, this file WILL be found if the "media" folder is exactly in the same hierarchical position of the executable (beside it). On the Mac I have discovered it works differently cause Qt Creator builds an "App Bundle" and the actual executable is inside the /Contents/MacOS folder, so I copied the "media" manually there. This worked without any hassle when "playing" my app from the Qt Creator but as mentioned before it doesn't work when running the bundle itself.
So does anyone know where or how can I homogenize the look for this "media" folder so it works on both: Qt Creator and the App bundle?
Lately, I have been using the following command to "install" the folder on the bundle.
mac {
MediaFiles.files = media
MediaFiles.path = Contents/MacOS
QMAKE_BUNDLE_DATA += MediaFiles
}
Thanks for your help.
After looking for a few days I found a couple of posts discussing the relative path problem. I was just not searching with the right words... The answer is displayed in:
Relative Paths Not Working in Xcode C++
http://www.experimentgarden.com/2009/06/how-to-load-resource-from-your.html
Basically it is necessary to add this:
//On the include part
#ifdef __APPLE__
#include "CoreFoundation/CoreFoundation.h"
#endif
// On the main of your app
// This makes relative paths work in C++ in Xcode by changing directory to the Resources folder inside the .app bundle
#ifdef __APPLE__
CFBundleRef mainBundle = CFBundleGetMainBundle();
CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(mainBundle);
char path[PATH_MAX];
if (!CFURLGetFileSystemRepresentation(resourcesURL, TRUE, (UInt8 *)path, PATH_MAX))
{
// error!
}
CFRelease(resourcesURL);
chdir(path);
std::cout << "Current Path: " << path << std::endl;
#endif
// ----------------------------------------------------------------------------
IMPORTANT:
The chdir, changes the working path of the app, so it is not necessary to change you relative code after that...