Jump to content

Tommi Prami

Members
  • Content Count

    520
  • Joined

  • Last visited

  • Days Won

    6

Everything posted by Tommi Prami

  1. Coworker made new free Firebird tool with Delphi. 1.0 is just out... https://texteditor.pro/firebird/ There is also superb text editor, which I use in my Delphi coding daily, very good features...
  2. Tommi Prami

    New free firebird tool... (Didn't make it ;) )

    From website I think. https://www.texteditor.pro/support/ -Tee-
  3. Tommi Prami

    New free firebird tool... (Didn't make it ;) )

    Lasse released 1.10 version, some of the initial nastines fixed : https://www.texteditor.pro/firebird/
  4. Thanks for all of your help. Good chat 🙂 .Tee.
  5. OTL is pretty big library, PPL is already there. In our company it is pretty strict what libraries can be imported to our codebase. I rather use OTL for many reasons, but most likely can't justify it. But I think I am solved all problems, only problem is that with PPL code is pretty ugly. Because no proper way to pass workload and receive result. Not too many lines in this case. PPL would benefit some higher level abstraction and helper classes and so, and most important would be documentation. -Tee-
  6. Tommi Prami

    Spell Checker implementation?

    Active Hunspell wrapper project would be cool. Jus saying... 🙂
  7. Always one way to go. Would save some lines of code with PPL. OTL is super cool tough. -Tee-
  8. Below is partial code that does actual running and capturing. It runs just fine but does not always capture the output of app. THere might be something very trivial that I just don't see, and Application.ProcessMessages calls Are not smart for start. Any ideas?? .Tee. const ExecutionTimeout = 60 * 1000; procedure TCommandLineApp.WaitforApp(const AProcessHandle: THandle; const ARaiseTimeoutException: Boolean; const AExplicitTimeOut: Integer = 0); var LApprunning: Cardinal; LStartTick: UInt64; LTimeout: Integer; LExecuteTimeOutExeeded: Boolean; LElapsedTime: UInt64; begin if AExplicitTimeOut <> 0 then LTimeout := AExplicitTimeOut else LTimeout := ExecutionTimeout; LStartTick := GetTickCount64; repeat LApprunning := WaitForSingleObject(AProcessHandle, Min(LTimeout, 100)); // TODO: This is not too smart, I think Application.ProcessMessages; LElapsedTime := Abs(GetTickCount64 - LStartTick); LExecuteTimeOutExeeded := LElapsedTime > LTimeout; until (LApprunning <> WAIT_TIMEOUT) or LExecuteTimeOutExeeded; if LExecuteTimeOutExeeded and ARaiseTimeoutException then raise Exception.Create('Commandline process timeout exeeded'); // TODO: This is not too smart, I think Application.ProcessMessages; end; function TCommandLineApp.InternalExecute(const AFullCommandLine: string; var AReturnedOutput: string): Boolean; function GetSystemErrorMessage: string; begin Result := CommandlineApplication + ': ' + SysErrorMessage(GetLastError); end; var LSecurityAttributes: TSecurityAttributes; LStartupInfo: TStartupInfo; LProcessInfo: TProcessInformation; LStdOutPipeRead, LStdOutPipeWrite: THandle; LWorkDir: string; LHandle: Boolean; LExitCode: DWord; begin Result := False; LSecurityAttributes := InitSecurityAtttributes; if CreatePipe(LStdOutPipeRead, LStdOutPipeWrite, @LSecurityAttributes, 0) then begin try LStartupInfo := InitStartupInfo(LStdOutPipeWrite); LWorkDir := GetCurrentDir; LHandle := CreateProcess(nil, PChar(AFullCommandLine), nil, nil, True, 0, nil, PChar(LWorkDir), LStartupInfo, LProcessInfo); if LHandle then begin try // Give app little bit time to start up (Not sure if needed) WaitforApp(LProcessInfo.hProcess, False, 500); ReadProcessStdOut(AReturnedOutput, LStdOutPipeRead); // If app does wait app hangs "for ever", exception is raised WaitforApp(LProcessInfo.hProcess, True); {TODO : Probaply should handle STILL_ACTIVE, Check out: https://msdn.microsoft.com/en-us/library/windows/desktop/ms683189(v=vs.85).aspx } if GetExitCodeProcess(LProcessInfo.hProcess, LExitCode) then FExitCode := LExitCode else FExitCode := -1; // Don't have rights to check for the exit code Result := (FExitCode = -1) or (FExitCode = 0); if not Result then FLastError := AReturnedOutput; finally CloseHandle(LProcessInfo.hThread); CloseHandle(LProcessInfo.hProcess); end; end else FLastError := GetSystemErrorMessage; finally CloseHandle(LStdOutPipeWrite); CloseHandle(LStdOutPipeRead); end end else FLastError := GetSystemErrorMessage; end;
  9. Tommi Prami

    Running commandline app and capturing output

    No, not going to run OpenSSL, Have used this code with OpenSSL previously. That was just an example. I am going to run internal company commandline tool. Which does some file processing, and I have x number of files, which I would like to run in parallel. Which going to work. Currently it is totally OK; parallel running would be faster. -Tee-
  10. Tommi Prami

    New free firebird tool... (Didn't make it ;) )

    Report to the author. .Tee.
  11. Tommi Prami

    Running commandline app and capturing output

    @Angus Robertson but anyhow, seems that I coudöl fix problems with your code. Need to tinker adound with my current contraption, it is not very clean API-vise. Thanks!! -Tee-
  12. Tommi Prami

    Running commandline app and capturing output

    Angus Robertson, thanks for code, I think this should work without using temp file. Also as it is now can't work if same process is fired multiple times at same time, as I woulöd need to do (easy to fix tough)... -Tee-
  13. Tommi Prami

    New free firebird tool... (Didn't make it ;) )

    Report to the author. I think it should not use gds*dll, but not sure. -Tee-
  14. Overkill for small utility with only few lines of code. And if no other use (For now at least).
  15. Fire up tasks in parallel and feed work to them, way or other, pass work log back and so on. Would be positive to terminate tasks, but that is not that big of a deal right now. Pretty basic stuff, but as I mentioned, I've tried few times to do something with PPL and it seems always been disaster. In way or another. OTL has good documentation and have the book, but as said, can't use it with this. -Tee-
  16. Tommi Prami

    Running commandline app and capturing output

    What I've tested, same app mich or might not get captured, earlier used this code to fire up OpenSSL, bow in house internal App. Now if I run 30 times same app, maybe none get captured, maybe all get captured, or anything in between. -Tee-
  17. Could you clarify which takes which time. I can read that both ways 😄
  18. Tommi Prami

    New free firebird tool... (Didn't make it ;) )

    32-bit version worked for me, because I'll have 32bit FB on computer and client library also.
  19. Tommi Prami

    New free firebird tool... (Didn't make it ;) )

    Send bug report. Dang... Happened for me also... I thinik it is because fot 64bit version and don't have clint library... -Tee-
  20. At first (2007 era) when FastMM4 was added into delphi as default memory manager there was some debug stuff removed I think. Is that the case still? Does anyone know reason why Embarcadero does not use the "full" version of it? Asked around Facebook I think, who uses internal and Who uses latest FastMM4 I think almost all used the latest one instead of one shipped with delphi. Which one you use? -Tee-
  21. Tommi Prami

    With haters unite

    With haters unite, please vote for this : https://quality.embarcadero.com/browse/RSP-18953 Compiler (etc) assisted with removal Refactoring tool would be super cool. Sometimes so error prone to remove by hand, especially nested withs. (oops wrong link at start)
  22. Tommi Prami

    With haters unite

    Sorry about all link hassle.. -tee-
  23. Tommi Prami

    With haters unite

    Damnation, right. This is correct URL: https://quality.embarcadero.com/browse/RSP-18953 Thanks... Copy paste errors all day 😄 -tee-
  24. Tommi Prami

    With haters unite

    Maybe now...
  25. Tommi Prami

    SHA Extensions and Delphi

    Did quick google search to familiarize myself on the subject and ran into this: https://github.com/minio/sha256-simd Seems to be worth checking out. .Tee.
×