-
Content Count
1005 -
Joined
-
Last visited
-
Days Won
66
pyscripter last won the day on July 3
pyscripter had the most liked content!
Community Reputation
788 ExcellentTechnical Information
-
Delphi-Version
Delphi 12 Athens
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
For the record, TurboPower was a good company, but their components were commercial. They were open-sourced their products when the company shut-down their component business. However, they are products of the previous century and they show it. And incidentally, TurboPower was owned by a gambling business (a Casino or something).
-
Is it possible to implement floating/fully custom Dropdown Menus?
pyscripter replied to araujoarthur's topic in VCL
Following on @Anders Melander suggestion you can find here a free implementation of his idea. The library also supports controls on menus and toolbars, is Vcl styles compatible and High-DPI aware. See some of the images here. -
pascal-process: A new library for running processes and redirecting their output.
pyscripter replied to pyscripter's topic in I made this
Done. Thanks.- 2 replies
-
- open-source
- process
-
(and 1 more)
Tagged with:
-
pascal-process: A new library for running processes and redirecting their output.
pyscripter posted a topic in I made this
There are many components/libraries available for running processes and capturing their output. But, I got frustrated with their design and functionality, mostly for the following reasons: Fixation with and premature conversion to strings. Processes produce and consume bytes. Blocking reading of process output, resulting to inefficiencies (tight loops with Sleep, or separate threads for reading the output or providing input to the process) Incomplete features and/or over-bloated So, I have made my own pascal-process single unit library. Main features: Asynchronous reading of process output Separate stdout and stderr reading which can optionally be merged Ability to consume output as it is produced or else let it accumulate and read the final result Ability to provide input to the running process before or while the process is running. Ability to terminate the running process. Synchronous and asynchronous execution of processes. Interfaced-based facilitating memory management. MIT licence Usage: You do not need to install the library. Just download or clone the repo and add the source subdirectory to the Library path. Then add PascalProcess to your uses clause. If you just want to get the output of a process you can use the class functions of TPProcess. TPProcess = class(TInterfacedObject, IPProcess) class function Execute(const ACommandLine: string; const ACurrentDir: string = ''): TBytes; overload; class procedure Execute(const ACommandLine: string; const ACurrentDir: string; out Output, ErrOutput: TBytes) overload; end; This is an example: var Output: TBytes; begin Output := TPProcess.Execute('cmd /c echo Hi'); Writeln(TEncoding.ANSI.GetString(Output)); end; For more demanding cases you can use the IPProcess interface. Example: type TUtils = class class procedure OnRead(Sender: TObject; const Bytes: TBytes); end; class procedure TUtils.OnRead(Sender: TObject; const Bytes: TBytes); begin Writeln(TEncoding.ANSI.GetString(Bytes)); end; procedure Test2; // Processes ouput as it gets produced // The main thread terminates the process var Process: IPProcess; begin Process := TPProcess.Create('cmd /c dir c:\ /s'); Process.OnRead := TUtils.OnRead; WriteLn('Press Enter to start the process. Press Enter again to terminate'); ReadLn; Process.Execute; ReadLn; Process.Terminate; end; See here the definition of IPProcess. Limitations: Currently the library is Windows only. The intention is to support other platforms (help wanted).- 2 replies
-
- open-source
- process
-
(and 1 more)
Tagged with:
-
For now, there are very serious limitations you need to consider when using emNewInterpreterOwnGIL to achieve true parallelism. See for instance the limitations in What’s new in Python 3.14 — Python 3.14.0b3 documentation. Even the innocent looking print command is not thread-safe. And almost nothing can be share between the interpreters. Also there are limitations about what you can import, and P4D modules are not yet considered safe for use with emNewInterpreterOwnGIL. This is changing with the forthcoming python 3.14. It will include a new module concurrent.interpreters that exposes the interpreters with their own GIL to pure python code. There will also be an addition of ways to communicate between the interpreters using queues. See PEP 734. So for example you could store your output to such a queue and print it when everything is finished. But all the above is cutting edge and unless you really need it you should avoid it, If you decide to use it then make sure you fully understand the limitations and implications. I will try to make P4D modules compatible with emNewInterpreterOwnGIL and that would at least give you the option to say add output to a Delphi string list (or something similar) protected with a global lock on the Delphi side. Note that all the above are not related to the free-threading version of Python, which in itself is another story altogether.
-
Getting exitcode (%errorlevel%) of python script
pyscripter replied to gmbouwer's topic in Python4Delphi
It should. Please update to the latest version of P4D and try again. Then report here whether it works. -
These two tests appear to be identical. Parsing them leads to a call result := TJSONNumber.Create(str); where str = '0.1.2' Apparently this succeeds in Delphi 10.4 but correctly fails in later versions. This is easily fixed by using TryStrToFloat before creating the TJSONNumber. @dummzeuch I have committed a potential fix for the above10.4 failed invalid tests. Could you please try again.
-
I have now replaced that call to Contains. Tested with Delphi 11. ✖ comment\after-literal-no-ws.toml: 'inf' is not a valid floating point value ✖ float\inf-and-nan.toml: 'nan' is not a valid floating point value ✖ spec-1.0.0\float-2.toml: 'inf' is not a valid floating point value Completed: 205, Succeeded: 202, Failed: 3 Completed: 529, Succeeded: 529, Failed: 0 ✓ All tests passed! I think I can live with that. Apparently StrToFloat was extended to cope with inf, nan, and -inf in Delphi 12. In Delphi 12 you can serialize such special floating point values. Could you please test again with Delphi 10.4 The parsing might work, but the serializer had many bugs in 10.4.
-
Backward compatibility is going to be an issue at least for the serializer part. Right now I am trying to fix Delphi 11 compatibility. It should be possible to make the parsing staff made compatible with earlier versions of Delphi, as long as TJSONObject exists.
-
TOML 1.1 is not yet official. 1.0 is the latest TOML standard. So they are correctly rejected for now.
-
@dummzeuch Fixed (I think). Could you please try again.
-
There is no need for that, if you clone the project. You just update the submodule.
-
Here: Completed: 205, Succeeded: 205, Failed: 0 ✓ All tests passed! Completed: 529, Succeeded: 529, Failed: 0 ✓ All tests passed! I can guess the issue is with the TFormatSettings in the conversion to float. I wlll fix it.
-
@dummzeuch With the permission of the original author the license has now been changed to the MIT one.
-
See https://github.com/genericptr/fpTOML/issues/5#issuecomment-2983448165