ImageJ Macro and Plugin Paths - imagej

I'm using ImageJ on MacOS X. Currently the ImageJ properties utility is reporting the Macros and Utilities directories as "null"
IJ.getDir("plugins"): null
IJ.getDir("macros"): null
I can set the directories using the following command from the command line.
java -Xmx1024m -jar /Applications/ImageJ/ImageJ.app/Contents/Resources/Java/ij.jar -ijpath /Applications/ImageJ
How does one set the ijpath when double clicking the ImageJ application (imagej.app)?

ImageJ is designed to look (every time it runs) for the plugins directory in the same folder where ImageJ.app is located. If you want to override that, you can use the command as you have found, or you can edit the Info.plist file that is inside the ImageJ.app folder.
Right-click on ImageJ.app and select Show Package Contents.
Open Info.plist (if you have Xcode it will be the default to open that file) and append to the Java->VMOptions line the location of the plugins folder you want to use, for example:
VMOption -Xms256m -Xmx3000m -Dplugins.dir=/Users/me/myplugins
If the directory you specify doesn't exist, it just reverts to the default of looking where ImageJ.app is.
For more info see: imagej.net and plugin-dirs

Related

How compile uic with PySide6

I want to compile uic to PySide6 but I don't find how to install pyside6-uic tool. Where can I install pyside6-uic? I downloaded PySide6 but command pyside6-uic doesn't work.
There is a reference here in the title:
https://doc.qt.io/qtforpython/tutorials/basictutorial/uifiles.html#using-ui-files-from-designer-or-qtcreator-with-quiloader-and-pyside6-uic
Step 1. If you installed PySide6
a. In a venv then go to your venv's folder.
b. Globally then go to your python installation folder.
Step 2. Go to Lib then site-packages then PySide6.
Step 3. Copy uic.exe ( or uic if the file extension are hidden) create a folder called bin and paste what you've copied inside it.
To compile ui files from:
QtDesigner: From the top menu select Form -> View Python Code... then click on the save icon (floppy disk) from the newly opened window.
Command Prompt: pyside6-uic.exe mainwindow.ui > ui_mainwindow.py
PowerShell: pyside6-uic.exe mainwindow.ui -o ui_mainwindow.py
If you using virtual environment, when you install pyside6 with pip in the virtual environment there is a folder named Scripts there is the pyside6-uic.exe tool.
if you have install pyside6 globally in your system and you use visual studio code you can use the extension PySide2-vsc then when you installed you can go to preferences > settings and search the PySide2-vsc extension settings then look for the "Command to compile a .ui file into python". Then you can use that feature with right-click on .ui files.
I could solve this issue to add this Path to my %PATH% Variable on windows.
C:\Users\<YOUR_USER_PATH_NAME>\AppData\Roaming\Python\Python311\Scripts
The pyside6-uic tool is supposed to be installed automatically when installing the Python package.
Check if uic is in PATH
When using loadUiType, the Qt documentation (here) states that :
The internal process relies on uic being in the PATH. The pyside6-uic
wrapper uses a shipped uic that is located in the
site-packages/PySide6/uic, so PATH needs to be updated to use that if
there is no uic in the system.
But even then, I got the following error :
Cannot run 'pyside6-uic': "execvp: No such file or directory" -
Exit status QProcess::NormalExit ( 255 )
Check if 'pyside6-uic' is in PATH
For me, pyside6-uic was not located in site-packages/PySide6/uic. When reinstalling the module with pip, I noticed this message :
WARNING: The scripts pyside6-assistant, pyside6-designer, pyside6-genpyi,
pyside6-linguist, pyside6-lrelease, pyside6-lupdate, pyside6-rcc and pyside6-uic are
installed in '/Users/<user>/Library/Python/3.8/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning,
use --no-warn-script-location.
So make sure to add the right directory to your $PATH variable.
Once it's done, you will be able to use the pyside6-uic command to generate a Python class from a UI file :
pyside6-uic mainwindow.ui > ui_mainwindow.py
Loading a .ui from code
You can also load a .ui file from your code using either:
loadUiType (doc page) :
This function generates and loads a .ui file at runtime, and it
returns a tuple containing the reference to the Python class, and the
base class.
or QUiLoader (doc page):
enables standalone applications to dynamically create user interfaces
at run-time using the information stored in UI files or specified in
plugin paths
from PySide6.QtUiTools import QUiLoader
ui_file = QFile("mainwindow.ui")
ui_file.open(QFile.ReadOnly)
loader = QUiLoader()
window = loader.load(ui_file)
window.show()
Generally speaking, use absolute paths to access your UI files. Relative paths are susceptible to errors.

Using Atom with Hydrogen. The working directory for Atom is one folder up from the current file's location. How do i change it to the current folder?

In both Hydrogen and using a plug-in terminal platform, the default directory is one folder up from where my code file resides.
E.g., I’ll be working on a file with path, say, parent/code/file.py. When I run pwd in the plug-in's terminal or the equivalent via Hydrogen in the python script I get parent/, but I need it to be parent/code/ to import files etc.
Perhaps the default directory for Atom is the project that is folder of the project that is open?
Any ideas how to change the default current directory for Atom (or is it package specific) to the file i’m working on/executing in Hydrogen?
In the hydrogen settings you can choose the location where the kernel should be started.
The default is the 'First started project's directory'. You can choose 'Current directory of the file' there, which should give you what you want.

Change fortify .NST file Generation Location

Currently, the .NST files after build are getting generated at "C:\Users\XYZ\AppData\Local\Fortify\sca6.2\build" folder. How can I change the it to some other folder in my system?
There are two files that need to be updated, located in the /Core/config:
fortify.properties
com.fortify.WorkingDirectory=${win32.LocalAppdata}/Fortify
fortify-sca.properties
com.fortify.sca.ProjectRoot=${win32.LocalAppdata}/Fortify
If you are also using the Eclipse plugin, make sure to change the files inside of there as well:
\plugins\com.fortify.dev.ide.eclipse_X.XX.X\Core\config\fortify.properties"
Make sure that fortify will have permissions to read/write to the new target location. Depending on how locked down your environment is (permissions, GPs) this could be tricky.
Update:
If you wanted to change a setting for once scan and/or cannot update the properties files, you can update the properties through commandline arguments.
You would need to pass these arguments on all commands to sourceanalyzer to work (clean, translate, and scan).
For any propertie that needs to change, you pass the following in the command:
-D<property>=<value>
In this case (assuming you want to put the working directory D:\Samples\eightball\working Directory):
-Dcom.fortify.sca.ProjectRoot="D:\Samples\eightball\working Directory"
Here is the batch file I used to scan the EightBall.java example file (normally located at <fortify Install Dir>\Samples\Basic\EightBall\ and moved it to D:\Samples\EightBall\
# Clean
sourceanalyzer -b eightball -Dcom.fortify.WorkingDirectory="D:\Samples\eightball\working Directory" -Dcom.fortify.sca.ProjectRoot="D:\Samples\eightball\working Directory" -clean
# Translate
sourceanalyzer -b eightball -Dcom.fortify.WorkingDirectory="D:\Samples\eightball\working Directory" -Dcom.fortify.sca.ProjectRoot="D:\Samples\eightball\working Directory" -source 1.5 EightBall.java
# Scan
sourceanalyzer -b eightball -Dcom.fortify.WorkingDirectory="D:\Samples\eightball\working Directory" -Dcom.fortify.sca.ProjectRoot="D:\Samples\eightball\working Directory" -scan -f EightBall.fpr

Xcode .bundle and .dylib

Is there a way to combine .bundle and .dylib into one file. I have written a tweak and a preference bundle for it. How do I have them to be installed as one?
you have to pack all the tweak files in a DEB package
for example create a directory named Tweak
and inside it create another directory named DEBIAN in debian directory create a text file called control
inside control
Package: com.example.tweak
Name: Tweak
Version: 1.0
Architecture: iphoneos-arm
Author: Sull <email#email.com>
Depiction: http://yourdepiction.com/example
Description: Example description here.
Homepage: http://example.com
Maintainer: Sull <email#email.com>
Section: Tweaks
*When done editing your control file, go to the end of the last line and press the enter/return key, now save the file. You always have to go to the last line and press enter or you'll run into errors when building.
as you said you have a Preferences bundle and a Dylib so the Tweak directory should look like this
/Tweak
----/DEBIAN
--------/control
----/Library
--------/MobileSubsttrate
------------/DynamicLibraries
----------------/tweak.dylib
----------------/tweak.plist
--------/PreferenceLoader
------------/Preferences
----------------/tweakPref.plist
--------/PreferenceBundles
------------/tweakPref.bundle
now run the command dpkg -b /Tweak in terminal
Assuming the Tweak folder is in root
You can ignore these warnings they are completely normal.
warning, Tweak/DEBIAN/control' contains user-defined fieldName'
warning, Tweak/DEBIAN/control' contains user-defined fieldAuthor'
warning, Tweak/DEBIAN/control' contains user-defined fieldSponsor'
dpkg-deb: ignoring 3 warnings about the control file(s)
there will be a file named Tweak.deb you can install it to the iPhone via terminal or apps like iFile

Adding a new build rule to parse all rtf files

Xcode includes a flexible build rules system. The documentation is all but non-existant however.
A project I am working on for iOS 5 and iOS 6 includes an rtf help file. For iOS 6, I can convert the rtf file into an archived NSAttributedString object, then load that at runtimeand display it directly to a UITextView. For iOS 5, I can't (without a lot of work in Core Text...) so I want just the text without the style info.
I wrote a command line tool, RTFToData that takes an RTF file as input and generates a .txt file and a .data file (where the .data file contains a version of the styled text that my project knows how to use.)
Here is the syntax of my command line tool:
RTFToData [-o] source_path [destination_path]
-o (optional) overwite existing files
source_path (required) path to source RTF file (must have extension "rtf" or "RTF"
destination_directory (optional.) writes output files to source file directory if no destination specified
destination_directory must exist if specified.
I want to set up my project so that I can add .rtf files as sources (with the "add to target" checkbox NOT checked.) I want Xcode to run my RTFToData command on each file specifying that the output files should be copied into a directory and then added to the target.
Ideally, I'd like the build process to know about the dependencies between my source .rtf files and the processed .data and .txt files. If I touch a .rtf file, I'd like the build process to re-run the rtftodata command.
I am a makefile and unix scripting neophyte. I THINK I can use a run script build rule that will do this, but I am unclear on how. I guess I need to write a script that finds all files of type ".rtf", pipes that list of files into an invocation of my RTFToData.
Can somebody outline the steps I need to take in the Xcode IDE to make my project handle this smoothly?
As a side-note, is there some directory where you can put command line tools so they are available to the current version of Xcode? So far I've been installing the RTFToData command in /Library/usr/bin, but I'd really like the build tool to be included in the project, or at the very least, not have to use sudo to set up every development machine that is used to build this project.
Create a custom build phase
Add the .rtf files to your project and make sure they are added to your target.
Go to your target settings and select the "Build Rules" tab:
Click the "Add Build Rule" button at the bottom.
You want to configure your rule based on something like this:
Enter a standard wildcard glob for the files you want to match (*.rtf).
Inside the script section you can make use of a number of environment variables. Assuming your glob has matched the input file Test.rtf you have access to these vars:
INPUT_FILE_PATH = /path/to/your/project/source/Test.rtf
INPUT_FILE_NAME = Test.rtf
INPUT_FILE_BASE = Test
INPUT_FILE_SUFFIX = .rtf
INPUT_FILE_DIR = /path/to/your/project/source/
You want to process your file and send it to the ${DERIVED_FILES_DIR} directory with whatever new filename or extension you need. In this case we take the base filename from the input and give it a new extension.
Fill out the "Output Files" section with the same output file you used in the script. This will ensure the dependency system works and that the file will be copied to your .app. The script will only be run if the input has changed or the output file is missing from the .app.
Note that the "Output Files" should not have double quotes. The paths will be quoted for you by Xcode.
If your script generates multiple output files, add extra entries for those as well.
Once this is all set up, .rtf files added to your target will be converted to whatever output files your script generates. The original .rtf files will not exist in the final .app.
Where to put scripts/programs
As a side-note, is there some directory where you can put command line
tools so they are available to the current version of Xcode?
Put your tools somewhere below the directory that contains your .xcproject. Then from your build phase/rules use the ${SRCROOT} environment variable, which is the directory containing your project:
Assuming this file system layout:
/path/to/project/project.xcodeproj
/path/to/project/Tools/CommandLineTool
Use this in your build phase/rules:
"${SRCROOT}/Tools/CommandLineTool" "${INPUT_FILE_PATH}" ...
Remember to use double-quotes everywhere you can!

Resources