QProcess not accepting arguments in MacOS - qprocess

Running Qt5.10 on MacOS 10.13.2
I am trying to open photoshop with one or more selected images in MacOS. In terminal this works:
open "/Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg" -a "Adobe Photoshop CS6"
The following works in Windows but not MacOS:
QString app = "\"/Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app\""; // diff file path for windows
QStringList arguments;
arguments << "/Users/roryhill/Pictures/4K/2017-01-25_0030-Edit.jpg";
QProcess *process = new QProcess();
process->start(app, arguments);
In MacOS I get the error: "FailedToStart".
If I drop the arguments in the last line and use:
process->start(app);
then photoshop opens.
I have also tried using the executable inside the app container:
"/Applications/Adobe Photoshop CS6/Adobe Photoshop CS6.app/Contents/MacOS/Adobe Photoshop CS6"
Again this works to open photoshop but fails when arguments are added.
This also fails:
process->setArguments(arguments);
process->setProgram(app);
process->start();
Omitting setArguments() fails too:
process->setProgram(app);
process->start();

Related

Flutter Web Test: Set the window size for chrome using flutter drive for integration test

So I have a project, with some integration testing for flutter web. I want to run these tests inside GitHub Actions. For that, I need to change the window size of chrome while testing, as in the default dimensions, some widgets are overflowing, therefore, getting out of the screen, making them non-interactable. I want to run the browser in 1920x1080 resolution. Currently, I am using the following steps to run it:
chromedriver --port=4444 &
sudo /usr/bin/Xvfb -ac $DISPLAY -screen 0 1920x1080x24 > /dev/null 2>&1 & # optional
I have already updated the resolution from xvfb, but it did nothing. I also tried adding the following code in the test file itself.
const size = Size(1920, 1080);
await tester.binding.setSurfaceSize(size);
tester.binding.window.physicalSizeTestValue = size;
But these also did not update the screen size.
For running the tests I am using flutter drive command, like this:
flutter drive --driver=test_driver/integration_test.dart --target=integration_test/test.dart -d chrome --web-renderer=html --headless

Build Unity Server under ubuntu via command line

I created a very simple Unity Server, which uses a simple script (taken from here).
I tried to build it through the ubuntu bash with the following command:
~/Unity/Hub/Editor/2019.4.30f1/Editor/Unity -batchmode -nographics -logfile stdout.log -projectPath /path/to/the/project -buildLinux64Player /project/build/destination -quit
And it worked! It's able to create a working build. The problem is that the 3D windows is displayed as well. I don't want to interact with any game object.
Is there a way to create or run the executable without GUI?
As you can see I used "batchmode" and "nographics" flags which were supposed to prevent the user interface to appear.
Which sort of mistake I have done?
Thanks for your time.
As you can see I used "batchmode" and "nographics" flags which were supposed to prevent the user interface to appear.
yes and it didn't!
However, these two flags only apply to this instance of the UnityEditor which performs the build ... they do not apply to the actual resulting built application ;)
Usually you would go to the BuildSettings and enable
Server Build
Enable this checkbox to build the Player for server use and with no visual elements (headless) without the need for any command line options. When you enable this option, Unity builds managed scripts
with the UNITY_SERVER define, which means you can write server-specific code for your applications. You can also build to the Windows version as a console app so that stdin and stdout are accessible. Unity logs go to stdout by default.
under CommandLine Arguments you can find for how to trigger a scripted build via the console. Instead of using -buildXYZ you could use -executeMethod and within that method define the exact player and build settings you want before starting the build process
#if UNITY_EDITOR
using System;
using System.IO;
using UnityEditor;
using UnityEngine;
class ScriptedBuilds
{
// Invoked via command line only
static void PerformHeadlessLinuxBuild()
{
// As a fallback use <project root>/BUILD as output path
var buildPath = Path.Combine(Application.dataPath, "BUILD");
// read in command line arguments e.g. add "-buildPath some/Path" if you want a different output path
var args = Environment.GetCommandLineArgs();
for (var i = 0; i < args.Length; i++)
{
if (args[i] == "-buildPath")
{
buildPath = args[i + 1];
}
}
// if the output folder doesn't exist create it now
if (!Directory.Exists(buildPath))
{
Directory.CreateDirectory(buildPath);
}
BuildPipeline.BuildPlayer(
// Simply use the scenes from the build settings
// see https://docs.unity3d.com/ScriptReference/EditorBuildSettings-scenes.html
EditorBuildSettings.scenes,
// pass on the output folder
buildPath,
// Build for Linux 64 bit
BuildTarget.StandaloneLinux64,
// Use Headless mode
// see https://docs.unity3d.com/ScriptReference/BuildOptions.EnableHeadlessMode.html
// and make the build fail for any error
// see https://docs.unity3d.com/ScriptReference/BuildOptions.StrictMode.html
BuildOptions.EnableHeadlessMode | BuildOptions.StrictMode
);
}
}
#endif
and then e.g.
~/Unity/Hub/Editor/2019.4.30f1/Editor/Unity -batchmode -nographics -logfile stdout.log -projectPath /path/to/the/project -executeMethod ScriptedBuilds.PerformHeadlessLinuxBuild -quit
or with a custom build output path
~/Unity/Hub/Editor/2019.4.30f1/Editor/Unity -batchmode -nographics -logfile stdout.log -projectPath /path/to/the/project -buildPath path/to/build/destination -executeMethod ScriptedBuilds.PerformHeadlessLinuxBuild -quit
Maybe you could try to add the #define UNITY_SERVER directive to the top of your script. This will enable the server build and disable visual elements see 'Server Build' option in the 'Platform list' table

SDL2 on Raspberry Pi 4: SDL Initialization failed No available video device

I was having a problem getting one of my programs that uses SDL to compile so to fix it I reinstalled SDL2 and SDL2Image following this link:
https://solarianprogrammer.com/2015/01/22/raspberry-pi-raspbian-getting-started-sdl-2/
I used this link before and have created windows and renderers successfully.
Now the program compiles and runs but I get the error
SDL Initialization failed no available video device
When initializing SDL.
I am not sure what video system is being used because the configuration command disables mir wayland x11 and opengl. The tutorial says something about forcing opengl es.
FOR SDL2:
I downloaded and unpacked the tar file into my home directory, then configured using this command:
../configure --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland --disable-video-x11 --disable-video-opengl
The output was:
SDL2 Configure Summary:
Building Shared Libraries
Building Static Libraries
Enabled modules : atomic audio video render events joystick haptic power filesystem threads timers file loadso cpuinfo assembly
Assembly Math :
Audio drivers : disk dummy oss alsa(dynamic) sndio
Video drivers : dummy opengl_es1 opengl_es2
Input drivers : linuxev linuxkd
Using libudev : YES
Using dbus : YES
I then used: make -j 4
then: sudo make install
FOR SDL2_Image:
I configured with: ../configure, there was no summary
then: make -j 4
then: sudo make install
I just tried the test program that the tutorial link gives and it executes and displays the image properly, here is the code for initializing things:
int main(int argc, char** argv) {
// Initialize SDL
check_error_sdl(SDL_Init(SDL_INIT_VIDEO) != 0, "Unable to initialize SDL");
// Create and initialize a 800x600 window
SDL_Window* window = SDL_CreateWindow("Test SDL 2", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
800, 600, SDL_WINDOW_SHOWN | SDL_WINDOW_OPENGL);
check_error_sdl(window == nullptr, "Unable to create window");
// Create and initialize a hardware accelerated renderer that will be refreshed in sync with your monitor (at approx. 60 Hz)
SDL_Renderer* renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
check_error_sdl(renderer == nullptr, "Unable to create a renderer");
// Set the default renderer color to corn blue
SDL_SetRenderDrawColor(renderer, 100, 149, 237, 255);
// Initialize SDL_img
int flags=IMG_INIT_JPG | IMG_INIT_PNG;
int initted = IMG_Init(flags);
check_error_sdl_img((initted & flags) != flags, "Unable to initialize SDL_image");
I copied that code over exactly to my code and I no longer get the SDL Init. failed but I get these errors:
Unable to initialize SDL_image Invalid renderer
Unable to create texture Invalid renderer
Unable to create texture Invalid renderer
Unable to create texture Invalid renderer
It is a 1-to-1 copy of this test file so I'm not sure what could be going on. Any suggesstions?
UPDATE:
After recompiling the test program it no longer works either and gives the SDL Init failed error. I compiled with this line:
g++ -std=c++0x -Wall -pedantic sdl2_test.cpp -o sdl2_test `sdl2-config --cflags --libs` -lSDL2_image
I reconfigured and installed, instead of configuring with:
../configure --disable-pulseaudio --disable-esd --disable-video-mir --disable-video-wayland --disable-video-x11 --disable-video-opengl
I simply did:
../configure
Not sure if this will introduce other problems down the road but for now the images display and keyboard input can be captured.

run part of code as root

I have a package which runs uses Gtk and written in vala.A dialog box or a gui opens after selecting a file.I want this dialog box or gui to run as root so as to open and read the files which don't open with normal users.I have this code
static void open_file(string filename) {
selected_file = filename;
stdout.printf(selected_file);
new ProgressWindow(selected_file, {});
}
I want to run ProgressWindow to run as root.Is it possible?
No. To run as root, it must be in a separate process and you must run that process using pkexec via PolicyKit. Here's a tutorial on PolicyKit in Vala.

How to execute an InDesign extendscript from command line?

I need to execute a .jsx script for InDesign from command line (Windows).
For Illustrator, it works easily with the following command:
"C:\Program Files\Adobe\Adobe Illustrator CS6 (64 Bit)\Support Files\Contents\Windows\Illustrator.exe" "...\myscript.jsx"
Both applications Illustrator and ExtendScript Toolkit CS6 open then the script is automatically launched.
When I try the same for InDesign, it doesn't work (InDesign says 'Unable to open myscript.jsx ...').
I also tried to launch ExtendScript Toolkit from command line as below:
"C:\Program Files (x86)\Adobe\Adobe Utilities - CS6\ExtendScript Toolkit CS6\ExtendScript Toolkit.exe" "...\myscript.jsx"
The result is ExtendScript Toolkit application is opened with the script loaded, but nothing is executed.
Does anyone know how to launch the script? Is there a -run or -cmd argument to add?
For me on Osx it works like this:
/Applications/Adobe\ ExtendScript\ Toolkit\ CC/ExtendScript\ Toolkit.app/Contents/MacOS/ExtendScript\ Toolkit -run test.jsx
On Windows it should be:
"\path\to\ExtendScript Toolkit.exe" -run test.jsx
content of test.jsx:
//#target indesign
alert(app.name);
It needs the -run flag. When using -cmd it still executes the script but from ESTK. The //#target indesign gets ignored. With the -run the script gets passed to InDesign. Unfortunately the ESTK brings up a dialogue that warns to execute scripts from untrusted sources.
a solution of yours could be to call a visualbasic script from command line. That VB would then call the indesign jsx file based on having referenced teh indesign application itself. Kind of tricky but should definitively work.
If you are trying to execute using node, these are the best two ways I have found to execute Indesign scripts.
Version Agnostic
Credit rendertom inside his vscode/atom plugins.
const outputFilePath = path.resolve(os.homedir(), 'Documents', 'Adobe Scripts', 'myscript.js');
const hostCommand = {
darwin: {
command: 'osascript',
args: [
'-e',
`tell application id "com.adobe.indesign" to do script "${outputFilePath}" language javascript`
],
options: {}
},
win32: {
command: 'powershell',
args: [
'-command',
`"$app = new-object -comobject InDesign.Application; $app.DoScript('${outputFilePath}', 1246973031)"`
],
options: {shell: true} // Windows requires a shell
}
};
if (typeof hostCommand[process.platform] == 'undefined') {
throw new Error('This platform is not supported');
}
const {command, args, options} = hostCommand[process.platform];
const p = spawn(command, args, options);
I don't have Windows at hand to actually test it but I would start by looking at those links:
Run VBS in command line : http://ss64.com/vb/cscript.html
Run InDesign in VB:https://www.google.fr/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&ved=0ahUKEwjj9_3JoPXMAhVI1BoKHUKMBT8QFggfMAA&url=https%3A%2F%2Fwww.adobe.com%2Fcontent%2Fdam%2FAdobe%2Fen%2Fdevnet%2Findesign%2Fsdk%2Fcs6%2Fscripting%2FInDesign_ScriptingGuide_VB.pdf&usg=AFQjCNFP8M8i3xrOqLp0zw3BGcNpnyhEXQ&sig2=pfFYnsgxXDpCf1A573JTDQ&bvm=bv.122676328,d.d2s
Look at the DoScript method for calling a JSX script.
myInDesign.DoScript myJavaScript,
Without ExtendScript Toolkit and on a Mac, you can use AppleScript or JavaScript for Automation (JXA).
This is how it's done in the jasminejsx library to execute jasmine specs in ExtendScript.
osascript -l "JavaScript" -e "var app = new Application('com.adobe.indesign'); app.doScript('$EXTENDSCRIPT', {language: 'javascript'});" &
See code here.