I have a problem running phantomjs.exe binary in my QProcess class. Consider this code:
QString program = "phantomjs.exe";
QProcess *process = new QProcess(this);
process->start(program, QStringList() << "test.js");
When I start the app main process loads up and nothing happens after that, just hundreds of other phantomjs.exe are created (checking it in TaskManager) as well as conhost.exe processes.
I tried other exe files, like notepad.exe, and it works just fine. Notepad window appears.
Did you encounter this problem?
Do you call phantom.exit() in your test script?
https://github.com/ariya/phantomjs/wiki/Quick-Start
console.log('Hello, world!');
phantom.exit();
Hope that helps.
After checking I found that there is a problem with QProcess. I used SHELLEXECUTEINFO instead. This code works for me well. No recursive calls of phantomjs.exe here:
SHELLEXECUTEINFO shExecInfo;
shExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
shExecInfo.fMask = NULL;
shExecInfo.hwnd = NULL;
shExecInfo.lpVerb = L"runas";
shExecInfo.lpFile = L"phantomjs.exe";
shExecInfo.lpParameters = L"test.js";
shExecInfo.lpDirectory = NULL;
shExecInfo.nShow = SW_NORMAL;
shExecInfo.hInstApp = NULL;
ShellExecuteEx(&shExecInfo);
Related
// but the code is throwing unexpected terminal operator new
function MovePokemon(argument0, argument1) {
old = argument0;
new = argument1;
TPartyID = global.PartyID[old]
global.PartyID[old] = global.PartyID[new]
global.PartyID[new] = TPartyID;
new is a keyword in the current versions of GameMaker, so you'll need to rename that variable (say, to _new).
The project in question may leave some to be desired given the complete absence of local variable declarations (var).
Try use this code in your script to avoid use "new"
function MovePokemon(argument0, argument1) {
TPartyID = global.PartyID[argument0]
global.PartyID[argument0] = global.PartyID[argument1]
global.PartyID[argument1] = TPartyID;
I want to attach a report in e-mail. Format of report is PDF. And i use this code for save report with PDF format;
Args args;
reportRun reportRun;
args = new args();
args.name(reportStr("InventTransferShipReport"));
args.caller(this);
args.parm(transferId);
args.parmObject(setRecord);
args.menuItemName(menuitemOutputStr(InventTransferShipReport));
reportRun = new reportRun(args);
reportRun.init();
WinAPI::deleteFile("C:\\Temp\\Test.pdf");
reportRun.printJobSettings().setTarget(PrintMedium::File);
reportRun.printJobSettings().format(PrintFormat::PDF);
reportRun.printJobSettings().fileName("C:\\Temp\\Test.pdf");
reportRun.run();
if(WinAPI::fileExists("C:\\Temp\\Test.pdf"))
{
info("done");
}
else
{
info("error");
}
But when i debugging code i noticed that the process end when reportRun.run(); execute. So why? How can i fixed this issue?
I just started using SALT for a project i am working on. It is said to work with Python but I find quite a bit of difference in thier syntax and overall format. I have pasted a code for a simple task which just opens and imports and loads some libraries onto the SALT console. I hope someone can check abnd see if he/she can instantly identify the language being used and what the code does. This is because i have a suspicion that the code is a mixture between C, Python as well as Java... if that is so doen't that mean it should be a totally different language on its own?
code:
var rtwxlib = import'rtwxlib';
var string = import'string';
var monitor = rtwxlib.Monitor
{
EvActivate = func() { print "Activate\n"; };
EvShutdown = func() { print "Shutdown\n"; };
EvProgress = func(self, fDone, msg = "") {
print("Progress: %d %s \r"::format(fDone*100, msg));
};
EvEventMsg = func(self, msg) {
print("\nEvent: %s\n"::format(iStat, msg));
};
};
var solver = rtwxlib.Solver(monitor);
solver::Open("test.wrx");
solver::DelGeometry();
solver::SaveAs('testresults.wrx');
solver::Close();
I was able to indentify the syntax of the language used as C. I beieve the problem I had which confused me was the libraries used for this code which I later found out was for a particular program. Thank you to all those who tried to help though :)
I have to say I'm kinda newbie with QT stuff.
I've tried to get to work Phonom using sample of code:
audioOutput = new Phonon::AudioOutput(Phonon::MusicCategory, this);
mediaObject = new Phonon::MediaObject(this);
metaInformationResolver = new Phonon::MediaObject(this);
Phonon::createPath(mediaObject, audioOutput);
mediaObject->setCurrentSource(Phonon::MediaSource(":/sound/beep.wav"));
mediaObject->play();
The only warning that apears while compilation is:
"WARNING: Phonon::createPath: Cannot connect Phonon::MediaObject ( no objectName ) to Phonon::AudioOutput ( no objectName ). " - it's results with no sound.
I tried to set device output by hand with no results. Meanwhile checked qmediaplayer example - which works fine.
Does anyone can tell me, what I'm doing wrong?
QT += phonon also included
well first of all I'm not sure why you are calling create path() 2 times at line 3 and 5 with same arguments then i'll try setting source before connecting but i don't think this are the real problems
to me this worked:
Phonon::AudioOutput *audioOutput = new Phonon::AudioOutput();
Phonon::MediaObject *mediaObject = new Phonon::MediaObject();
mediaObject->setCurrentSource(Phonon::MediaSource("PathToFile"));
Phonon::createPath(mediaObject, audioOutput);
Phonon::MediaObject *metaInformationResolver = new Phonon::MediaObject();
mediaObject->play();
In the YSOD below, the stacktrace (and the source file line) contain the full path to the source file. Unfortunately, the full path to the source file name contains my user name, which is firstname.lastname.
I want to keep the YSOD, as well as the stack trace including the filename and line number (it's a demo and testing system), but the username should vanish from the sourcefile path. Seeing the file's path is also OK, but the path should be truncated at the solution root directory.
(without me having to copy-paste the solution every time to another path before publishing it...)
Is there any way to accomplish this ?
Note: Custom error pages aren't an option.
Path is embedded in .pdb files, which are produced by the compiler. The only way to change this is to build your project in some other location, preferably somewhere near the build server.
Never mind, I found it out myself.
Thanks to Anton Gogolev's statement that the path is in the pdb file, I realized it is possible.
One can do a binary search-and-replace on the pdb file, and replace the username with something else.
I quickly tried using this:
https://codereview.stackexchange.com/questions/3226/replace-sequence-of-strings-in-binary-file
and it worked (on 50% of the pdb files).
So mind the crap, that code-snippet in the link seems to be buggy.
But the concept seems to work.
I now use this code:
public static void SizeUnsafeReplaceTextInFile(string strPath, string strTextToSearch, string strTextToReplace)
{
byte[] baBuffer = System.IO.File.ReadAllBytes(strPath);
List<int> lsReplacePositions = new List<int>();
System.Text.Encoding enc = System.Text.Encoding.UTF8;
byte[] baSearchBytes = enc.GetBytes(strTextToSearch);
byte[] baReplaceBytes = enc.GetBytes(strTextToReplace);
var matches = SearchBytePattern(baSearchBytes, baBuffer, ref lsReplacePositions);
if (matches != 0)
{
foreach (var iReplacePosition in lsReplacePositions)
{
for (int i = 0; i < baReplaceBytes.Length; ++i)
{
baBuffer[iReplacePosition + i] = baReplaceBytes[i];
} // Next i
} // Next iReplacePosition
} // End if (matches != 0)
System.IO.File.WriteAllBytes(strPath, baBuffer);
Array.Clear(baBuffer, 0, baBuffer.Length);
Array.Clear(baSearchBytes, 0, baSearchBytes.Length);
Array.Clear(baReplaceBytes, 0, baReplaceBytes.Length);
baBuffer = null;
baSearchBytes = null;
baReplaceBytes = null;
} // End Sub ReplaceTextInFile
Replace firstname.lastname with something that has equally many characters, for example "Poltergeist".
Now I only need to figure out how to run the binary search and replace as a post-build action.